# HG changeset patch # User Guillermo PĂ©rez # Date 2012-11-15 23:06:32 # Node ID 45766e2a7384097463c31ea16ecf037002b8bd92 # Parent 7ac2a7720724529fa149ac91f2bae3c2253ec643 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,18 +1651,17 @@ def diffui(*args, **kw): '''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): def join(f): return os.path.join(prefix, f) + 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) @@ -1707,7 +1706,7 @@ def trydiff(repo, revs, ctx1, ctx2, modi 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) @@ -1753,7 +1752,7 @@ def trydiff(repo, revs, ctx1, ctx2, modi 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: