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

Idan Kamara idankk86 at gmail.com
Thu Oct 18 14:16:58 CDT 2012


On Thu, Oct 18, 2012 at 9:11 PM, Pierre-Yves David <
pierre-yves.david at ens-lyon.org> wrote:
>
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at logilab.fr>
> # Date 1350587037 -7200
> # Node ID 7ec488b147963f80344dd4431f74faac66e68ef0
> # 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_source' extra key.
>
> diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
> --- a/mercurial/cmdutil.py
> +++ b/mercurial/cmdutil.py
> @@ -1696,6 +1696,9 @@
>              if not message:
>                  message = old.description()
>
> +            pureextra = extra.copy()
> +            extra['amend_source'] = old.hex()
> +
>              new = context.memctx(repo,
>                                   parents=[base.node(), nullid],
>                                   text=message,
> @@ -1705,6 +1708,18 @@
>                                   date=date,
>                                   extra=extra)
>              new._text = commitforceeditor(repo, new, [])
> +
> +            if ((not node)
> +                and new._text == old.description()
> +                and user == old.user()
> +                and date == old.date()
> +                and pureextra == old.extra()):
> +                # nothing changed. continuing here would create a new
> node
> +                # anyway because of the amend_source noise.
> +                #
> +                # This not what we expect from amend.
> +                return old.node()
> +
>              ph = repo.ui.config('phases', 'new-commit', phases.draft)
>              try:
>                  repo.ui.setconfig('phases', 'new-commit', old.phase())
> 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
> @@ -20,8 +20,7 @@
>  Nothing to amend:
>
>    $ hg ci --amend
> -  nothing changed
> -  [1]
> +  saved backup bundle to
> $TESTTMP/.hg/strip-backup/489edb5b847d-amend-backup.hg (glob)

Still buggy :(
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20121018/a057cd59/attachment.html>


More information about the Mercurial-devel mailing list