Keeping local changes while switching revisions

Christoph Rissner c.r at visotech.at
Wed Feb 24 16:21:04 UTC 2010


On 02/24/2010 04:57 PM, Martin Kacer wrote:
 > I can either use "update -C" (which discards the local changes) or
 > "update -c" (which aborts the operation). To my knowledge, there is no
 > way to keep the changed file in the workspace or to attempt a merge.

Its a little bit cumbersome, but you can update twice via the common 
ancestor (hg debugancestor):

$ hg init x
$ cd x
$ touch a b c
$ hg ci -Am "r0"
adding a
adding b
adding c
$ echo 1 >> a
$ hg ci -m "r1"
$ hg up 0
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ echo 1 >> b
$ hg ci -m "r2"
created new head
$ echo 1 >> c
$ hg up -r 1
abort: crosses branches (use 'hg merge' to merge or use 'hg update -C' 
to discard changes)
$ hg debugancestor 1 2
0:6959404609da606e9d6386b8e47f480377321073
$ hg up 0
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg up -r 1
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg diff
diff -r 97bf5d4385b7 c
--- a/c
+++ b/c
@@ -0,0 +1,1 @@
+1


Christoph Rissner




More information about the Mercurial mailing list