Details
Details
- Reviewers
durin42 - Group Reviewers
hg-reviewers - Commits
- rHG82ee401135dd: py3: handle keyword arguments correctly in cmdutil.py
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
durin42 |
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
return newlyaddedandmodifiedfiles | return newlyaddedandmodifiedfiles | ||||
def parsealiases(cmd): | def parsealiases(cmd): | ||||
return cmd.lstrip("^").split("|") | return cmd.lstrip("^").split("|") | ||||
def setupwrapcolorwrite(ui): | def setupwrapcolorwrite(ui): | ||||
# wrap ui.write so diff output can be labeled/colorized | # wrap ui.write so diff output can be labeled/colorized | ||||
def wrapwrite(orig, *args, **kw): | def wrapwrite(orig, *args, **kw): | ||||
label = kw.pop('label', '') | label = kw.pop(r'label', '') | ||||
for chunk, l in patch.difflabel(lambda: args): | for chunk, l in patch.difflabel(lambda: args): | ||||
orig(chunk, label=label + l) | orig(chunk, label=label + l) | ||||
oldwrite = ui.write | oldwrite = ui.write | ||||
def wrap(*args, **kwargs): | def wrap(*args, **kwargs): | ||||
return wrapwrite(oldwrite, *args, **kwargs) | return wrapwrite(oldwrite, *args, **kwargs) | ||||
setattr(ui, 'write', wrap) | setattr(ui, 'write', wrap) | ||||
return oldwrite | return oldwrite | ||||
del fp | del fp | ||||
# 4. We prepared working directory according to filtered | # 4. We prepared working directory according to filtered | ||||
# patch. Now is the time to delegate the job to | # patch. Now is the time to delegate the job to | ||||
# commit/qrefresh or the like! | # commit/qrefresh or the like! | ||||
# Make all of the pathnames absolute. | # Make all of the pathnames absolute. | ||||
newfiles = [repo.wjoin(nf) for nf in newfiles] | newfiles = [repo.wjoin(nf) for nf in newfiles] | ||||
return commitfunc(ui, repo, *newfiles, **opts) | return commitfunc(ui, repo, *newfiles, **pycompat.strkwargs(opts)) | ||||
finally: | finally: | ||||
# 5. finally restore backed-up files | # 5. finally restore backed-up files | ||||
try: | try: | ||||
dirstate = repo.dirstate | dirstate = repo.dirstate | ||||
for realname, tmpname in backups.iteritems(): | for realname, tmpname in backups.iteritems(): | ||||
ui.debug('restoring %r to %r\n' % (tmpname, realname)) | ui.debug('restoring %r to %r\n' % (tmpname, realname)) | ||||
if dirstate[realname] == 'n': | if dirstate[realname] == 'n': | ||||
# being updated to its first parent. | # being updated to its first parent. | ||||
m = None | m = None | ||||
else: | else: | ||||
m = scmutil.matchfiles(repo, files or []) | m = scmutil.matchfiles(repo, files or []) | ||||
editform = mergeeditform(repo[None], 'import.normal') | editform = mergeeditform(repo[None], 'import.normal') | ||||
if opts.get('exact'): | if opts.get('exact'): | ||||
editor = None | editor = None | ||||
else: | else: | ||||
editor = getcommiteditor(editform=editform, **opts) | editor = getcommiteditor(editform=editform, | ||||
**pycompat.strkwargs(opts)) | |||||
extra = {} | extra = {} | ||||
for idfunc in extrapreimport: | for idfunc in extrapreimport: | ||||
extrapreimportmap[idfunc](repo, extractdata, extra, opts) | extrapreimportmap[idfunc](repo, extractdata, extra, opts) | ||||
overrides = {} | overrides = {} | ||||
if partial: | if partial: | ||||
overrides[('ui', 'allowemptycommit')] = True | overrides[('ui', 'allowemptycommit')] = True | ||||
with repo.ui.configoverride(overrides, 'import'): | with repo.ui.configoverride(overrides, 'import'): | ||||
n = repo.commit(message, user, | n = repo.commit(message, user, | ||||
copies.append((fn, rename[0])) | copies.append((fn, rename[0])) | ||||
revmatchfn = None | revmatchfn = None | ||||
if filematcher is not None: | if filematcher is not None: | ||||
revmatchfn = filematcher(ctx.rev()) | revmatchfn = filematcher(ctx.rev()) | ||||
edges = edgefn(type, char, state, rev, parents) | edges = edgefn(type, char, state, rev, parents) | ||||
firstedge = next(edges) | firstedge = next(edges) | ||||
width = firstedge[2] | width = firstedge[2] | ||||
displayer.show(ctx, copies=copies, matchfn=revmatchfn, | displayer.show(ctx, copies=copies, matchfn=revmatchfn, | ||||
_graphwidth=width, **props) | _graphwidth=width, **pycompat.strkwargs(props)) | ||||
lines = displayer.hunk.pop(rev).split('\n') | lines = displayer.hunk.pop(rev).split('\n') | ||||
if not lines[-1]: | if not lines[-1]: | ||||
del lines[-1] | del lines[-1] | ||||
displayer.flush(ctx) | displayer.flush(ctx) | ||||
for type, char, width, coldata in itertools.chain([firstedge], edges): | for type, char, width, coldata in itertools.chain([firstedge], edges): | ||||
graphmod.ascii(ui, state, type, char, lines, coldata) | graphmod.ascii(ui, state, type, char, lines, coldata) | ||||
lines = [] | lines = [] | ||||
displayer.close() | displayer.close() | ||||
if warn: | if warn: | ||||
for warning in warnings: | for warning in warnings: | ||||
ui.warn(warning) | ui.warn(warning) | ||||
return ret | return ret | ||||
def cat(ui, repo, ctx, matcher, basefm, fntemplate, prefix, **opts): | def cat(ui, repo, ctx, matcher, basefm, fntemplate, prefix, **opts): | ||||
err = 1 | err = 1 | ||||
opts = pycompat.byteskwargs(opts) | |||||
def write(path): | def write(path): | ||||
filename = None | filename = None | ||||
if fntemplate: | if fntemplate: | ||||
filename = makefilename(repo, fntemplate, ctx.node(), | filename = makefilename(repo, fntemplate, ctx.node(), | ||||
pathname=os.path.join(prefix, path)) | pathname=os.path.join(prefix, path)) | ||||
# attempt to create the directory if it does not already exist | # attempt to create the directory if it does not already exist | ||||
try: | try: | ||||
err = 0 | err = 0 | ||||
for subpath in sorted(ctx.substate): | for subpath in sorted(ctx.substate): | ||||
sub = ctx.sub(subpath) | sub = ctx.sub(subpath) | ||||
try: | try: | ||||
submatch = matchmod.subdirmatcher(subpath, matcher) | submatch = matchmod.subdirmatcher(subpath, matcher) | ||||
if not sub.cat(submatch, basefm, fntemplate, | if not sub.cat(submatch, basefm, fntemplate, | ||||
os.path.join(prefix, sub._path), **opts): | os.path.join(prefix, sub._path), | ||||
**pycompat.strkwargs(opts)): | |||||
err = 0 | err = 0 | ||||
except error.RepoLookupError: | except error.RepoLookupError: | ||||
ui.status(_("skipping missing subrepository: %s\n") | ui.status(_("skipping missing subrepository: %s\n") | ||||
% os.path.join(prefix, subpath)) | % os.path.join(prefix, subpath)) | ||||
return err | return err | ||||
def commit(ui, repo, commitfunc, pats, opts): | def commit(ui, repo, commitfunc, pats, opts): |