Patchwork [2,of,4] trydiff: join filename with prefix only once

login
register
mail settings
Submitter Martin von Zweigbergk
Date Feb. 2, 2015, 11:45 p.m.
Message ID <2ab403e0f991311b6698.1422920711@waste.org>
Download mbox | patch
Permalink /patch/7606/
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 1421448363 28800
#      Fri Jan 16 14:46:03 2015 -0800
# Node ID 2ab403e0f991311b6698038b47bf84ed26ba2ed5
# Parent  e9a8ab833c8ba15c3fb80e274c2cd0b132763ea1
trydiff: join filename with prefix only once

Patch

diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -1739,9 +1739,6 @@ 
 def trydiff(repo, revs, ctx1, ctx2, modified, added, removed,
             copy, getfilectx, opts, losedatafn, prefix):
 
-    def join(f):
-        return posixpath.join(prefix, f)
-
     def addmodehdr(header, mode1, mode2):
         if mode1 != mode2:
             header.append('old mode %s\n' % mode1)
@@ -1855,6 +1852,8 @@ 
                 elif binary or flag2 != flag1:
                     losedatafn(f)
 
+        path1 = posixpath.join(prefix, f1)
+        path2 = posixpath.join(prefix, f2)
         header = []
         if opts.git:
             if content1 is None: # added
@@ -1864,11 +1863,11 @@ 
             else:  # modified/copied/renamed
                 addmodehdr(header, gitmode[flag1], gitmode[flag2])
                 if op is not None:
-                    header.append('%s from %s\n' % (op, join(f1)))
-                    header.append('%s to %s\n' % (op, join(f2)))
+                    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(join(f1), join(f2), revs))
+            header.insert(0, diffline(path1, path2, revs))
         if binarydiff and not opts.nobinary:
             text = mdiff.b85diff(content1, content2)
             if text and opts.git:
@@ -1876,7 +1875,7 @@ 
         else:
             text = mdiff.unidiff(content1, date1,
                                  content2, date2,
-                                 join(f1), join(f2), opts=opts)
+                                 path1, path2, opts=opts)
         if header and (text or len(header) > 1):
             yield ''.join(header)
         if text: