[PATCH] histedit: refuse to edit public changeset

Augie Fackler raf at durin42.com
Fri Oct 12 16:18:22 CDT 2012


queued, thanks

On Oct 12, 2012, at 2:42 PM, Pierre-Yves David <pierre-yves.david at ens-lyon.org> wrote:

> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
> # Date 1350070868 -7200
> # Node ID 1bf90fff15d58465702c43eae393e7f60876d21a
> # Parent  d23c9738da3c5b493eaac557afb2988a5ec6af7c
> histedit: refuse to edit public changeset
> 
> Public changeset are immutable. This changeset enforce that in histedit.
> 
> diff --git a/hgext/histedit.py b/hgext/histedit.py
> --- a/hgext/histedit.py
> +++ b/hgext/histedit.py
> @@ -588,8 +588,12 @@
> 
>     When keep is false, the specified set can't have children."""
>     revs = list(repo.set('%n::%n', old, new))
> -    if not keep and repo.revs('(%ld::) - (%ld + hidden())', revs, revs):
> -        raise util.Abort(_('cannot edit history that would orphan nodes'))
> +    if not keep:
> +        if repo.revs('(%ld::) - (%ld + hidden())', revs, revs):
> +            raise util.Abort(_('cannot edit history that would orphan nodes'))
> +        root = min(revs)
> +        if not root.phase():
> +            raise util.Abort(_('cannot edit immutable changeset: %s') % root)
>     return [c.node() for c in revs]
> 
> 
> diff --git a/tests/test-histedit-obsolete.t b/tests/test-histedit-obsolete.t
> --- a/tests/test-histedit-obsolete.t
> +++ b/tests/test-histedit-obsolete.t
> @@ -121,3 +121,22 @@
>> EOF
>   $ hg histedit 6 --commands commands.txt
>   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
> +
> +
> +Check that histedit respect phases
> +=========================================
> +
> +(not directly related to the test file but doesn't deserve it's own test case)
> +
> +  $ hg log -G
> +  @  9:7c044e3e33a9 f
> +  |
> +  o  6:d36c0562f908 c
> +  |
> +  o  0:cb9a9f314b8b a
> +  
> +  $ hg ph -pv '.^'
> +  phase changed for 2 changesets
> +  $ hg histedit -r '.~2'
> +  abort: cannot edit immutable changeset: cb9a9f314b8b
> +  [255]



More information about the Mercurial-devel mailing list