Show More
@@ -1079,9 +1079,10 b' def postcommitstatus(orig, repo, *args, ' | |||||
1079 | finally: |
|
1079 | finally: | |
1080 | repo.lfstatus = False |
|
1080 | repo.lfstatus = False | |
1081 |
|
1081 | |||
1082 | def cmdutilforget(orig, ui, repo, match, prefix, explicitonly, dryrun): |
|
1082 | def cmdutilforget(orig, ui, repo, match, prefix, explicitonly, dryrun, confirm): | |
1083 | normalmatcher = composenormalfilematcher(match, repo[None].manifest()) |
|
1083 | normalmatcher = composenormalfilematcher(match, repo[None].manifest()) | |
1084 |
bad, forgot = orig(ui, repo, normalmatcher, prefix, explicitonly, dryrun |
|
1084 | bad, forgot = orig(ui, repo, normalmatcher, prefix, explicitonly, dryrun, | |
|
1085 | confirm) | |||
1085 | m = composelargefilematcher(match, repo[None].manifest()) |
|
1086 | m = composelargefilematcher(match, repo[None].manifest()) | |
1086 |
|
1087 | |||
1087 | try: |
|
1088 | try: |
@@ -63,6 +63,11 b' dryrunopts = [' | |||||
63 | _('do not perform actions, just print output')), |
|
63 | _('do not perform actions, just print output')), | |
64 | ] |
|
64 | ] | |
65 |
|
65 | |||
|
66 | confirmopts = [ | |||
|
67 | ('', 'confirm', None, | |||
|
68 | _('ask before applying actions')), | |||
|
69 | ] | |||
|
70 | ||||
66 | remoteopts = [ |
|
71 | remoteopts = [ | |
67 | ('e', 'ssh', '', |
|
72 | ('e', 'ssh', '', | |
68 | _('specify ssh command to use'), _('CMD')), |
|
73 | _('specify ssh command to use'), _('CMD')), | |
@@ -2022,7 +2027,9 b' def addwebdirpath(repo, serverpath, webc' | |||||
2022 | for subpath in ctx.substate: |
|
2027 | for subpath in ctx.substate: | |
2023 | ctx.sub(subpath).addwebdirpath(serverpath, webconf) |
|
2028 | ctx.sub(subpath).addwebdirpath(serverpath, webconf) | |
2024 |
|
2029 | |||
2025 | def forget(ui, repo, match, prefix, explicitonly, dryrun): |
|
2030 | def forget(ui, repo, match, prefix, explicitonly, dryrun, confirm): | |
|
2031 | if dryrun and confirm: | |||
|
2032 | raise error.Abort(_("cannot specify both --dry-run and --confirm")) | |||
2026 | join = lambda f: os.path.join(prefix, f) |
|
2033 | join = lambda f: os.path.join(prefix, f) | |
2027 | bad = [] |
|
2034 | bad = [] | |
2028 | badfn = lambda x, y: bad.append(x) or match.bad(x, y) |
|
2035 | badfn = lambda x, y: bad.append(x) or match.bad(x, y) | |
@@ -2038,7 +2045,8 b' def forget(ui, repo, match, prefix, expl' | |||||
2038 | sub = wctx.sub(subpath) |
|
2045 | sub = wctx.sub(subpath) | |
2039 | try: |
|
2046 | try: | |
2040 | submatch = matchmod.subdirmatcher(subpath, match) |
|
2047 | submatch = matchmod.subdirmatcher(subpath, match) | |
2041 |
subbad, subforgot = sub.forget(submatch, prefix, |
|
2048 | subbad, subforgot = sub.forget(submatch, prefix, | |
|
2049 | dryrun=dryrun, confirm=confirm) | |||
2042 | bad.extend([subpath + '/' + f for f in subbad]) |
|
2050 | bad.extend([subpath + '/' + f for f in subbad]) | |
2043 | forgot.extend([subpath + '/' + f for f in subforgot]) |
|
2051 | forgot.extend([subpath + '/' + f for f in subforgot]) | |
2044 | except error.LookupError: |
|
2052 | except error.LookupError: | |
@@ -2061,8 +2069,34 b' def forget(ui, repo, match, prefix, expl' | |||||
2061 | % match.rel(f)) |
|
2069 | % match.rel(f)) | |
2062 | bad.append(f) |
|
2070 | bad.append(f) | |
2063 |
|
2071 | |||
|
2072 | if confirm: | |||
|
2073 | responses = _('[Ynsa?]' | |||
|
2074 | '$$ &Yes, forget this file' | |||
|
2075 | '$$ &No, skip this file' | |||
|
2076 | '$$ &Skip remaining files' | |||
|
2077 | '$$ Include &all remaining files' | |||
|
2078 | '$$ &? (display help)') | |||
|
2079 | for filename in forget[:]: | |||
|
2080 | r = ui.promptchoice(_('forget %s %s') % (filename, responses)) | |||
|
2081 | if r == 4: # ? | |||
|
2082 | while r == 4: | |||
|
2083 | for c, t in ui.extractchoices(responses)[1]: | |||
|
2084 | ui.write('%s - %s\n' % (c, encoding.lower(t))) | |||
|
2085 | r = ui.promptchoice(_('forget %s %s') % (filename, | |||
|
2086 | responses)) | |||
|
2087 | if r == 0: # yes | |||
|
2088 | continue | |||
|
2089 | elif r == 1: # no | |||
|
2090 | forget.remove(filename) | |||
|
2091 | elif r == 2: # Skip | |||
|
2092 | fnindex = forget.index(filename) | |||
|
2093 | del forget[fnindex:] | |||
|
2094 | break | |||
|
2095 | elif r == 3: # All | |||
|
2096 | break | |||
|
2097 | ||||
2064 | for f in forget: |
|
2098 | for f in forget: | |
2065 | if ui.verbose or not match.exact(f): |
|
2099 | if ui.verbose or not match.exact(f) or confirm: | |
2066 | ui.status(_('removing %s\n') % match.rel(f)) |
|
2100 | ui.status(_('removing %s\n') % match.rel(f)) | |
2067 |
|
2101 | |||
2068 | if not dryrun: |
|
2102 | if not dryrun: |
@@ -112,6 +112,7 b' globalopts = [' | |||||
112 | ] |
|
112 | ] | |
113 |
|
113 | |||
114 | dryrunopts = cmdutil.dryrunopts |
|
114 | dryrunopts = cmdutil.dryrunopts | |
|
115 | confirmopts = cmdutil.confirmopts | |||
115 | remoteopts = cmdutil.remoteopts |
|
116 | remoteopts = cmdutil.remoteopts | |
116 | walkopts = cmdutil.walkopts |
|
117 | walkopts = cmdutil.walkopts | |
117 | commitopts = cmdutil.commitopts |
|
118 | commitopts = cmdutil.commitopts | |
@@ -2060,7 +2061,7 b' def files(ui, repo, *pats, **opts):' | |||||
2060 |
|
2061 | |||
2061 | @command( |
|
2062 | @command( | |
2062 | '^forget', |
|
2063 | '^forget', | |
2063 | walkopts + dryrunopts, |
|
2064 | walkopts + dryrunopts + confirmopts, | |
2064 | _('[OPTION]... FILE...'), inferrepo=True) |
|
2065 | _('[OPTION]... FILE...'), inferrepo=True) | |
2065 | def forget(ui, repo, *pats, **opts): |
|
2066 | def forget(ui, repo, *pats, **opts): | |
2066 | """forget the specified files on the next commit |
|
2067 | """forget the specified files on the next commit | |
@@ -2096,9 +2097,10 b' def forget(ui, repo, *pats, **opts):' | |||||
2096 | raise error.Abort(_('no files specified')) |
|
2097 | raise error.Abort(_('no files specified')) | |
2097 |
|
2098 | |||
2098 | m = scmutil.match(repo[None], pats, opts) |
|
2099 | m = scmutil.match(repo[None], pats, opts) | |
2099 | dryrun = opts.get('dry_run') |
|
2100 | dryrun, confirm = opts.get('dry_run'), opts.get('confirm') | |
2100 | rejected = cmdutil.forget(ui, repo, m, prefix="", |
|
2101 | rejected = cmdutil.forget(ui, repo, m, prefix="", | |
2101 |
explicitonly=False, dryrun=dryrun |
|
2102 | explicitonly=False, dryrun=dryrun, | |
|
2103 | confirm=confirm)[0] | |||
2102 | return rejected and 1 or 0 |
|
2104 | return rejected and 1 or 0 | |
2103 |
|
2105 | |||
2104 | @command( |
|
2106 | @command( |
@@ -352,7 +352,7 b' class abstractsubrepo(object):' | |||||
352 | matched by the match function |
|
352 | matched by the match function | |
353 | ''' |
|
353 | ''' | |
354 |
|
354 | |||
355 | def forget(self, match, prefix, dryrun): |
|
355 | def forget(self, match, prefix, dryrun, confirm): | |
356 | return ([], []) |
|
356 | return ([], []) | |
357 |
|
357 | |||
358 | def removefiles(self, matcher, prefix, after, force, subrepos, |
|
358 | def removefiles(self, matcher, prefix, after, force, subrepos, | |
@@ -815,10 +815,10 b' class hgsubrepo(abstractsubrepo):' | |||||
815 | return ctx.walk(match) |
|
815 | return ctx.walk(match) | |
816 |
|
816 | |||
817 | @annotatesubrepoerror |
|
817 | @annotatesubrepoerror | |
818 | def forget(self, match, prefix, dryrun): |
|
818 | def forget(self, match, prefix, dryrun, confirm): | |
819 | return cmdutil.forget(self.ui, self._repo, match, |
|
819 | return cmdutil.forget(self.ui, self._repo, match, | |
820 | self.wvfs.reljoin(prefix, self._path), |
|
820 | self.wvfs.reljoin(prefix, self._path), | |
821 | True, dryrun=dryrun) |
|
821 | True, dryrun=dryrun, confirm=confirm) | |
822 |
|
822 | |||
823 | @annotatesubrepoerror |
|
823 | @annotatesubrepoerror | |
824 | def removefiles(self, matcher, prefix, after, force, subrepos, |
|
824 | def removefiles(self, matcher, prefix, after, force, subrepos, |
@@ -272,3 +272,58 b' test --dry-run mode in forget' | |||||
272 | [1] |
|
272 | [1] | |
273 |
|
273 | |||
274 | $ cd .. |
|
274 | $ cd .. | |
|
275 | ||||
|
276 | test --confirm option in forget | |||
|
277 | ||||
|
278 | $ hg init forgetconfirm | |||
|
279 | $ cd forgetconfirm | |||
|
280 | $ echo foo > foo | |||
|
281 | $ hg commit -qAm "foo" | |||
|
282 | $ echo bar > bar | |||
|
283 | $ hg commit -qAm "bar" | |||
|
284 | $ hg forget foo --dry-run --confirm | |||
|
285 | abort: cannot specify both --dry-run and --confirm | |||
|
286 | [255] | |||
|
287 | ||||
|
288 | $ hg forget foo --config ui.interactive=True --confirm << EOF | |||
|
289 | > ? | |||
|
290 | > n | |||
|
291 | > EOF | |||
|
292 | forget foo [Ynsa?] ? | |||
|
293 | y - yes, forget this file | |||
|
294 | n - no, skip this file | |||
|
295 | s - skip remaining files | |||
|
296 | a - include all remaining files | |||
|
297 | ? - ? (display help) | |||
|
298 | forget foo [Ynsa?] n | |||
|
299 | ||||
|
300 | $ hg forget foo bar --config ui.interactive=True --confirm << EOF | |||
|
301 | > y | |||
|
302 | > n | |||
|
303 | > EOF | |||
|
304 | forget bar [Ynsa?] y | |||
|
305 | forget foo [Ynsa?] n | |||
|
306 | removing bar | |||
|
307 | $ hg status | |||
|
308 | R bar | |||
|
309 | $ hg up -qC . | |||
|
310 | ||||
|
311 | $ hg forget foo bar --config ui.interactive=True --confirm << EOF | |||
|
312 | > s | |||
|
313 | > EOF | |||
|
314 | forget bar [Ynsa?] s | |||
|
315 | $ hg st | |||
|
316 | $ hg up -qC . | |||
|
317 | ||||
|
318 | $ hg forget foo bar --config ui.interactive=True --confirm << EOF | |||
|
319 | > a | |||
|
320 | > EOF | |||
|
321 | forget bar [Ynsa?] a | |||
|
322 | removing bar | |||
|
323 | removing foo | |||
|
324 | $ hg status | |||
|
325 | R bar | |||
|
326 | R foo | |||
|
327 | $ hg up -qC . | |||
|
328 | ||||
|
329 | $ cd .. |
@@ -232,7 +232,7 b' Show all commands + options' | |||||
232 | commit: addremove, close-branch, amend, secret, edit, interactive, include, exclude, message, logfile, date, user, subrepos |
|
232 | commit: addremove, close-branch, amend, secret, edit, interactive, include, exclude, message, logfile, date, user, subrepos | |
233 | 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 |
|
233 | 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 | |
234 | export: output, switch-parent, rev, text, git, binary, nodates, template |
|
234 | export: output, switch-parent, rev, text, git, binary, nodates, template | |
235 | forget: include, exclude, dry-run |
|
235 | forget: include, exclude, dry-run, confirm | |
236 | init: ssh, remotecmd, insecure |
|
236 | init: ssh, remotecmd, insecure | |
237 | 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 |
|
237 | 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 | |
238 | merge: force, rev, preview, abort, tool |
|
238 | merge: force, rev, preview, abort, tool |
General Comments 0
You need to be logged in to leave comments.
Login now