Details
Details
- Reviewers
durin42 - Group Reviewers
hg-reviewers - Commits
- rHGf10cb49951e1: forget: rename --confirm to --interactive
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 | hgext/largefiles/overrides.py (5 lines) | |||
M | mercurial/cmdutil.py (14 lines) | |||
M | mercurial/commands.py (8 lines) | |||
M | mercurial/subrepo.py (6 lines) | |||
M | tests/test-add.t (18 lines) | |||
M | tests/test-completion.t (2 lines) |
def postcommitstatus(orig, repo, *args, **kwargs): | def postcommitstatus(orig, repo, *args, **kwargs): | ||||
repo.lfstatus = True | repo.lfstatus = True | ||||
try: | try: | ||||
return orig(repo, *args, **kwargs) | return orig(repo, *args, **kwargs) | ||||
finally: | finally: | ||||
repo.lfstatus = False | repo.lfstatus = False | ||||
def cmdutilforget(orig, ui, repo, match, prefix, explicitonly, dryrun, confirm): | def cmdutilforget(orig, ui, repo, match, prefix, explicitonly, dryrun, | ||||
interactive): | |||||
normalmatcher = composenormalfilematcher(match, repo[None].manifest()) | normalmatcher = composenormalfilematcher(match, repo[None].manifest()) | ||||
bad, forgot = orig(ui, repo, normalmatcher, prefix, explicitonly, dryrun, | bad, forgot = orig(ui, repo, normalmatcher, prefix, explicitonly, dryrun, | ||||
confirm) | interactive) | ||||
m = composelargefilematcher(match, repo[None].manifest()) | m = composelargefilematcher(match, repo[None].manifest()) | ||||
try: | try: | ||||
repo.lfstatus = True | repo.lfstatus = True | ||||
s = repo.status(match=m, clean=True) | s = repo.status(match=m, clean=True) | ||||
finally: | finally: | ||||
repo.lfstatus = False | repo.lfstatus = False | ||||
manifest = repo[None].manifest() | manifest = repo[None].manifest() |
webconf[serverpath] = repo.root | webconf[serverpath] = repo.root | ||||
repo.ui.debug('adding %s = %s\n' % (serverpath, repo.root)) | repo.ui.debug('adding %s = %s\n' % (serverpath, repo.root)) | ||||
for r in repo.revs('filelog("path:.hgsub")'): | for r in repo.revs('filelog("path:.hgsub")'): | ||||
ctx = repo[r] | ctx = repo[r] | ||||
for subpath in ctx.substate: | for subpath in ctx.substate: | ||||
ctx.sub(subpath).addwebdirpath(serverpath, webconf) | ctx.sub(subpath).addwebdirpath(serverpath, webconf) | ||||
def forget(ui, repo, match, prefix, explicitonly, dryrun, confirm): | def forget(ui, repo, match, prefix, explicitonly, dryrun, interactive): | ||||
if dryrun and confirm: | if dryrun and interactive: | ||||
raise error.Abort(_("cannot specify both --dry-run and --confirm")) | raise error.Abort(_("cannot specify both --dry-run and --interactive")) | ||||
join = lambda f: os.path.join(prefix, f) | join = lambda f: os.path.join(prefix, f) | ||||
bad = [] | bad = [] | ||||
badfn = lambda x, y: bad.append(x) or match.bad(x, y) | badfn = lambda x, y: bad.append(x) or match.bad(x, y) | ||||
wctx = repo[None] | wctx = repo[None] | ||||
forgot = [] | forgot = [] | ||||
s = repo.status(match=matchmod.badmatch(match, badfn), clean=True) | s = repo.status(match=matchmod.badmatch(match, badfn), clean=True) | ||||
forget = sorted(s.modified + s.added + s.deleted + s.clean) | forget = sorted(s.modified + s.added + s.deleted + s.clean) | ||||
if explicitonly: | if explicitonly: | ||||
forget = [f for f in forget if match.exact(f)] | forget = [f for f in forget if match.exact(f)] | ||||
for subpath in sorted(wctx.substate): | for subpath in sorted(wctx.substate): | ||||
sub = wctx.sub(subpath) | sub = wctx.sub(subpath) | ||||
try: | try: | ||||
submatch = matchmod.subdirmatcher(subpath, match) | submatch = matchmod.subdirmatcher(subpath, match) | ||||
subbad, subforgot = sub.forget(submatch, prefix, | subbad, subforgot = sub.forget(submatch, prefix, dryrun=dryrun, | ||||
dryrun=dryrun, confirm=confirm) | interactive=interactive) | ||||
bad.extend([subpath + '/' + f for f in subbad]) | bad.extend([subpath + '/' + f for f in subbad]) | ||||
forgot.extend([subpath + '/' + f for f in subforgot]) | forgot.extend([subpath + '/' + f for f in subforgot]) | ||||
except error.LookupError: | except error.LookupError: | ||||
ui.status(_("skipping missing subrepository: %s\n") | ui.status(_("skipping missing subrepository: %s\n") | ||||
% join(subpath)) | % join(subpath)) | ||||
if not explicitonly: | if not explicitonly: | ||||
for f in match.files(): | for f in match.files(): | ||||
if f not in repo.dirstate and not repo.wvfs.isdir(f): | if f not in repo.dirstate and not repo.wvfs.isdir(f): | ||||
if f not in forgot: | if f not in forgot: | ||||
if repo.wvfs.exists(f): | if repo.wvfs.exists(f): | ||||
# Don't complain if the exact case match wasn't given. | # Don't complain if the exact case match wasn't given. | ||||
# But don't do this until after checking 'forgot', so | # But don't do this until after checking 'forgot', so | ||||
# that subrepo files aren't normalized, and this op is | # that subrepo files aren't normalized, and this op is | ||||
# purely from data cached by the status walk above. | # purely from data cached by the status walk above. | ||||
if repo.dirstate.normalize(f) in repo.dirstate: | if repo.dirstate.normalize(f) in repo.dirstate: | ||||
continue | continue | ||||
ui.warn(_('not removing %s: ' | ui.warn(_('not removing %s: ' | ||||
'file is already untracked\n') | 'file is already untracked\n') | ||||
% match.rel(f)) | % match.rel(f)) | ||||
bad.append(f) | bad.append(f) | ||||
if confirm: | if interactive: | ||||
responses = _('[Ynsa?]' | responses = _('[Ynsa?]' | ||||
'$$ &Yes, forget this file' | '$$ &Yes, forget this file' | ||||
'$$ &No, skip this file' | '$$ &No, skip this file' | ||||
'$$ &Skip remaining files' | '$$ &Skip remaining files' | ||||
'$$ Include &all remaining files' | '$$ Include &all remaining files' | ||||
'$$ &? (display help)') | '$$ &? (display help)') | ||||
for filename in forget[:]: | for filename in forget[:]: | ||||
r = ui.promptchoice(_('forget %s %s') % (filename, responses)) | r = ui.promptchoice(_('forget %s %s') % (filename, responses)) | ||||
elif r == 2: # Skip | elif r == 2: # Skip | ||||
fnindex = forget.index(filename) | fnindex = forget.index(filename) | ||||
del forget[fnindex:] | del forget[fnindex:] | ||||
break | break | ||||
elif r == 3: # All | elif r == 3: # All | ||||
break | break | ||||
for f in forget: | for f in forget: | ||||
if ui.verbose or not match.exact(f) or confirm: | if ui.verbose or not match.exact(f) or interactive: | ||||
ui.status(_('removing %s\n') % match.rel(f)) | ui.status(_('removing %s\n') % match.rel(f)) | ||||
if not dryrun: | if not dryrun: | ||||
rejected = wctx.forget(forget, prefix) | rejected = wctx.forget(forget, prefix) | ||||
bad.extend(f for f in rejected if f in match.files()) | bad.extend(f for f in rejected if f in match.files()) | ||||
forgot.extend(f for f in forget if f not in rejected) | forgot.extend(f for f in forget if f not in rejected) | ||||
return bad, forgot | return bad, forgot | ||||
('', 'version', None, _('output version information and exit')), | ('', 'version', None, _('output version information and exit')), | ||||
('h', 'help', None, _('display help and exit')), | ('h', 'help', None, _('display help and exit')), | ||||
('', 'hidden', False, _('consider hidden changesets')), | ('', 'hidden', False, _('consider hidden changesets')), | ||||
('', 'pager', 'auto', | ('', 'pager', 'auto', | ||||
_("when to paginate (boolean, always, auto, or never)"), _('TYPE')), | _("when to paginate (boolean, always, auto, or never)"), _('TYPE')), | ||||
] | ] | ||||
dryrunopts = cmdutil.dryrunopts | dryrunopts = cmdutil.dryrunopts | ||||
confirmopts = cmdutil.confirmopts | |||||
remoteopts = cmdutil.remoteopts | remoteopts = cmdutil.remoteopts | ||||
walkopts = cmdutil.walkopts | walkopts = cmdutil.walkopts | ||||
commitopts = cmdutil.commitopts | commitopts = cmdutil.commitopts | ||||
commitopts2 = cmdutil.commitopts2 | commitopts2 = cmdutil.commitopts2 | ||||
formatteropts = cmdutil.formatteropts | formatteropts = cmdutil.formatteropts | ||||
templateopts = cmdutil.templateopts | templateopts = cmdutil.templateopts | ||||
logopts = cmdutil.logopts | logopts = cmdutil.logopts | ||||
diffopts = cmdutil.diffopts | diffopts = cmdutil.diffopts | ||||
m = scmutil.match(ctx, pats, opts) | m = scmutil.match(ctx, pats, opts) | ||||
ui.pager('files') | ui.pager('files') | ||||
with ui.formatter('files', opts) as fm: | with ui.formatter('files', opts) as fm: | ||||
return cmdutil.files(ui, ctx, m, fm, fmt, opts.get('subrepos')) | return cmdutil.files(ui, ctx, m, fm, fmt, opts.get('subrepos')) | ||||
@command( | @command( | ||||
'^forget', | '^forget', | ||||
walkopts + dryrunopts + confirmopts, | [('i', 'interactive', None, _('use interactive mode')), | ||||
] + walkopts + dryrunopts, | |||||
_('[OPTION]... FILE...'), inferrepo=True) | _('[OPTION]... FILE...'), inferrepo=True) | ||||
def forget(ui, repo, *pats, **opts): | def forget(ui, repo, *pats, **opts): | ||||
"""forget the specified files on the next commit | """forget the specified files on the next commit | ||||
Mark the specified files so they will no longer be tracked | Mark the specified files so they will no longer be tracked | ||||
after the next commit. | after the next commit. | ||||
This only removes files from the current branch, not from the | This only removes files from the current branch, not from the | ||||
Returns 0 on success. | Returns 0 on success. | ||||
""" | """ | ||||
opts = pycompat.byteskwargs(opts) | opts = pycompat.byteskwargs(opts) | ||||
if not pats: | if not pats: | ||||
raise error.Abort(_('no files specified')) | raise error.Abort(_('no files specified')) | ||||
m = scmutil.match(repo[None], pats, opts) | m = scmutil.match(repo[None], pats, opts) | ||||
dryrun, confirm = opts.get('dry_run'), opts.get('confirm') | dryrun, interactive = opts.get('dry_run'), opts.get('interactive') | ||||
rejected = cmdutil.forget(ui, repo, m, prefix="", | rejected = cmdutil.forget(ui, repo, m, prefix="", | ||||
explicitonly=False, dryrun=dryrun, | explicitonly=False, dryrun=dryrun, | ||||
confirm=confirm)[0] | interactive=interactive)[0] | ||||
return rejected and 1 or 0 | return rejected and 1 or 0 | ||||
@command( | @command( | ||||
'graft', | 'graft', | ||||
[('r', 'rev', [], _('revisions to graft'), _('REV')), | [('r', 'rev', [], _('revisions to graft'), _('REV')), | ||||
('c', 'continue', False, _('resume interrupted graft')), | ('c', 'continue', False, _('resume interrupted graft')), | ||||
('e', 'edit', False, _('invoke editor on commit messages')), | ('e', 'edit', False, _('invoke editor on commit messages')), | ||||
('', 'log', None, _('append graft info to log message')), | ('', 'log', None, _('append graft info to log message')), |
return total | return total | ||||
def walk(self, match): | def walk(self, match): | ||||
''' | ''' | ||||
walk recursively through the directory tree, finding all files | walk recursively through the directory tree, finding all files | ||||
matched by the match function | matched by the match function | ||||
''' | ''' | ||||
def forget(self, match, prefix, dryrun, confirm): | def forget(self, match, prefix, dryrun, interactive): | ||||
return ([], []) | return ([], []) | ||||
def removefiles(self, matcher, prefix, after, force, subrepos, | def removefiles(self, matcher, prefix, after, force, subrepos, | ||||
dryrun, warnings): | dryrun, warnings): | ||||
"""remove the matched files from the subrepository and the filesystem, | """remove the matched files from the subrepository and the filesystem, | ||||
possibly by force and/or after the file has been removed from the | possibly by force and/or after the file has been removed from the | ||||
filesystem. Return 0 on success, 1 on any warning. | filesystem. Return 0 on success, 1 on any warning. | ||||
""" | """ | ||||
% self.wvfs.reljoin(reporelpath(self), subpath)) | % self.wvfs.reljoin(reporelpath(self), subpath)) | ||||
return files | return files | ||||
def walk(self, match): | def walk(self, match): | ||||
ctx = self._repo[None] | ctx = self._repo[None] | ||||
return ctx.walk(match) | return ctx.walk(match) | ||||
@annotatesubrepoerror | @annotatesubrepoerror | ||||
def forget(self, match, prefix, dryrun, confirm): | def forget(self, match, prefix, dryrun, interactive): | ||||
return cmdutil.forget(self.ui, self._repo, match, | return cmdutil.forget(self.ui, self._repo, match, | ||||
self.wvfs.reljoin(prefix, self._path), | self.wvfs.reljoin(prefix, self._path), | ||||
True, dryrun=dryrun, confirm=confirm) | True, dryrun=dryrun, interactive=interactive) | ||||
@annotatesubrepoerror | @annotatesubrepoerror | ||||
def removefiles(self, matcher, prefix, after, force, subrepos, | def removefiles(self, matcher, prefix, after, force, subrepos, | ||||
dryrun, warnings): | dryrun, warnings): | ||||
return cmdutil.remove(self.ui, self._repo, matcher, | return cmdutil.remove(self.ui, self._repo, matcher, | ||||
self.wvfs.reljoin(prefix, self._path), | self.wvfs.reljoin(prefix, self._path), | ||||
after, force, subrepos, dryrun) | after, force, subrepos, dryrun) | ||||
removing foo | removing foo | ||||
$ hg diff | $ hg diff | ||||
$ hg forget not_exist -n | $ hg forget not_exist -n | ||||
not_exist: $ENOENT$ | not_exist: $ENOENT$ | ||||
[1] | [1] | ||||
$ cd .. | $ cd .. | ||||
test --confirm option in forget | test --interactive mode in forget | ||||
$ hg init forgetconfirm | $ hg init interactiveforget | ||||
$ cd forgetconfirm | $ cd interactiveforget | ||||
$ echo foo > foo | $ echo foo > foo | ||||
$ hg commit -qAm "foo" | $ hg commit -qAm "foo" | ||||
$ echo bar > bar | $ echo bar > bar | ||||
$ hg commit -qAm "bar" | $ hg commit -qAm "bar" | ||||
$ hg forget foo --dry-run --confirm | $ hg forget foo --dry-run -i | ||||
abort: cannot specify both --dry-run and --confirm | abort: cannot specify both --dry-run and --interactive | ||||
[255] | [255] | ||||
$ hg forget foo --config ui.interactive=True --confirm << EOF | $ hg forget foo --config ui.interactive=True -i << EOF | ||||
> ? | > ? | ||||
> n | > n | ||||
> EOF | > EOF | ||||
forget foo [Ynsa?] ? | forget foo [Ynsa?] ? | ||||
y - yes, forget this file | y - yes, forget this file | ||||
n - no, skip this file | n - no, skip this file | ||||
s - skip remaining files | s - skip remaining files | ||||
a - include all remaining files | a - include all remaining files | ||||
? - ? (display help) | ? - ? (display help) | ||||
forget foo [Ynsa?] n | forget foo [Ynsa?] n | ||||
$ hg forget foo bar --config ui.interactive=True --confirm << EOF | $ hg forget foo bar --config ui.interactive=True -i << EOF | ||||
> y | > y | ||||
> n | > n | ||||
> EOF | > EOF | ||||
forget bar [Ynsa?] y | forget bar [Ynsa?] y | ||||
forget foo [Ynsa?] n | forget foo [Ynsa?] n | ||||
removing bar | removing bar | ||||
$ hg status | $ hg status | ||||
R bar | R bar | ||||
$ hg up -qC . | $ hg up -qC . | ||||
$ hg forget foo bar --config ui.interactive=True --confirm << EOF | $ hg forget foo bar --config ui.interactive=True -i << EOF | ||||
> s | > s | ||||
> EOF | > EOF | ||||
forget bar [Ynsa?] s | forget bar [Ynsa?] s | ||||
$ hg st | $ hg st | ||||
$ hg up -qC . | $ hg up -qC . | ||||
$ hg forget foo bar --config ui.interactive=True --confirm << EOF | $ hg forget foo bar --config ui.interactive=True -i << EOF | ||||
> a | > a | ||||
> EOF | > EOF | ||||
forget bar [Ynsa?] a | forget bar [Ynsa?] a | ||||
removing bar | removing bar | ||||
removing foo | removing foo | ||||
$ hg status | $ hg status | ||||
R bar | R bar | ||||
R foo | R foo | ||||
$ hg up -qC . | $ hg up -qC . | ||||
$ cd .. | $ cd .. |
Show all commands + options | Show all commands + options | ||||
$ hg debugcommands | $ hg debugcommands | ||||
add: include, exclude, subrepos, dry-run | add: include, exclude, subrepos, dry-run | ||||
annotate: rev, follow, no-follow, text, user, file, date, number, changeset, line-number, skip, ignore-all-space, ignore-space-change, ignore-blank-lines, ignore-space-at-eol, include, exclude, template | annotate: rev, follow, no-follow, text, user, file, date, number, changeset, line-number, skip, ignore-all-space, ignore-space-change, ignore-blank-lines, ignore-space-at-eol, include, exclude, template | ||||
clone: noupdate, updaterev, rev, branch, pull, uncompressed, stream, ssh, remotecmd, insecure | clone: noupdate, updaterev, rev, branch, pull, uncompressed, stream, ssh, remotecmd, insecure | ||||
commit: addremove, close-branch, amend, secret, edit, interactive, include, exclude, message, logfile, date, user, subrepos | commit: addremove, close-branch, amend, secret, edit, interactive, include, exclude, message, logfile, date, user, subrepos | ||||
diff: rev, change, text, git, binary, nodates, noprefix, show-function, reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, ignore-space-at-eol, unified, stat, root, include, exclude, subrepos | diff: rev, change, text, git, binary, nodates, noprefix, show-function, reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, ignore-space-at-eol, unified, stat, root, include, exclude, subrepos | ||||
export: output, switch-parent, rev, text, git, binary, nodates, template | export: output, switch-parent, rev, text, git, binary, nodates, template | ||||
forget: include, exclude, dry-run, confirm | forget: include, exclude, dry-run, interactive | ||||
init: ssh, remotecmd, insecure | init: ssh, remotecmd, insecure | ||||
log: follow, follow-first, date, copies, keyword, rev, line-range, removed, only-merges, user, only-branch, branch, prune, patch, git, limit, no-merges, stat, graph, style, template, include, exclude | log: follow, follow-first, date, copies, keyword, rev, line-range, removed, only-merges, user, only-branch, branch, prune, patch, git, limit, no-merges, stat, graph, style, template, include, exclude | ||||
merge: force, rev, preview, abort, tool | merge: force, rev, preview, abort, tool | ||||
pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure | pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure | ||||
push: force, rev, bookmark, branch, new-branch, pushvars, ssh, remotecmd, insecure | push: force, rev, bookmark, branch, new-branch, pushvars, ssh, remotecmd, insecure | ||||
remove: after, force, subrepos, include, exclude, dry-run | remove: after, force, subrepos, include, exclude, dry-run | ||||
serve: accesslog, daemon, daemon-postexec, errorlog, port, address, prefix, name, web-conf, webdir-conf, pid-file, stdio, cmdserver, templates, style, ipv6, certificate, subrepos | serve: accesslog, daemon, daemon-postexec, errorlog, port, address, prefix, name, web-conf, webdir-conf, pid-file, stdio, cmdserver, templates, style, ipv6, certificate, subrepos | ||||
status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, terse, copies, print0, rev, change, include, exclude, subrepos, template | status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, terse, copies, print0, rev, change, include, exclude, subrepos, template |