[PATCH 1 of 2] amend: add noise in extra to avoid creating obsolescence cycle (issue3664)

Pierre-Yves David pierre-yves.david at logilab.fr
Thu Oct 18 11:40:26 CDT 2012


On Thu, Oct 18, 2012 at 06:23:03PM +0200, Idan Kamara wrote:
> On Thu, Oct 18, 2012 at 6:03 PM, <pierre-yves.david at logilab.fr> wrote:
> >
> > # HG changeset patch
> > # User Pierre-Yves David <pierre-yves.david at logilab.fr>
> > # Date 1350575482 -7200
> > # Node ID 122ab0793ce25a8ada0895fca25d05dbde7326a3
> > # Parent  a1c4b21fc1b206f5cf386a8d9d5b5882aaa6807f
> > amend: add noise in extra to avoid creating obsolescence cycle (issue3664)
> >
> > Obsolescence cycle are bad and should be avoided as much as possible. The
> > current amend implemented touch changeset meta data as few as possible.
> > This
> > make is easy for amend to result in the same node than a precursors. We
> > add some
> > deterministic noise in extra to avoid this. In practice, the hex of the
> > amended
> > changeset is stored in 'amend-from' extra key.
> >
> > diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
> > --- a/mercurial/cmdutil.py
> > +++ b/mercurial/cmdutil.py
> > @@ -1694,10 +1694,12 @@ def amend(ui, repo, commitfunc, old, ext
> >                  user = opts.get('user') or old.user()
> >                  date = opts.get('date') or old.date()
> >              if not message:
> >                  message = old.description()
> >
> > +            extra['amend-from'] = old.hex()
> > +
> >              new = context.memctx(repo,
> >                                   parents=[base.node(), nullid],
> >                                   text=message,
> >                                   files=files,
> >                                   filectxfn=filectxfn,
> > diff --git a/tests/test-commit-amend.t b/tests/test-commit-amend.t
> > --- a/tests/test-commit-amend.t
> > +++ b/tests/test-commit-amend.t
> > @@ -18,36 +18,35 @@ Refuse to amend public csets:
> >    $ hg ci -Am 'base1'
> >
> >  Nothing to amend:
> >
> >    $ hg ci --amend
> > -  nothing changed
> > -  [1]
> 
> It's a pity that we can't preserve the behavior that when
> nothing changed amend is a no-op. It's useful for a user to
> know that it did what you wanted.

Woops, it slipped in. I'll try to nail that.

-- 
Pierre-Yves David

http://www.logilab.fr/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20121018/9c7d16e5/attachment.pgp>


More information about the Mercurial-devel mailing list