Mercurial > hg
comparison mercurial/cmdutil.py @ 35350:82ee401135dd
py3: handle keyword arguments correctly in cmdutil.py
Differential Revision: https://phab.mercurial-scm.org/D1626
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Sun, 10 Dec 2017 04:45:10 +0530 |
parents | 6ba79cf34f5e |
children | 8a0cac20a1ad |
comparison
equal
deleted
inserted
replaced
35349:a274c4b698f2 | 35350:82ee401135dd |
---|---|
179 return cmd.lstrip("^").split("|") | 179 return cmd.lstrip("^").split("|") |
180 | 180 |
181 def setupwrapcolorwrite(ui): | 181 def setupwrapcolorwrite(ui): |
182 # wrap ui.write so diff output can be labeled/colorized | 182 # wrap ui.write so diff output can be labeled/colorized |
183 def wrapwrite(orig, *args, **kw): | 183 def wrapwrite(orig, *args, **kw): |
184 label = kw.pop('label', '') | 184 label = kw.pop(r'label', '') |
185 for chunk, l in patch.difflabel(lambda: args): | 185 for chunk, l in patch.difflabel(lambda: args): |
186 orig(chunk, label=label + l) | 186 orig(chunk, label=label + l) |
187 | 187 |
188 oldwrite = ui.write | 188 oldwrite = ui.write |
189 def wrap(*args, **kwargs): | 189 def wrap(*args, **kwargs): |
370 # patch. Now is the time to delegate the job to | 370 # patch. Now is the time to delegate the job to |
371 # commit/qrefresh or the like! | 371 # commit/qrefresh or the like! |
372 | 372 |
373 # Make all of the pathnames absolute. | 373 # Make all of the pathnames absolute. |
374 newfiles = [repo.wjoin(nf) for nf in newfiles] | 374 newfiles = [repo.wjoin(nf) for nf in newfiles] |
375 return commitfunc(ui, repo, *newfiles, **opts) | 375 return commitfunc(ui, repo, *newfiles, **pycompat.strkwargs(opts)) |
376 finally: | 376 finally: |
377 # 5. finally restore backed-up files | 377 # 5. finally restore backed-up files |
378 try: | 378 try: |
379 dirstate = repo.dirstate | 379 dirstate = repo.dirstate |
380 for realname, tmpname in backups.iteritems(): | 380 for realname, tmpname in backups.iteritems(): |
1332 m = scmutil.matchfiles(repo, files or []) | 1332 m = scmutil.matchfiles(repo, files or []) |
1333 editform = mergeeditform(repo[None], 'import.normal') | 1333 editform = mergeeditform(repo[None], 'import.normal') |
1334 if opts.get('exact'): | 1334 if opts.get('exact'): |
1335 editor = None | 1335 editor = None |
1336 else: | 1336 else: |
1337 editor = getcommiteditor(editform=editform, **opts) | 1337 editor = getcommiteditor(editform=editform, |
1338 **pycompat.strkwargs(opts)) | |
1338 extra = {} | 1339 extra = {} |
1339 for idfunc in extrapreimport: | 1340 for idfunc in extrapreimport: |
1340 extrapreimportmap[idfunc](repo, extractdata, extra, opts) | 1341 extrapreimportmap[idfunc](repo, extractdata, extra, opts) |
1341 overrides = {} | 1342 overrides = {} |
1342 if partial: | 1343 if partial: |
2715 revmatchfn = filematcher(ctx.rev()) | 2716 revmatchfn = filematcher(ctx.rev()) |
2716 edges = edgefn(type, char, state, rev, parents) | 2717 edges = edgefn(type, char, state, rev, parents) |
2717 firstedge = next(edges) | 2718 firstedge = next(edges) |
2718 width = firstedge[2] | 2719 width = firstedge[2] |
2719 displayer.show(ctx, copies=copies, matchfn=revmatchfn, | 2720 displayer.show(ctx, copies=copies, matchfn=revmatchfn, |
2720 _graphwidth=width, **props) | 2721 _graphwidth=width, **pycompat.strkwargs(props)) |
2721 lines = displayer.hunk.pop(rev).split('\n') | 2722 lines = displayer.hunk.pop(rev).split('\n') |
2722 if not lines[-1]: | 2723 if not lines[-1]: |
2723 del lines[-1] | 2724 del lines[-1] |
2724 displayer.flush(ctx) | 2725 displayer.flush(ctx) |
2725 for type, char, width, coldata in itertools.chain([firstedge], edges): | 2726 for type, char, width, coldata in itertools.chain([firstedge], edges): |
3006 | 3007 |
3007 return ret | 3008 return ret |
3008 | 3009 |
3009 def cat(ui, repo, ctx, matcher, basefm, fntemplate, prefix, **opts): | 3010 def cat(ui, repo, ctx, matcher, basefm, fntemplate, prefix, **opts): |
3010 err = 1 | 3011 err = 1 |
3012 opts = pycompat.byteskwargs(opts) | |
3011 | 3013 |
3012 def write(path): | 3014 def write(path): |
3013 filename = None | 3015 filename = None |
3014 if fntemplate: | 3016 if fntemplate: |
3015 filename = makefilename(repo, fntemplate, ctx.node(), | 3017 filename = makefilename(repo, fntemplate, ctx.node(), |
3048 sub = ctx.sub(subpath) | 3050 sub = ctx.sub(subpath) |
3049 try: | 3051 try: |
3050 submatch = matchmod.subdirmatcher(subpath, matcher) | 3052 submatch = matchmod.subdirmatcher(subpath, matcher) |
3051 | 3053 |
3052 if not sub.cat(submatch, basefm, fntemplate, | 3054 if not sub.cat(submatch, basefm, fntemplate, |
3053 os.path.join(prefix, sub._path), **opts): | 3055 os.path.join(prefix, sub._path), |
3056 **pycompat.strkwargs(opts)): | |
3054 err = 0 | 3057 err = 0 |
3055 except error.RepoLookupError: | 3058 except error.RepoLookupError: |
3056 ui.status(_("skipping missing subrepository: %s\n") | 3059 ui.status(_("skipping missing subrepository: %s\n") |
3057 % os.path.join(prefix, subpath)) | 3060 % os.path.join(prefix, subpath)) |
3058 | 3061 |