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

login
register
mail settings
Submitter phabricator
Date June 18, 2019, 11:41 a.m.
Message ID <f13645efbd68ae3ef6b6d9cef2b66512@localhost.localdomain>
Download mbox | patch
Permalink /patch/40574/
State Not Applicable
Headers show

Comments

phabricator - June 18, 2019, 11:41 a.m.
Closed by commit rHG9f7cb777b654: commit: add a check if it is trying to close an already closed branch head (authored by khanchi97).
This revision was automatically updated to reflect the committed changes.

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D6491?vs=15532&id=15567#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6491?vs=15532&id=15567

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

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

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

CHANGE DETAILS




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

Patch

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
@@ -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'))