Patchwork [4,of,4] trydiff: order header-writing code in same order as output

login
register
mail settings
Submitter Martin von Zweigbergk
Date Feb. 2, 2015, 11:45 p.m.
Message ID <d77b71a6b396569da1a1.1422920713@waste.org>
Download mbox | patch
Permalink /patch/7608/
State Accepted
Headers show

Comments

Martin von Zweigbergk - Feb. 2, 2015, 11:45 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1421448548 28800
#      Fri Jan 16 14:49:08 2015 -0800
# Node ID d77b71a6b396569da1a10ae5b5a6365fc9f9f0a3
# Parent  31dcd28149e033c4bf523790d1a266628684d294
trydiff: order header-writing code in same order as output

Instead of inserting a line before the others header lines, move the
code that writes that line before the code that writes the other
lines.
Pierre-Yves David - Feb. 3, 2015, 11:09 a.m.
On 02/02/2015 11:45 PM, Martin von Zweigbergk wrote:
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@google.com>
> # Date 1421448548 28800
> #      Fri Jan 16 14:49:08 2015 -0800
> # Node ID d77b71a6b396569da1a10ae5b5a6365fc9f9f0a3
> # Parent  31dcd28149e033c4bf523790d1a266628684d294
> trydiff: order header-writing code in same order as output

Pushed to the clowncopter, thanks.

Patch

diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -1850,6 +1850,8 @@ 
         path1 = posixpath.join(prefix, f1)
         path2 = posixpath.join(prefix, f2)
         header = []
+        if opts.git or revs:
+            header.append(diffline(path1, path2, revs))
         if opts.git:
             if content1 is None: # added
                 header.append('new file mode %s\n' % gitmode[flag2])
@@ -1864,8 +1866,6 @@ 
                     header.append('%s from %s\n' % (op, path1))
                     header.append('%s to %s\n' % (op, path2))
 
-        if opts.git or revs:
-            header.insert(0, diffline(path1, path2, revs))
         if binarydiff and not opts.nobinary:
             text = mdiff.b85diff(content1, content2)
             if text and opts.git: