<div dir="ltr">On Thu, Oct 18, 2012 at 9:11 PM, Pierre-Yves David <<a href="mailto:pierre-yves.david@ens-lyon.org">pierre-yves.david@ens-lyon.org</a>> wrote:<br>><br>> # HG changeset patch<br>> # User Pierre-Yves David <<a href="mailto:pierre-yves.david@logilab.fr">pierre-yves.david@logilab.fr</a>><br>
> # Date 1350587037 -7200<br>> # Node ID 7ec488b147963f80344dd4431f74faac66e68ef0<br>> # Parent  a1c4b21fc1b206f5cf386a8d9d5b5882aaa6807f<br>> amend: add noise in extra to avoid creating obsolescence cycle (issue3664)<br>
><br>> Obsolescence cycle are bad and should be avoided as much as possible. The<br>> current amend implemented touch changeset meta data as few as possible.<br>> This<br>> make is easy for amend to result in the same node than a precursors. We<br>
> add some<br>> deterministic noise in extra to avoid this. In practice, the hex of the<br>> amended<br>> changeset is stored in 'amend_source' extra key.<br>><br>> diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py<br>
> --- a/mercurial/cmdutil.py<br>> +++ b/mercurial/cmdutil.py<br>> @@ -1696,6 +1696,9 @@<br>>              if not message:<br>>                  message = old.description()<br>><br>> +            pureextra = extra.copy()<br>
> +            extra['amend_source'] = old.hex()<br>> +<br>>              new = context.memctx(repo,<br>>                                   parents=[base.node(), nullid],<br>>                                   text=message,<br>
> @@ -1705,6 +1708,18 @@<br>>                                   date=date,<br>>                                   extra=extra)<br>>              new._text = commitforceeditor(repo, new, [])<br>> +<br>> +            if ((not node)<br>
> +                and new._text == old.description()<br>> +                and user == old.user()<br>> +                and date == old.date()<br>> +                and pureextra == old.extra()):<br>> +                # nothing changed. continuing here would create a new<br>
> node<br>> +                # anyway because of the amend_source noise.<br>> +                #<br>> +                # This not what we expect from amend.<br>> +                return old.node()<br>> +<br>
>              ph = repo.ui.config('phases', 'new-commit', phases.draft)<br>>              try:<br>>                  repo.ui.setconfig('phases', 'new-commit', old.phase())<br>> diff --git a/tests/test-commit-amend.t b/tests/test-commit-amend.t<br>
> --- a/tests/test-commit-amend.t<br>> +++ b/tests/test-commit-amend.t<br>> @@ -20,8 +20,7 @@<br>>  Nothing to amend:<br>><br>>    $ hg ci --amend<br>> -  nothing changed<br>> -  [1]<br>> +  saved backup bundle to<br>
> $TESTTMP/.hg/strip-backup/489edb5b847d-amend-backup.hg (glob)<br><div><br></div><div>Still buggy :(</div></div>