D6491: branch: add a check if it is trying to close an already closed branch head

khanchi97 (Sushil khanchi) phabricator at mercurial-scm.org
Fri Jun 7 13:57:00 UTC 2019


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

REVISION SUMMARY
  It would check if the revision we are going to close is already a
  closed branch head and print the error message accordingly.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/commands.py
  tests/test-branches.t

CHANGE DETAILS

diff --git a/tests/test-branches.t b/tests/test-branches.t
--- a/tests/test-branches.t
+++ b/tests/test-branches.t
@@ -280,7 +280,7 @@
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg commit -d '9 0' --close-branch -m 'close this part branch too'
   $ hg commit -d '9 0' --close-branch -m 're-closing this branch'
-  abort: can only close branch heads
+  abort: current revision is already a branch closing head
   [255]
 
   $ hg log -r tip --debug
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1674,7 +1674,10 @@
     if opts.get('close_branch'):
         extra['close'] = '1'
 
-        if not bheads:
+        if repo['.'].closesbranch():
+            raise error.Abort(_('current revision is already a branch closing'
+                                ' head'))
+        elif not bheads:
             raise error.Abort(_('can only close branch heads'))
         elif (branch == repo['.'].branch() and repo['.'].node() not in bheads
               and not opts.get('force')):



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


More information about the Mercurial-devel mailing list