Show More
@@ -1077,9 +1077,9 def postcommitstatus(orig, repo, *args, | |||||
1077 | finally: |
|
1077 | finally: | |
1078 | repo.lfstatus = False |
|
1078 | repo.lfstatus = False | |
1079 |
|
1079 | |||
1080 | def cmdutilforget(orig, ui, repo, match, prefix, explicitonly): |
|
1080 | def cmdutilforget(orig, ui, repo, match, prefix, explicitonly, dryrun): | |
1081 | normalmatcher = composenormalfilematcher(match, repo[None].manifest()) |
|
1081 | normalmatcher = composenormalfilematcher(match, repo[None].manifest()) | |
1082 | bad, forgot = orig(ui, repo, normalmatcher, prefix, explicitonly) |
|
1082 | bad, forgot = orig(ui, repo, normalmatcher, prefix, explicitonly, dryrun) | |
1083 | m = composelargefilematcher(match, repo[None].manifest()) |
|
1083 | m = composelargefilematcher(match, repo[None].manifest()) | |
1084 |
|
1084 | |||
1085 | try: |
|
1085 | try: |
@@ -1996,7 +1996,7 def addwebdirpath(repo, serverpath, webc | |||||
1996 | for subpath in ctx.substate: |
|
1996 | for subpath in ctx.substate: | |
1997 | ctx.sub(subpath).addwebdirpath(serverpath, webconf) |
|
1997 | ctx.sub(subpath).addwebdirpath(serverpath, webconf) | |
1998 |
|
1998 | |||
1999 | def forget(ui, repo, match, prefix, explicitonly): |
|
1999 | def forget(ui, repo, match, prefix, explicitonly, dryrun): | |
2000 | join = lambda f: os.path.join(prefix, f) |
|
2000 | join = lambda f: os.path.join(prefix, f) | |
2001 | bad = [] |
|
2001 | bad = [] | |
2002 | badfn = lambda x, y: bad.append(x) or match.bad(x, y) |
|
2002 | badfn = lambda x, y: bad.append(x) or match.bad(x, y) | |
@@ -2012,7 +2012,7 def forget(ui, repo, match, prefix, expl | |||||
2012 | sub = wctx.sub(subpath) |
|
2012 | sub = wctx.sub(subpath) | |
2013 | try: |
|
2013 | try: | |
2014 | submatch = matchmod.subdirmatcher(subpath, match) |
|
2014 | submatch = matchmod.subdirmatcher(subpath, match) | |
2015 | subbad, subforgot = sub.forget(submatch, prefix) |
|
2015 | subbad, subforgot = sub.forget(submatch, prefix, dryrun=dryrun) | |
2016 | bad.extend([subpath + '/' + f for f in subbad]) |
|
2016 | bad.extend([subpath + '/' + f for f in subbad]) | |
2017 | forgot.extend([subpath + '/' + f for f in subforgot]) |
|
2017 | forgot.extend([subpath + '/' + f for f in subforgot]) | |
2018 | except error.LookupError: |
|
2018 | except error.LookupError: | |
@@ -2039,9 +2039,10 def forget(ui, repo, match, prefix, expl | |||||
2039 | if ui.verbose or not match.exact(f): |
|
2039 | if ui.verbose or not match.exact(f): | |
2040 | ui.status(_('removing %s\n') % match.rel(f)) |
|
2040 | ui.status(_('removing %s\n') % match.rel(f)) | |
2041 |
|
2041 | |||
2042 | rejected = wctx.forget(forget, prefix) |
|
2042 | if not dryrun: | |
2043 | bad.extend(f for f in rejected if f in match.files()) |
|
2043 | rejected = wctx.forget(forget, prefix) | |
2044 | forgot.extend(f for f in forget if f not in rejected) |
|
2044 | bad.extend(f for f in rejected if f in match.files()) | |
|
2045 | forgot.extend(f for f in forget if f not in rejected) | |||
2045 | return bad, forgot |
|
2046 | return bad, forgot | |
2046 |
|
2047 | |||
2047 | def files(ui, ctx, m, fm, fmt, subrepos): |
|
2048 | def files(ui, ctx, m, fm, fmt, subrepos): |
@@ -2036,7 +2036,10 def files(ui, repo, *pats, **opts): | |||||
2036 | with ui.formatter('files', opts) as fm: |
|
2036 | with ui.formatter('files', opts) as fm: | |
2037 | return cmdutil.files(ui, ctx, m, fm, fmt, opts.get('subrepos')) |
|
2037 | return cmdutil.files(ui, ctx, m, fm, fmt, opts.get('subrepos')) | |
2038 |
|
2038 | |||
2039 | @command('^forget', walkopts, _('[OPTION]... FILE...'), inferrepo=True) |
|
2039 | @command( | |
|
2040 | '^forget', | |||
|
2041 | walkopts + dryrunopts, | |||
|
2042 | _('[OPTION]... FILE...'), inferrepo=True) | |||
2040 | def forget(ui, repo, *pats, **opts): |
|
2043 | def forget(ui, repo, *pats, **opts): | |
2041 | """forget the specified files on the next commit |
|
2044 | """forget the specified files on the next commit | |
2042 |
|
2045 | |||
@@ -2071,7 +2074,9 def forget(ui, repo, *pats, **opts): | |||||
2071 | raise error.Abort(_('no files specified')) |
|
2074 | raise error.Abort(_('no files specified')) | |
2072 |
|
2075 | |||
2073 | m = scmutil.match(repo[None], pats, opts) |
|
2076 | m = scmutil.match(repo[None], pats, opts) | |
2074 | rejected = cmdutil.forget(ui, repo, m, prefix="", explicitonly=False)[0] |
|
2077 | dryrun = opts.get(r'dry_run') | |
|
2078 | rejected = cmdutil.forget(ui, repo, m, prefix="", | |||
|
2079 | explicitonly=False, dryrun=dryrun)[0] | |||
2075 | return rejected and 1 or 0 |
|
2080 | return rejected and 1 or 0 | |
2076 |
|
2081 | |||
2077 | @command( |
|
2082 | @command( |
@@ -348,7 +348,7 class abstractsubrepo(object): | |||||
348 | matched by the match function |
|
348 | matched by the match function | |
349 | ''' |
|
349 | ''' | |
350 |
|
350 | |||
351 | def forget(self, match, prefix): |
|
351 | def forget(self, match, prefix, dryrun): | |
352 | return ([], []) |
|
352 | return ([], []) | |
353 |
|
353 | |||
354 | def removefiles(self, matcher, prefix, after, force, subrepos, warnings): |
|
354 | def removefiles(self, matcher, prefix, after, force, subrepos, warnings): | |
@@ -811,9 +811,10 class hgsubrepo(abstractsubrepo): | |||||
811 | return ctx.walk(match) |
|
811 | return ctx.walk(match) | |
812 |
|
812 | |||
813 | @annotatesubrepoerror |
|
813 | @annotatesubrepoerror | |
814 | def forget(self, match, prefix): |
|
814 | def forget(self, match, prefix, dryrun): | |
815 | return cmdutil.forget(self.ui, self._repo, match, |
|
815 | return cmdutil.forget(self.ui, self._repo, match, | |
816 |
self.wvfs.reljoin(prefix, self._path), |
|
816 | self.wvfs.reljoin(prefix, self._path), | |
|
817 | True, dryrun=dryrun) | |||
817 |
|
818 | |||
818 | @annotatesubrepoerror |
|
819 | @annotatesubrepoerror | |
819 | def removefiles(self, matcher, prefix, after, force, subrepos, warnings): |
|
820 | def removefiles(self, matcher, prefix, after, force, subrepos, warnings): |
@@ -256,3 +256,19 and OS X | |||||
256 | #endif |
|
256 | #endif | |
257 |
|
257 | |||
258 | $ cd .. |
|
258 | $ cd .. | |
|
259 | ||||
|
260 | test --dry-run mode in forget | |||
|
261 | ||||
|
262 | $ hg init testdir_forget | |||
|
263 | $ cd testdir_forget | |||
|
264 | $ echo foo > foo | |||
|
265 | $ hg add foo | |||
|
266 | $ hg commit -m "foo" | |||
|
267 | $ hg forget foo --dry-run -v | |||
|
268 | removing foo | |||
|
269 | $ hg diff | |||
|
270 | $ hg forget not_exist -n | |||
|
271 | not_exist: $ENOENT$ | |||
|
272 | [1] | |||
|
273 | ||||
|
274 | $ cd .. |
@@ -231,7 +231,7 Show all commands + options | |||||
231 | commit: addremove, close-branch, amend, secret, edit, interactive, include, exclude, message, logfile, date, user, subrepos |
|
231 | commit: addremove, close-branch, amend, secret, edit, interactive, include, exclude, message, logfile, date, user, subrepos | |
232 | 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 |
|
232 | 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 | export: output, switch-parent, rev, text, git, binary, nodates |
|
233 | export: output, switch-parent, rev, text, git, binary, nodates | |
234 | forget: include, exclude |
|
234 | forget: include, exclude, dry-run | |
235 | init: ssh, remotecmd, insecure |
|
235 | init: ssh, remotecmd, insecure | |
236 | 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 |
|
236 | 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 | merge: force, rev, preview, abort, tool |
|
237 | merge: force, rev, preview, abort, tool |
General Comments 0
You need to be logged in to leave comments.
Login now