D6566: abort: first prototype of hg abort

taapas1128 (Taapas Agrawal) phabricator at mercurial-scm.org
Mon Jun 24 11:06:28 EDT 2019


taapas1128 updated this revision to Diff 15646.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6566?vs=15635&id=15646

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6566/new/

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/state.py
  tests/test-completion.t
  tests/test-globalopts.t
  tests/test-help-hide.t
  tests/test-help.t

CHANGE DETAILS

diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -5,6 +5,7 @@
   
   basic commands:
   
+   abort         abort an unfinished operation
    add           add the specified files on the next commit
    annotate      show changeset information by line for each file
    clone         make a copy of an existing repository
@@ -26,6 +27,7 @@
   (use 'hg help' for the full list of commands or 'hg -v' for details)
 
   $ hg -q
+   abort         abort an unfinished operation
    add           add the specified files on the next commit
    annotate      show changeset information by line for each file
    clone         make a copy of an existing repository
@@ -73,6 +75,7 @@
   
   Change manipulation:
   
+   abort         abort an unfinished operation
    backout       reverse effect of earlier changeset
    graft         copy changes from other branches onto the current branch
    merge         merge another revision into working directory
@@ -199,6 +202,7 @@
   
   Change manipulation:
   
+   abort         abort an unfinished operation
    backout       reverse effect of earlier changeset
    graft         copy changes from other branches onto the current branch
    merge         merge another revision into working directory
@@ -399,6 +403,7 @@
   
   basic commands:
   
+   abort         abort an unfinished operation
    add           add the specified files on the next commit
    annotate, blame
                  show changeset information by line for each file
@@ -2350,6 +2355,13 @@
   <tr><td colspan="2"><h2><a name="main" href="#main">Main Commands</a></h2></td></tr>
   
   <tr><td>
+  <a href="/help/abort">
+  abort
+  </a>
+  </td><td>
+  abort an unfinished operation
+  </td></tr>
+  <tr><td>
   <a href="/help/add">
   add
   </a>
diff --git a/tests/test-help-hide.t b/tests/test-help-hide.t
--- a/tests/test-help-hide.t
+++ b/tests/test-help-hide.t
@@ -21,6 +21,7 @@
   
   Change manipulation:
   
+   abort         abort an unfinished operation
    backout       reverse effect of earlier changeset
    graft         copy changes from other branches onto the current branch
    merge         merge another revision into working directory
@@ -155,6 +156,7 @@
   
   Change manipulation:
   
+   abort         abort an unfinished operation
    backout       reverse effect of earlier changeset
    graft         copy changes from other branches onto the current branch
    merge         merge another revision into working directory
diff --git a/tests/test-globalopts.t b/tests/test-globalopts.t
--- a/tests/test-globalopts.t
+++ b/tests/test-globalopts.t
@@ -317,6 +317,7 @@
   
   Change manipulation:
   
+   abort         abort an unfinished operation
    backout       reverse effect of earlier changeset
    graft         copy changes from other branches onto the current branch
    merge         merge another revision into working directory
@@ -447,6 +448,7 @@
   
   Change manipulation:
   
+   abort         abort an unfinished operation
    backout       reverse effect of earlier changeset
    graft         copy changes from other branches onto the current branch
    merge         merge another revision into working directory
diff --git a/tests/test-completion.t b/tests/test-completion.t
--- a/tests/test-completion.t
+++ b/tests/test-completion.t
@@ -1,5 +1,6 @@
 Show all commands except debug commands
   $ hg debugcomplete
+  abort
   add
   addremove
   annotate
@@ -57,6 +58,7 @@
 
 Show all commands that start with "a"
   $ hg debugcomplete a
+  abort
   add
   addremove
   annotate
@@ -233,6 +235,7 @@
 
 Show all commands + options
   $ hg debugcommands
+  abort: 
   add: include, exclude, subrepos, dry-run
   addremove: similarity, subrepos, include, exclude, 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
diff --git a/mercurial/state.py b/mercurial/state.py
--- a/mercurial/state.py
+++ b/mercurial/state.py
@@ -99,7 +99,7 @@
 
     def __init__(self, opname, fname, clearable=False, allowcommit=False,
                  reportonly=False, continueflag=False, stopflag=False ,
-                 cmdmsg="", cmdhint="", statushint=""):
+                 cmdmsg="", cmdhint="", statushint="", abortfunc=None):
         """opname is the name the command or operation
         fname is the file name in which data should be stored in .hg directory.
         It is None for merge command.
@@ -133,6 +133,7 @@
         self._stopflag = stopflag
         self._reportonly = reportonly
         self._continueflag = continueflag
+        self._abortfunc = abortfunc
 
     def statusmsg(self):
         """returns the hint message corresponding to the command for
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -131,6 +131,28 @@
 
 # Commands start here, listed alphabetically
 
+ at command('abort', [], helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
+        helpbasic=True)
+def abort(ui, repo, **opts):
+    """abort an unfinished operation
+
+    This function is the first prototype for hg abort command.
+    It first checks the state and checks which command is active
+    then calls then returns the respective logic for aborting the
+    command.
+    """
+    abortstate = None
+    for state in statemod._unfinishedstates:
+        if state.isunfinished(repo):
+            abortstate = state
+            break
+    if not abortstate:
+        raise error.Abort(_('no operation in progress'))
+    if abortstate._abortfunc:
+        return abortstate._abortfunc(ui, repo)
+    raise error.Abort((_("%s does not support 'hg abort'") %
+                        (abortstate._opname)), hint=abortstate.hint())
+
 @command('add',
     walkopts + subrepoopts + dryrunopts,
     _('[OPTION]... [FILE]...'),



To: taapas1128, #hg-reviewers
Cc: martinvonz, mercurial-devel


More information about the Mercurial-devel mailing list