Reverse the way backout is doing the merge

Peter Arrenbrecht peter.arrenbrecht at gmail.com
Thu Feb 21 03:35:01 CST 2008


I believe this proposal is related to

  http://www.venge.net/mtn-wiki/DaggyFixes

The current behaviour seems to be daggy, the proposed one not. From a
theoretical point of view I would prefer the daggy behaviour. However,
I have no practical experience with backout, so I cannot comment on
its actual usability.
-peo

On Thu, Feb 21, 2008 at 9:16 AM, Gilles Moris <gilles.moris at free.fr> wrote:
> I would like to propose a slight modification of the backout command.
>  The reason is that I found that the use of the command is not very
>  intuitive.
>
>  Currently, backout is creating a backout revision as a child node of the
>  backed out node and will leave you at this new head. Additionally, the
>  --merge option will merge into it the head from where the backout
>  command was issued. Then you need to commit to finish the merge. I find
>  that this has several drawbacks:
>  * this changes the current head, which I find disturbing for a user
>  * when there is a long history between the backed out node and the
>  current head, this will generate a huge number of diffs that are scary
>  at first sight, and not very natural to review before commit.
>
>  I propose to switch back to the original node as soon as the backout
>  node (which becomes the new tip) has been created. Then the --merge
>  option can just merge this new tip in the current node. The advantages
>  are that:
>  * the current head/node is not changed from the user's point of view
>  * even without using the --merge option, the backout revision is still
>  easy to locate, as this is the tip
>  * the merge is much more intuitive as diffs of the merge is right you
>  are looking to backout
>  * it does not change the API, just the behavior if --merge is not used.
>  So the impact should not be too big.
>
>  Tell me your thoughts.
>  Thanks.
>  Gilles.
>
>  Here follows the patch for main:
>
>  # HG changeset patch
>  # User Gilles Moris <gilles.moris at free.fr>
>  # Date 1203580372 -3600
>  # Node ID 799e763abe3887a041167c6b854643f34e11444b
>  # Parent  9b817c0a82f1cd556bf3803b7ea2caea4918509c
>  Reverse the way backout is doing the merge
>
>  Currently, backout is creating a backout revision as a child node of the
>  backed out node and will leave you at this new head. This has several
>  drawbacks:
>  * this changes the current head
>  * when there is a long history between the backed out node and the
>  current head, this will generate a huge number of diffs that are scary
>  at first sight, and not very natural to review before commit.
>  The change consists to switch back to the original node as soon as the
>  backout node (which becomes the new tip) has been created. Then the
>  --merge option can just merge this new tip in the current node.
>  * the current head/node is not changed from the user's point of view
>  * even without using the --merge option, the backout revision is still
>  easy to locate, as this is the tip
>  * the merge is much more intuitive as diffs of the merge is right you
>  are looking to backout
>
>  diff -r 9b817c0a82f1 -r 799e763abe38 mercurial/commands.py
>  --- a/mercurial/commands.py     Thu Feb 14 10:55:17 2008 -0600
>  +++ b/mercurial/commands.py     Thu Feb 21 08:52:52 2008 +0100
>  @@ -176,10 +176,8 @@ def backout(ui, repo, node=None, rev=Non
>       changeset is a child of the backed out changeset.
>
>       If you back out a changeset other than the tip, a new head is
>  -    created.  This head is the parent of the working directory.  If
>  -    you back out an old changeset, your working directory will appear
>  -    old after the backout.  You should merge the backout changeset
>  -    with another head.
>  +    created.  This head will be the new tip and you should merge this
>  +    backout changeset with another head (current one by default).
>
>       The --merge option remembers the parent of the working directory
>       before starting the backout, then merges the new head with that
>  @@ -238,9 +236,10 @@ def backout(ui, repo, node=None, rev=Non
>       ui.status(_('changeset %s backs out changeset %s\n') %
>                 (nice(repo.changelog.tip()), nice(node)))
>       if op1 != node:
>  +        hg.clean(repo, op1, show_stats=False)
>           if opts['merge']:
>  -            ui.status(_('merging with changeset %s\n') % nice(op1))
>  -            hg.merge(repo, hex(op1))
>  +            ui.status(_('merging with changeset %s\n') % nice(repo.changelog.tip()))
>  +            hg.merge(repo, hex(repo.changelog.tip()))
>           else:
>               ui.status(_('the backout changeset is a new head - '
>                           'do not forget to merge\n'))
>  diff -r 9b817c0a82f1 -r 799e763abe38 tests/test-backout
>  --- a/tests/test-backout        Thu Feb 14 10:55:17 2008 -0600
>  +++ b/tests/test-backout        Thu Feb 21 08:52:52 2008 +0100
>  @@ -59,9 +59,10 @@ cd merge
>   cd merge
>
>   echo line 1 > a
>  +echo line 2 >> a
>   hg commit -d '0 0' -A -m a
>  -
>  -echo line 2 >> a
>  +# remove line 1
>  +echo line 2 > a
>   hg commit -d '1 0' -m b
>
>   echo line 3 >> a
>  @@ -69,6 +70,7 @@ hg commit -d '2 0' -m c
>
>   hg backout --merge -d '3 0' 1
>   hg commit -d '4 0' -m d
>  +# check line 1 is back
>   cat a
>
>   echo '# backout should not back out subsequent changesets'
>  @@ -81,6 +83,8 @@ echo 1 > b
>   echo 1 > b
>   hg commit -d '2 0' -A -m c
>   hg backout -d '3 0' 1
>  +hg locate b
>  +hg update -C tip
>   hg locate b
>
>   cd ..
>  diff -r 9b817c0a82f1 -r 799e763abe38 tests/test-backout.out
>  --- a/tests/test-backout.out    Thu Feb 14 10:55:17 2008 -0600
>  +++ b/tests/test-backout.out    Thu Feb 21 08:52:52 2008 +0100
>  @@ -25,12 +25,14 @@ abort: cannot back out change on a diffe
>   # backout with merge
>   adding a
>   reverting a
>  -changeset 3:3eb045e364a4 backs out changeset 1:314f55b1bf23
>  -merging with changeset 2:b66ea5b77abb
>  +changeset 3:26b8ccb9ad91 backs out changeset 1:5a50a024c182
>  +merging with changeset 3:26b8ccb9ad91
>   merging a
>   0 files updated, 1 files merged, 0 files removed, 0 files unresolved
>   (branch merge, don't forget to commit)
>   line 1
>  +line 2
>  +line 3
>   # backout should not back out subsequent changesets
>   adding a
>   adding b
>  @@ -38,6 +40,8 @@ changeset 3:3202beb76721 backs out chang
>   changeset 3:3202beb76721 backs out changeset 1:22bca4c721e5
>   the backout changeset is a new head - do not forget to merge
>   (use "backout --merge" if you want to auto-merge)
>  +b
>  +1 files updated, 0 files merged, 1 files removed, 0 files unresolved
>   adding a
>   adding b
>   adding c
>  diff -r 9b817c0a82f1 -r 799e763abe38 tests/test-parse-date.out
>  --- a/tests/test-parse-date.out Thu Feb 14 10:55:17 2008 -0600
>  +++ b/tests/test-parse-date.out Thu Feb 21 08:52:52 2008 +0100
>  @@ -1,6 +1,6 @@ reverting a
>   reverting a
>   changeset 3:107ce1ee2b43 backs out changeset 1:25a1420a55f8
>  -merging with changeset 2:e6c3abc120e7
>  +merging with changeset 3:107ce1ee2b43
>   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
>   (branch merge, don't forget to commit)
>   transaction abort!
>
>  _______________________________________________
>  Mercurial mailing list
>  Mercurial at selenic.com
>  http://selenic.com/mailman/listinfo/mercurial
>


More information about the Mercurial mailing list