[PATCH] merge: suggest 'hg up -C .' for discarding changes, not 'hg up -C'

Martin Geisler mg at lazybytes.net
Thu Sep 2 10:26:09 CDT 2010

Brodie Rao <brodie at bitheap.org> writes:

> # HG changeset patch
> # User Brodie Rao <brodie at bitheap.org>
> # Date 1283371843 14400
> # Node ID 950086b9dff8c05fbc454f7c95da23792e33c71f
> # Parent  a55e3c50868fc2e827f44187c7fd3f6c4e2f3f31
> merge: suggest 'hg up -C .' for discarding changes, not 'hg up -C'
> Without specifying the parent revision of the working copy, users will
> update to tip, which is most likely the other head they were trying to
> merge, not the revision they were at before the merge.
> diff -r a55e3c50868f -r 950086b9dff8 mercurial/merge.py
> --- a/mercurial/merge.py	Wed Sep 01 15:23:21 2010 +0200
> +++ b/mercurial/merge.py	Wed Sep 01 16:10:43 2010 -0400
> @@ -448,7 +448,7 @@ def update(repo, node, branchmerge, forc
>      * = don't-care
>      1 = abort: crosses branches (use 'hg merge' or 'hg update -c')
>      2 = abort: crosses branches (use 'hg merge' to merge or
> -                 use 'hg update -C' to discard changes)
> +                 use 'hg update -C .' to discard changes)
>      3 = abort: uncommitted local changes
>      4 = incompatible options (checked in commands.py)
>      """
> @@ -494,7 +494,8 @@ def update(repo, node, branchmerge, forc
>                  pass # all good
>              elif wc.files() or wc.deleted():
>                  raise util.Abort(_("crosses branches (use 'hg merge' to merge "
> -                                 "or use 'hg update -C' to discard changes)"))
> +                                   "or use 'hg update -C .' to discard "
> +                                   "changes)"))

I don't think these two hunks should change -- that warning is for the
case where a user does 'hg update X' with a dirty working copy.

The text is actually a bit too short, it should really say:

  crosses branches (use 'hg merge %s' to merge or use 'hg update -C %s'
  to discard changes

where %s is replaced with the revision the user is trying to update to.

In a similar way, I always liked how old versions of Mercurial would
tell me exactly what I needed to do in order to abandon a merge and get
back to where I were or restart it -- the messages like this one:

  There are unresolved merges, you can redo the full merge using:
    hg update -C 123
    hg merge 234

It make Mercurial look very helpful and aware of what is going on.

Martin Geisler

Mercurial links: http://mercurial.ch/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20100902/147c3663/attachment.pgp>

More information about the Mercurial-devel mailing list