Commits

Christian Widmer committed eeb2036

Fix the range information patching

The way the range information was patched comes from how the
record extention does it. This does not work for us as our
patch is applied on top of those changes which we don't put
onto the shelf.

Comments (0)

Files changed (2)

         self.added, self.removed = countchanges(self.hunk)
 
     def __cmp__(self, rhs):
-        # since the hunk().toline needs to be adjusted when hunks are
+        # since the hunk().fromline needs to be adjusted when hunks are
         # removed/added, we can't take it into account when we cmp
-        attrs = ['header', 'fromline', 'proc', 'hunk', 'added', 'removed']
+        attrs = ['header', 'toline', 'proc', 'hunk', 'added', 'removed']
         for attr in attrs:
             selfattr = getattr(self, attr, None)
             rhsattr = getattr(rhs, attr, None)
             if r == 'y':
                 if fixoffset:
                     chunk = copy.copy(chunk)
-                    chunk.toline += fixoffset
+                    chunk.fromline += fixoffset
                 applied[chunk.filename()].append(chunk)
             else:
-                fixoffset += chunk.removed - chunk.added
+                fixoffset += chunk.added - chunk.removed
     return reduce(operator.add, [h for h in applied.itervalues()
                                  if h[0].special() or len(h) > 1], [])
 
   diff --git a/file1.txt b/file1.txt
   --- a/file1.txt
   +++ b/file1.txt
-  @@ -2,5 +2,4 @@
+  @@ -1,5 +1,4 @@
    1
    2
    3