| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 ## Copyright (c) 2012 The WebM project authors. All Rights Reserved. | 2 ## Copyright (c) 2012 The WebM project authors. All Rights Reserved. |
| 3 ## | 3 ## |
| 4 ## Use of this source code is governed by a BSD-style license | 4 ## Use of this source code is governed by a BSD-style license |
| 5 ## that can be found in the LICENSE file in the root of the source | 5 ## that can be found in the LICENSE file in the root of the source |
| 6 ## tree. An additional intellectual property rights grant can be found | 6 ## tree. An additional intellectual property rights grant can be found |
| 7 ## in the file PATENTS. All contributing project authors may | 7 ## in the file PATENTS. All contributing project authors may |
| 8 ## be found in the AUTHORS file in the root of the source tree. | 8 ## be found in the AUTHORS file in the root of the source tree. |
| 9 ## | 9 ## |
| 10 """Classes for representing diff pieces.""" | 10 """Classes for representing diff pieces.""" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 | 49 |
| 50 def Append(self, line): | 50 def Append(self, line): |
| 51 """Adds a line to the DiffHunk and its DiffLines children.""" | 51 """Adds a line to the DiffHunk and its DiffLines children.""" |
| 52 if line[0] == "-": | 52 if line[0] == "-": |
| 53 self.left.Append(line) | 53 self.left.Append(line) |
| 54 elif line[0] == "+": | 54 elif line[0] == "+": |
| 55 self.right.Append(line) | 55 self.right.Append(line) |
| 56 elif line[0] == " ": | 56 elif line[0] == " ": |
| 57 self.left.Append(line) | 57 self.left.Append(line) |
| 58 self.right.Append(line) | 58 self.right.Append(line) |
| 59 elif line[0] == "\\": |
| 60 # Ignore newline messages from git diff. |
| 61 pass |
| 59 else: | 62 else: |
| 60 assert False, ("Unrecognized character at start of diff line " | 63 assert False, ("Unrecognized character at start of diff line " |
| 61 "%r" % line[0]) | 64 "%r" % line[0]) |
| 62 self.lines.append(line) | 65 self.lines.append(line) |
| 63 | 66 |
| 64 def Complete(self): | 67 def Complete(self): |
| 65 return self.left.Complete() and self.right.Complete() | 68 return self.left.Complete() and self.right.Complete() |
| 66 | 69 |
| 67 def __repr__(self): | 70 def __repr__(self): |
| 68 return "DiffHunk(%s, %s, len %d)" % ( | 71 return "DiffHunk(%s, %s, len %d)" % ( |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 hunk.Append(line) | 121 hunk.Append(line) |
| 119 | 122 |
| 120 # See if the whole hunk has been parsed. If so, yield it and prepare | 123 # See if the whole hunk has been parsed. If so, yield it and prepare |
| 121 # for the next hunk. | 124 # for the next hunk. |
| 122 if hunk.Complete(): | 125 if hunk.Complete(): |
| 123 yield hunk | 126 yield hunk |
| 124 hunk = None | 127 hunk = None |
| 125 | 128 |
| 126 # Partial hunks are a parse error | 129 # Partial hunks are a parse error |
| 127 assert hunk is None | 130 assert hunk is None |
| OLD | NEW |