diff mercurial/patch.py @ 17941:9a6e4d5d7ea8

diff: move diffline to patch module diffline is not part of diff computation, so it makes more sense to place it with other header generation in patch module. In upcoming patches we will generalize this approach for all headers added in the patch, including the git index header.
author Guillermo Pérez <bisho@fb.com>
date Thu, 15 Nov 2012 12:19:03 -0800
parents c84ef0047a94
children 5e655418aa8d
line wrap: on
line diff
--- a/mercurial/patch.py	Thu Nov 15 12:16:08 2012 -0800
+++ b/mercurial/patch.py	Thu Nov 15 12:19:03 2012 -0800
@@ -1664,6 +1664,19 @@
     def join(f):
         return os.path.join(prefix, f)
 
+    def diffline(revs, a, b, opts):
+        parts = ['diff']
+        if opts.git:
+            parts.append('--git')
+        if revs and not opts.git:
+            parts.append(' '.join(["-r %s" % rev for rev in revs]))
+        if opts.git:
+            parts.append('a/%s' % a)
+            parts.append('b/%s' % b)
+        else:
+            parts.append(a)
+        return ' '.join(parts) + '\n'
+
     date1 = util.datestr(ctx1.date())
     man1 = ctx1.manifest()
 
@@ -1749,7 +1762,7 @@
 
         if dodiff:
             if opts.git or revs:
-                header.insert(0, mdiff.diffline(revs, join(a), join(b), opts))
+                header.insert(0, diffline(revs, join(a), join(b), opts))
             if dodiff == 'binary':
                 text = mdiff.b85diff(to, tn)
             else: