Details
Details
- Reviewers
durin42 - Group Reviewers
hg-reviewers - Commits
- rHG3da4bd50103d: py3: fix handling of keyword arguments in revert
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
( )
durin42 |
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/cmdutil.py (4 lines) | |||
M | mercurial/commands.py (4 lines) | |||
M | mercurial/subrepo.py (12 lines) |
repo.ui.write(_('committed changeset %d:%s\n') % (int(ctx), ctx.hex())) | repo.ui.write(_('committed changeset %d:%s\n') % (int(ctx), ctx.hex())) | ||||
elif repo.ui.verbose: | elif repo.ui.verbose: | ||||
repo.ui.write(_('committed changeset %d:%s\n') % (int(ctx), ctx)) | repo.ui.write(_('committed changeset %d:%s\n') % (int(ctx), ctx)) | ||||
def postcommitstatus(repo, pats, opts): | def postcommitstatus(repo, pats, opts): | ||||
return repo.status(match=scmutil.match(repo[None], pats, opts)) | return repo.status(match=scmutil.match(repo[None], pats, opts)) | ||||
def revert(ui, repo, ctx, parents, *pats, **opts): | def revert(ui, repo, ctx, parents, *pats, **opts): | ||||
opts = pycompat.byteskwargs(opts) | |||||
parent, p2 = parents | parent, p2 = parents | ||||
node = ctx.node() | node = ctx.node() | ||||
mf = ctx.manifest() | mf = ctx.manifest() | ||||
if node == p2: | if node == p2: | ||||
parent = p2 | parent = p2 | ||||
# need all matching names in dirstate and manifest of target rev, | # need all matching names in dirstate and manifest of target rev, | ||||
needdata = ('revert', 'add', 'undelete') | needdata = ('revert', 'add', 'undelete') | ||||
_revertprefetch(repo, ctx, *[actions[name][0] for name in needdata]) | _revertprefetch(repo, ctx, *[actions[name][0] for name in needdata]) | ||||
_performrevert(repo, parents, ctx, actions, interactive, tobackup) | _performrevert(repo, parents, ctx, actions, interactive, tobackup) | ||||
if targetsubs: | if targetsubs: | ||||
# Revert the subrepos on the revert list | # Revert the subrepos on the revert list | ||||
for sub in targetsubs: | for sub in targetsubs: | ||||
try: | try: | ||||
wctx.sub(sub).revert(ctx.substate[sub], *pats, **opts) | wctx.sub(sub).revert(ctx.substate[sub], *pats, | ||||
**pycompat.strkwargs(opts)) | |||||
except KeyError: | except KeyError: | ||||
raise error.Abort("subrepository '%s' does not exist in %s!" | raise error.Abort("subrepository '%s' does not exist in %s!" | ||||
% (sub, short(ctx.node()))) | % (sub, short(ctx.node()))) | ||||
def _revertprefetch(repo, ctx, *files): | def _revertprefetch(repo, ctx, *files): | ||||
"""Let extension changing the storage layer prefetch content""" | """Let extension changing the storage layer prefetch content""" | ||||
def _performrevert(repo, parents, ctx, actions, interactive=False, | def _performrevert(repo, parents, ctx, actions, interactive=False, |
See :hg:`help dates` for a list of formats valid for -d/--date. | See :hg:`help dates` for a list of formats valid for -d/--date. | ||||
See :hg:`help backout` for a way to reverse the effect of an | See :hg:`help backout` for a way to reverse the effect of an | ||||
earlier changeset. | earlier changeset. | ||||
Returns 0 on success. | Returns 0 on success. | ||||
""" | """ | ||||
opts = pycompat.byteskwargs(opts) | |||||
if opts.get("date"): | if opts.get("date"): | ||||
if opts.get("rev"): | if opts.get("rev"): | ||||
raise error.Abort(_("you can't specify a revision and a date")) | raise error.Abort(_("you can't specify a revision and a date")) | ||||
opts["rev"] = cmdutil.finddate(ui, repo, opts["date"]) | opts["rev"] = cmdutil.finddate(ui, repo, opts["date"]) | ||||
parent, p2 = repo.dirstate.parents() | parent, p2 = repo.dirstate.parents() | ||||
if not opts.get('rev') and p2 != nullid: | if not opts.get('rev') and p2 != nullid: | ||||
# revert after merge is a trap for new users (issue2915) | # revert after merge is a trap for new users (issue2915) | ||||
hint = _("use --all to revert all files," | hint = _("use --all to revert all files," | ||||
" or 'hg update %s' to update") % ctx.rev() | " or 'hg update %s' to update") % ctx.rev() | ||||
elif dirty: | elif dirty: | ||||
hint = _("uncommitted changes, use --all to discard all changes") | hint = _("uncommitted changes, use --all to discard all changes") | ||||
else: | else: | ||||
hint = _("use --all to revert all files") | hint = _("use --all to revert all files") | ||||
raise error.Abort(msg, hint=hint) | raise error.Abort(msg, hint=hint) | ||||
return cmdutil.revert(ui, repo, ctx, (parent, p2), *pats, **opts) | return cmdutil.revert(ui, repo, ctx, (parent, p2), *pats, | ||||
**pycompat.strkwargs(opts)) | |||||
@command('rollback', dryrunopts + | @command('rollback', dryrunopts + | ||||
[('f', 'force', False, _('ignore safety measures'))]) | [('f', 'force', False, _('ignore safety measures'))]) | ||||
def rollback(ui, repo, **opts): | def rollback(ui, repo, **opts): | ||||
"""roll back the last transaction (DANGEROUS) (DEPRECATED) | """roll back the last transaction (DANGEROUS) (DEPRECATED) | ||||
Please use :hg:`commit --amend` instead of rollback to correct | Please use :hg:`commit --amend` instead of rollback to correct | ||||
mistakes in the last commit. | mistakes in the last commit. |
@annotatesubrepoerror | @annotatesubrepoerror | ||||
def revert(self, substate, *pats, **opts): | def revert(self, substate, *pats, **opts): | ||||
# reverting a subrepo is a 2 step process: | # reverting a subrepo is a 2 step process: | ||||
# 1. if the no_backup is not set, revert all modified | # 1. if the no_backup is not set, revert all modified | ||||
# files inside the subrepo | # files inside the subrepo | ||||
# 2. update the subrepo to the revision specified in | # 2. update the subrepo to the revision specified in | ||||
# the corresponding substate dictionary | # the corresponding substate dictionary | ||||
self.ui.status(_('reverting subrepo %s\n') % substate[0]) | self.ui.status(_('reverting subrepo %s\n') % substate[0]) | ||||
if not opts.get('no_backup'): | if not opts.get(r'no_backup'): | ||||
# Revert all files on the subrepo, creating backups | # Revert all files on the subrepo, creating backups | ||||
# Note that this will not recursively revert subrepos | # Note that this will not recursively revert subrepos | ||||
# We could do it if there was a set:subrepos() predicate | # We could do it if there was a set:subrepos() predicate | ||||
opts = opts.copy() | opts = opts.copy() | ||||
opts['date'] = None | opts[r'date'] = None | ||||
opts['rev'] = substate[1] | opts[r'rev'] = substate[1] | ||||
self.filerevert(*pats, **opts) | self.filerevert(*pats, **opts) | ||||
# Update the repo to the revision specified in the given substate | # Update the repo to the revision specified in the given substate | ||||
if not opts.get('dry_run'): | if not opts.get(r'dry_run'): | ||||
self.get(substate, overwrite=True) | self.get(substate, overwrite=True) | ||||
def filerevert(self, *pats, **opts): | def filerevert(self, *pats, **opts): | ||||
ctx = self._repo[opts['rev']] | ctx = self._repo[opts[r'rev']] | ||||
parents = self._repo.dirstate.parents() | parents = self._repo.dirstate.parents() | ||||
if opts.get('all'): | if opts.get(r'all'): | ||||
pats = ['set:modified()'] | pats = ['set:modified()'] | ||||
else: | else: | ||||
pats = [] | pats = [] | ||||
cmdutil.revert(self.ui, self._repo, ctx, parents, *pats, **opts) | cmdutil.revert(self.ui, self._repo, ctx, parents, *pats, **opts) | ||||
def shortid(self, revid): | def shortid(self, revid): | ||||
return revid[:12] | return revid[:12] | ||||