changeset 24020:cc81e6da0757

trydiff: move git-header code out of diffline function This collects more of the code for writing git headers in a single place and makes diffline() close on a few variables less.
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 16 Jan 2015 14:58:06 -0800
parents 26fbf07482b2
children f51a822dcf3b
files mercurial/patch.py
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/patch.py	Tue Jan 27 09:22:59 2015 -0500
+++ b/mercurial/patch.py	Fri Jan 16 14:58:06 2015 -0800
@@ -1754,9 +1754,7 @@
         bprefix = 'b/'
 
     def diffline(a, b, revs):
-        if opts.git:
-            line = 'diff --git %s%s %s%s\n' % (aprefix, a, bprefix, b)
-        elif not repo.ui.quiet:
+        if not repo.ui.quiet:
             if revs:
                 revinfo = ' '.join(["-r %s" % rev for rev in revs])
                 line = 'diff %s %s\n' % (revinfo, a)
@@ -1847,9 +1845,11 @@
         path1 = posixpath.join(prefix, f1)
         path2 = posixpath.join(prefix, f2)
         header = []
-        if opts.git or revs:
+        if revs:
             header.append(diffline(path1, path2, revs))
-        if opts.git:
+        elif opts.git:
+            header.append('diff --git %s%s %s%s\n' %
+                          (aprefix, path1, bprefix, path2))
             if content1 is None: # added
                 header.append('new file mode %s\n' % gitmode[flag2])
             elif content2 is None: # removed