# HG changeset patch # User Martin von Zweigbergk # Date 1421448363 28800 # Node ID e02888efc5aaf3372bad71179082c7e4955fe760 # Parent b65637247c699fe5d803f0237160e30525b0cb4c trydiff: join filename with prefix only once diff -r b65637247c69 -r e02888efc5aa mercurial/patch.py --- a/mercurial/patch.py Thu Jan 22 17:00:54 2015 -0800 +++ b/mercurial/patch.py Fri Jan 16 14:46:03 2015 -0800 @@ -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: