changeset 42493:9f7cb777b654

commit: add a check if it is trying to close an already closed branch head It would check if the revision we are going to close is already a closed branch head and print the error message accordingly. Differential Revision: https://phab.mercurial-scm.org/D6491
author Sushil khanchi <sushilkhanchi97@gmail.com>
date Tue, 16 Apr 2019 02:33:54 +0530
parents 4bcabb5ae9b6
children abd4783db5a7
files mercurial/commands.py tests/test-branches.t
diffstat 2 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Mon Jun 17 10:53:00 2019 -0700
+++ b/mercurial/commands.py	Tue Apr 16 02:33:54 2019 +0530
@@ -1673,7 +1673,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:
             raise error.Abort(_('can only close branch heads'))
--- a/tests/test-branches.t	Mon Jun 17 10:53:00 2019 -0700
+++ b/tests/test-branches.t	Tue Apr 16 02:33:54 2019 +0530
@@ -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