revert conflict without losing non-committed changes
Harvey Chapman
hchapman-hg at 3gfp.com
Mon Aug 4 17:16:22 UTC 2014
On Aug 2, 2014, at 7:46 AM, anatoly techtonik <techtonik at gmail.com> wrote:
> $ hg up default
> merging spyderlib/spyder.py
> merging spyderlib/spyder.py failed!
> 0 files updated, 0 files merged, 1 files removed, 1 files unresolved
> use 'hg resolve' to retry unresolved file merges
>
> Damn, I don't want to resolve anything. Is there any
> way to get back and understand what will happen
> with my files exactly?
I don’t think there’s a single, silver bullet solution. You could:
- Update back to the revision you came from. I couldn’t figure out how to get this revision other than to look inside .hg/merge/state. `hg parents` doesn’t really work. I’m guessing because this merge is not intended to be recorded.
- use `hg resolve --list --no-status` to list the unresolved files
- restore them by moving the .orig versions back in to place, e.g. `mv spyderlib/spyder.py.orig spyderlib/spyder.py`
- now mark all of the unresolved files as resolved: `hg resolve --all --mark`
Testing:
========$ hg gl
o changeset: 3:702134d0f066 tip draft
| Upstream Version
o changeset: 2:5acf82629630 draft
| append
o changeset: 1:14813619b753 draft
| append
@ changeset: 0:b170f1ab73b2 draft
initial
========$ hg status
M file
========$ hg diff -r default
diff --git a/file b/file
--- a/file
+++ b/file
@@ -1,15 +1,7 @@
a
-Upstream Version
+My Local Uncommitted Change
c
d
e
f
g
-h
-i
-j
-k
-l
-m
-n
-o
========$ hg update default
merging file
merging file failed!
0 files updated, 0 files merged, 0 files removed, 1 files unresolved
use 'hg resolve' to retry unresolved file merges
========$ hg resolve --list
U file
========$ ls
file file.orig
========$ head -n 1 .hg/merge/state
b170f1ab73b237626eadbc88c2d83f40bb78e092
========$ hg update b170f1ab73b237626eadbc88c2d83f40bb78e092
merging file
merging file failed!
0 files updated, 0 files merged, 0 files removed, 1 files unresolved
use 'hg resolve' to retry unresolved file merges
========$ for file in `hg resolve --list --no-status`; do mv “$file".orig “$file"; done
========$ hg resolve --all --mark
========$
Notes:
- Is this solution complete?
- Perhaps there’s a better/safer way to get the old parent.
- I’m a little nervous that the second update might clobber one of the original .orig backup files.
- Is there an update-if extension? That is, update will only proceed if the merge is clean?
- Couldn’t all of this be done in an `hg merge|resolve —abort` command?
More information about the Mercurial
mailing list