[PATCH 07 of 12] patch: make _addmodehdr a function under trydiff
Guillermo Pérez
bisho at fb.com
Thu Nov 15 17:23:37 CST 2012
# HG changeset patch
# User Guillermo Pérez <bisho at fb.com>
# Date 1353020792 28800
# Node ID d9c10c486865863951e9fa3647b6a2895f090765
# Parent 80e1a05abbe1f3f92ec7efe149d6dda9fa512b63
patch: make _addmodehdr a function under trydiff
addmodehdr is a header helper, same as diffline, so it doesn't
need to be a top-level function and can be nested under trydiff.
In upcoming patches we will generalize this approach for
all headers.
diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -1651,12 +1651,6 @@
'''like diff(), but yields 2-tuples of (output, label) for ui.write()'''
return difflabel(diff, *args, **kw)
-
-def _addmodehdr(header, omode, nmode):
- if omode != nmode:
- header.append('old mode %s\n' % omode)
- header.append('new mode %s\n' % nmode)
-
def trydiff(repo, revs, ctx1, ctx2, modified, added, removed,
copy, getfilectx, opts, losedatafn, prefix):
@@ -1664,6 +1658,11 @@
return os.path.join(prefix, f)
''' Helper header functions '''
+ def addmodehdr(header, omode, nmode):
+ if omode != nmode:
+ header.append('old mode %s\n' % omode)
+ header.append('new mode %s\n' % nmode)
+
def diffline(a, b, revs):
if opts.git:
line = 'diff --git a/%s b/%s\n' % (a, b)
@@ -1708,7 +1707,7 @@
else:
a = copyto[f]
omode = gitmode[man1.flags(a)]
- _addmodehdr(header, omode, mode)
+ addmodehdr(header, omode, mode)
if a in removed and a not in gone:
op = 'rename'
gone.add(a)
@@ -1754,7 +1753,7 @@
nflag = ctx2.flags(f)
binary = util.binary(to) or util.binary(tn)
if opts.git:
- _addmodehdr(header, gitmode[oflag], gitmode[nflag])
+ addmodehdr(header, gitmode[oflag], gitmode[nflag])
if binary:
dodiff = 'binary'
elif binary or nflag != oflag:
More information about the Mercurial-devel
mailing list