D6282: branch: abort if closing branch from a non-branchhead cset

Pierre-Yves David pierre-yves.david at ens-lyon.org
Fri Apr 26 10:56:57 EDT 2019



On 4/19/19 9:49 AM, khanchi97 (Sushil khanchi) wrote:
> khanchi97 created this revision.
> Herald added a subscriber: mercurial-devel.
> Herald added a reviewer: hg-reviewers.
> 
> REVISION SUMMARY
>    This patch make sure that we abort if the user is trying to
>    close a branch from a cset which is not a branch head.
>    Changes in test file reflect the fixed behaviour.

Is there a way to override this ? There can be situation where the 
changeset is not a local head but could be a remote head.

> 
> REPOSITORY
>    rHG Mercurial
> 
> REVISION DETAIL
>    https://phab.mercurial-scm.org/D6282
> 
> 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
> @@ -956,19 +956,16 @@
>   
>   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
> +  abort: can only close branch heads
> +  [255]
>   
>     $ 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
> +  o  2: 155349b645be added c
>     |  	default
>     |
> -  | o  2: 155349b645be added c
> -  |/   	default
> -  |
>     o  1: 5f6d8a4bf34a added b
>     |  	default
>     |
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -1675,6 +1675,8 @@
>   
>           if 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'))
>           elif opts.get('amend'):
>               if (repo['.'].p1().branch() != branch and
>                   repo['.'].p2().branch() != branch):
> 
> 
> 
> To: khanchi97, #hg-reviewers
> Cc: mercurial-devel
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
> 

-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list