D3405: forget: rename --confirm to --interactive

khanchi97 (Sushil khanchi) phabricator at mercurial-scm.org
Wed Apr 18 13:57:10 UTC 2018


khanchi97 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3405

AFFECTED FILES
  hgext/largefiles/overrides.py
  mercurial/cmdutil.py
  mercurial/commands.py
  mercurial/subrepo.py
  tests/test-add.t
  tests/test-completion.t

CHANGE DETAILS

diff --git a/tests/test-completion.t b/tests/test-completion.t
--- a/tests/test-completion.t
+++ b/tests/test-completion.t
@@ -232,7 +232,7 @@
   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
   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
   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
diff --git a/tests/test-add.t b/tests/test-add.t
--- a/tests/test-add.t
+++ b/tests/test-add.t
@@ -273,19 +273,19 @@
 
   $ cd ..
 
-test --confirm option in forget
+test --interactive mode in forget
 
-  $ hg init forgetconfirm
-  $ cd forgetconfirm
+  $ hg init interactiveforget
+  $ cd interactiveforget
   $ echo foo > foo
   $ hg commit -qAm "foo"
   $ echo bar > bar
   $ hg commit -qAm "bar"
-  $ hg forget foo --dry-run --confirm
-  abort: cannot specify both --dry-run and --confirm
+  $ hg forget foo --dry-run -i
+  abort: cannot specify both --dry-run and --interactive
   [255]
 
-  $ hg forget foo --config ui.interactive=True --confirm << EOF
+  $ hg forget foo --config ui.interactive=True -i << EOF
   > ?
   > n
   > EOF
@@ -297,7 +297,7 @@
   ? - ? (display help)
   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
   > n
   > EOF
@@ -308,14 +308,14 @@
   R bar
   $ hg up -qC .
 
-  $ hg forget foo bar --config ui.interactive=True --confirm << EOF
+  $ hg forget foo bar --config ui.interactive=True -i << EOF
   > s
   > EOF
   forget bar [Ynsa?] s
   $ hg st
   $ hg up -qC .
 
-  $ hg forget foo bar --config ui.interactive=True --confirm << EOF
+  $ hg forget foo bar --config ui.interactive=True -i << EOF
   > a
   > EOF
   forget bar [Ynsa?] a
diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -352,7 +352,7 @@
         matched by the match function
         '''
 
-    def forget(self, match, prefix, dryrun, confirm):
+    def forget(self, match, prefix, dryrun, interactive):
         return ([], [])
 
     def removefiles(self, matcher, prefix, after, force, subrepos,
@@ -816,10 +816,10 @@
         return ctx.walk(match)
 
     @annotatesubrepoerror
-    def forget(self, match, prefix, dryrun, confirm):
+    def forget(self, match, prefix, dryrun, interactive):
         return cmdutil.forget(self.ui, self._repo, match,
                               self.wvfs.reljoin(prefix, self._path),
-                              True, dryrun=dryrun, confirm=confirm)
+                              True, dryrun=dryrun, interactive=interactive)
 
     @annotatesubrepoerror
     def removefiles(self, matcher, prefix, after, force, subrepos,
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -112,7 +112,6 @@
 ]
 
 dryrunopts = cmdutil.dryrunopts
-confirmopts = cmdutil.confirmopts
 remoteopts = cmdutil.remoteopts
 walkopts = cmdutil.walkopts
 commitopts = cmdutil.commitopts
@@ -2062,7 +2061,8 @@
 
 @command(
     '^forget',
-    walkopts + dryrunopts + confirmopts,
+    [('i', 'interactive', None, _('use interactive mode')),
+    ] + walkopts + dryrunopts,
     _('[OPTION]... FILE...'), inferrepo=True)
 def forget(ui, repo, *pats, **opts):
     """forget the specified files on the next commit
@@ -2098,10 +2098,10 @@
         raise error.Abort(_('no files specified'))
 
     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="",
                               explicitonly=False, dryrun=dryrun,
-                              confirm=confirm)[0]
+                              interactive=interactive)[0]
     return rejected and 1 or 0
 
 @command(
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2031,9 +2031,9 @@
         for subpath in ctx.substate:
             ctx.sub(subpath).addwebdirpath(serverpath, webconf)
 
-def forget(ui, repo, match, prefix, explicitonly, dryrun, confirm):
-    if dryrun and confirm:
-        raise error.Abort(_("cannot specify both --dry-run and --confirm"))
+def forget(ui, repo, match, prefix, explicitonly, dryrun, interactive):
+    if dryrun and interactive:
+        raise error.Abort(_("cannot specify both --dry-run and --interactive"))
     join = lambda f: os.path.join(prefix, f)
     bad = []
     badfn = lambda x, y: bad.append(x) or match.bad(x, y)
@@ -2049,8 +2049,8 @@
         sub = wctx.sub(subpath)
         try:
             submatch = matchmod.subdirmatcher(subpath, match)
-            subbad, subforgot = sub.forget(submatch, prefix,
-                                           dryrun=dryrun, confirm=confirm)
+            subbad, subforgot = sub.forget(submatch, prefix, dryrun=dryrun,
+                                           interactive=interactive)
             bad.extend([subpath + '/' + f for f in subbad])
             forgot.extend([subpath + '/' + f for f in subforgot])
         except error.LookupError:
@@ -2073,7 +2073,7 @@
                                 % match.rel(f))
                     bad.append(f)
 
-    if confirm:
+    if interactive:
         responses = _('[Ynsa?]'
                       '$$ &Yes, forget this file'
                       '$$ &No, skip this file'
@@ -2100,7 +2100,7 @@
                 break
 
     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))
 
     if not dryrun:
diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -1079,10 +1079,11 @@
     finally:
         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())
     bad, forgot = orig(ui, repo, normalmatcher, prefix, explicitonly, dryrun,
-                       confirm)
+                       interactive)
     m = composelargefilematcher(match, repo[None].manifest())
 
     try:



To: khanchi97, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list