# HG changeset patch # User Guillermo PĂ©rez # Date 1353020792 28800 # 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 -r 7ac2a7720724 -r 45766e2a7384 mercurial/patch.py --- a/mercurial/patch.py Thu Nov 15 13:57:03 2012 -0800 +++ b/mercurial/patch.py Thu Nov 15 15:06:32 2012 -0800 @@ -1651,18 +1651,17 @@ '''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 @@ 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 @@ 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: