Patchwork D6281: branch: add tests which shows branch can be closed from a non-branchhead cset

login
register
mail settings
Submitter phabricator
Date April 19, 2019, 7:48 a.m.
Message ID <differential-rev-PHID-DREV-4fm75knphksuaivq4hjz-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/39760/
State Superseded
Headers show

Comments

phabricator - April 19, 2019, 7:48 a.m.
khanchi97 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This patch shows that we can close a branch even from a cset which is not
  a branch head. It was supposed to abort this operation.
  Next patch will be fixing the issue.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  tests/test-branches.t

CHANGE DETAILS




To: khanchi97, #hg-reviewers
Cc: mercurial-devel
phabricator - April 25, 2019, 5:47 p.m.
khanchi97 added inline comments.

INLINE COMMENTS

> test-branches.t:961
> +  $ hg ci -m "closing branch" --close-branch
> +  created new head
> +

I created this patch assuming that hg should not allow to create a branch closing commit from a cset which is not a branch head. Let me know if I am missing something here.

REPOSITORY
  rHG Mercurial

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

To: khanchi97, #hg-reviewers
Cc: mercurial-devel
phabricator - April 25, 2019, 5:51 p.m.
pulkit accepted this revision.
pulkit added a comment.


  Queueing this, many thanks!

INLINE COMMENTS

> khanchi97 wrote in test-branches.t:961
> I created this patch assuming that hg should not allow to create a branch closing commit from a cset which is not a branch head. Let me know if I am missing something here.

I think that the assumption is correct. `hg help commit` says `--close-branch mark a branch head as closed`.

So it should definitely be a head.

REPOSITORY
  rHG Mercurial

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

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
@@ -940,3 +940,38 @@ 
   0010: 56 46 78 69 00 00 00 01                         |VFxi....|
 
   $ cd ..
+
+Test to make sure that `--close-branch` only works on a branch head:
+--------------------------------------------------------------------
+  $ hg init closebranch
+  $ cd closebranch
+  $ for ch in a b c; do
+  > echo $ch > $ch
+  > hg add $ch
+  > hg ci -m "added "$ch
+  > done;
+
+  $ hg up -r "desc('added b')"
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+
+trying to close branch from a cset which is not a branch head
+it should abort:
+XXX: it should have aborted here
+  $ hg ci -m "closing branch" --close-branch
+  created new head
+
+  $ hg up 0
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ hg log -GT "{rev}: {node|short} {desc|firstline}\n\t{branch}\n\n"
+  _  3: 006876ddd20e closing branch
+  |  	default
+  |
+  | o  2: 155349b645be added c
+  |/   	default
+  |
+  o  1: 5f6d8a4bf34a added b
+  |  	default
+  |
+  @  0: 9092f1db7931 added a
+     	default
+