[Bug 6888] New: Unclear how to abort merging uncommitted changes into an ancestor on hg update REV

mercurial-bugs at mercurial-scm.org mercurial-bugs at mercurial-scm.org
Wed Jul 10 12:05:28 UTC 2024


https://bz.mercurial-scm.org/show_bug.cgi?id=6888

            Bug ID: 6888
           Summary: Unclear how to abort merging uncommitted changes into
                    an ancestor on hg update REV
           Product: Mercurial
           Version: 6.7.4
          Hardware: PC
                OS: NetBSD
            Status: UNCONFIRMED
          Severity: bug
          Priority: wish
         Component: Mercurial
          Assignee: bugzilla at mercurial-scm.org
          Reporter: mercurial-bugzilla at campbell.mumble.net
                CC: mercurial-devel at mercurial-scm.org
    Python Version: ---

I was in a tree with four changesets on a topic, and some uncommitted changes
(which I had forgotten about).

I wanted to update to the root of the topic (public commit on the main branch)
to try a build and compare it to the build on the topic.

I ran

hg update s0

and was confronted by a message like:

merging distrib/sets/sets.subr
merge: warning: conflicts during merge
merging distrib/sets/sets.subr failed!
14 files updated, 0 files merged, 0 files removed, 1 files unresolved
use 'hg resolve' to retry unresolved file merges

At this point I realized I had uncommitted changes which I wanted to keep
intact, and commit, before I go back to s0 to test something.

In git, I would do `git merge --abort' or similar in order to restore the
commit I was at _and_ the uncommitted changes in my tree.  (Except I don't
think even git lets you try to apply uncommitted changes to an ancestor commit
unless you go out of your way with `git checkout --merge <commit>' or `git
switch --merge --detach <commit>'.)

I looked at the following options:

(a) hg merge --abort

    Problem 1: hg help update says: "To cancel an uncommitted merge (and lose
your changes), use 'hg merge --abort'."  But I don't want to lose my
uncommitted changes -- I want them back where I had them.

    Problem 2: It fails anyway with "abort: no merge in progress".

(b) hg update <topic>

    Fails with: "abort: outstanding merge conflicts"

(c) hg rollback

    Printed something which I have now lost about push-response, but I'm not
sure it did anything.  If it did, I would guess it might have lost one of my hg
commit --amends, but I'm not sure it did that either.

(d) hg resolve -m <file>, hg update

    This left two layers of merge conflicts, which I stripped off and --
because I had the intact content of the file with uncommitted changes still in
my Emacs buffer -- was able to verify brought me back to the state I wanted.

Surely there is a way to say `oops, never mind, please restore my tree to the
state it was in -- parent changeset and uncommitted changes -- before
attempting the update to an ancestor commit'?

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the Mercurial-devel mailing list