##// END OF EJS Templates
merge with hg-stable
Thomas Arendsen Hein -
r5058:a3d6de28 merge default
parent child Browse files
Show More
@@ -0,0 +1,30 b''
1 #!/bin/sh
2
3 hg init repo
4 cd repo
5
6 echo line 1 > foo
7 hg ci -qAm 'add foo' -d "1000000 0"
8
9 # copy foo to bar and change both files
10 hg cp foo bar
11 echo line 2-1 >> foo
12 echo line 2-2 >> bar
13 hg ci -m 'cp foo bar; change both' -d "1000000 0"
14
15 # in another branch, change foo in a way that doesn't conflict with
16 # the other changes
17 hg up -qC 0
18 echo line 0 >| foo
19 hg cat foo >> foo
20 hg ci -m 'change foo' -d "1000000 0"
21
22 # we get conflicts that shouldn't be there
23 hg merge --debug
24
25 echo "-- foo --"
26 cat foo
27
28 echo "-- bar --"
29 cat bar
30
@@ -0,0 +1,20 b''
1 resolving manifests
2 overwrite None partial False
3 ancestor 310fd17130da local 2092631ce82b+ remote 7731dad1c2b9
4 foo: versions differ -> m
5 foo: remote copied to bar -> m
6 copying foo to bar
7 merging foo and bar
8 my foo@2092631ce82b+ other bar@7731dad1c2b9 ancestor foo@310fd17130da
9 merging foo
10 my foo@2092631ce82b+ other foo@7731dad1c2b9 ancestor foo@310fd17130da
11 0 files updated, 2 files merged, 0 files removed, 0 files unresolved
12 (branch merge, don't forget to commit)
13 -- foo --
14 line 0
15 line 1
16 line 2-1
17 -- bar --
18 line 0
19 line 1
20 line 2-2
@@ -9,10 +9,11 b' from node import *'
9 from i18n import _
9 from i18n import _
10 import errno, util, os, tempfile, context
10 import errno, util, os, tempfile, context
11
11
12 def filemerge(repo, fw, fo, wctx, mctx):
12 def filemerge(repo, fw, fd, fo, wctx, mctx):
13 """perform a 3-way merge in the working directory
13 """perform a 3-way merge in the working directory
14
14
15 fw = filename in the working directory
15 fw = original filename in the working directory
16 fd = destination filename in the working directory
16 fo = filename in other parent
17 fo = filename in other parent
17 wctx, mctx = working and merge changecontexts
18 wctx, mctx = working and merge changecontexts
18 """
19 """
@@ -27,15 +28,16 b' def filemerge(repo, fw, fo, wctx, mctx):'
27 return name
28 return name
28
29
29 fcm = wctx.filectx(fw)
30 fcm = wctx.filectx(fw)
31 fcmdata = wctx.filectx(fd).data()
30 fco = mctx.filectx(fo)
32 fco = mctx.filectx(fo)
31
33
32 if not fco.cmp(fcm.data()): # files identical?
34 if not fco.cmp(fcmdata): # files identical?
33 return None
35 return None
34
36
35 fca = fcm.ancestor(fco)
37 fca = fcm.ancestor(fco)
36 if not fca:
38 if not fca:
37 fca = repo.filectx(fw, fileid=nullrev)
39 fca = repo.filectx(fw, fileid=nullrev)
38 a = repo.wjoin(fw)
40 a = repo.wjoin(fd)
39 b = temp("base", fca)
41 b = temp("base", fca)
40 c = temp("other", fco)
42 c = temp("other", fco)
41
43
@@ -49,11 +51,11 b' def filemerge(repo, fw, fo, wctx, mctx):'
49 cmd = (os.environ.get("HGMERGE") or repo.ui.config("ui", "merge")
51 cmd = (os.environ.get("HGMERGE") or repo.ui.config("ui", "merge")
50 or "hgmerge")
52 or "hgmerge")
51 r = util.system('%s "%s" "%s" "%s"' % (cmd, a, b, c), cwd=repo.root,
53 r = util.system('%s "%s" "%s" "%s"' % (cmd, a, b, c), cwd=repo.root,
52 environ={'HG_FILE': fw,
54 environ={'HG_FILE': fd,
53 'HG_MY_NODE': str(wctx.parents()[0]),
55 'HG_MY_NODE': str(wctx.parents()[0]),
54 'HG_OTHER_NODE': str(mctx)})
56 'HG_OTHER_NODE': str(mctx)})
55 if r:
57 if r:
56 repo.ui.warn(_("merging %s failed!\n") % fw)
58 repo.ui.warn(_("merging %s failed!\n") % fd)
57
59
58 os.unlink(b)
60 os.unlink(b)
59 os.unlink(c)
61 os.unlink(c)
@@ -380,6 +382,15 b' def applyupdates(repo, action, wctx, mct'
380
382
381 updated, merged, removed, unresolved = 0, 0, 0, 0
383 updated, merged, removed, unresolved = 0, 0, 0, 0
382 action.sort()
384 action.sort()
385 # prescan for copy/renames
386 for a in action:
387 f, m = a[:2]
388 if m == 'm': # merge
389 f2, fd, flags, move = a[2:]
390 if f != fd:
391 repo.ui.debug(_("copying %s to %s\n") % (f, fd))
392 repo.wwrite(fd, repo.wread(f), flags)
393
383 for a in action:
394 for a in action:
384 f, m = a[:2]
395 f, m = a[:2]
385 if f and f[0] == "/":
396 if f and f[0] == "/":
@@ -396,7 +407,7 b' def applyupdates(repo, action, wctx, mct'
396 removed += 1
407 removed += 1
397 elif m == "m": # merge
408 elif m == "m": # merge
398 f2, fd, flags, move = a[2:]
409 f2, fd, flags, move = a[2:]
399 r = filemerge(repo, f, f2, wctx, mctx)
410 r = filemerge(repo, f, fd, f2, wctx, mctx)
400 if r > 0:
411 if r > 0:
401 unresolved += 1
412 unresolved += 1
402 else:
413 else:
@@ -404,12 +415,9 b' def applyupdates(repo, action, wctx, mct'
404 updated += 1
415 updated += 1
405 else:
416 else:
406 merged += 1
417 merged += 1
407 if f != fd:
418 if f != fd and move:
408 repo.ui.debug(_("copying %s to %s\n") % (f, fd))
419 repo.ui.debug(_("removing %s\n") % f)
409 repo.wwrite(fd, repo.wread(f), flags)
420 os.unlink(repo.wjoin(f))
410 if move:
411 repo.ui.debug(_("removing %s\n") % f)
412 os.unlink(repo.wjoin(f))
413 util.set_exec(repo.wjoin(fd), "x" in flags)
421 util.set_exec(repo.wjoin(fd), "x" in flags)
414 elif m == "g": # get
422 elif m == "g": # get
415 flags = a[2]
423 flags = a[2]
@@ -5,7 +5,7 b' adding quux2'
5 merging bar
5 merging bar
6 merging bar failed!
6 merging bar failed!
7 merging foo and baz
7 merging foo and baz
8 merging foo failed!
8 merging baz failed!
9 1 files updated, 0 files merged, 0 files removed, 2 files unresolved
9 1 files updated, 0 files merged, 0 files removed, 2 files unresolved
10 There are unresolved merges, you can redo the full merge using:
10 There are unresolved merges, you can redo the full merge using:
11 hg update -C 2
11 hg update -C 2
@@ -7,9 +7,9 b' resolving manifests'
7 a2: divergent renames -> dr
7 a2: divergent renames -> dr
8 a: remote moved to b -> m
8 a: remote moved to b -> m
9 b2: remote created -> g
9 b2: remote created -> g
10 copying a to b
10 merging a and b
11 merging a and b
11 my a@f26ec4fc3fa3+ other b@8e765a822af2 ancestor a@af1939970a1c
12 my a@f26ec4fc3fa3+ other b@8e765a822af2 ancestor a@af1939970a1c
12 copying a to b
13 removing a
13 removing a
14 warning: detected divergent renames of a2 to:
14 warning: detected divergent renames of a2 to:
15 c2
15 c2
@@ -6,17 +6,17 b' resolving manifests'
6 ancestor 924404dff337 local e300d1c794ec+ remote 735846fee2d7
6 ancestor 924404dff337 local e300d1c794ec+ remote 735846fee2d7
7 rev: versions differ -> m
7 rev: versions differ -> m
8 a: remote copied to b -> m
8 a: remote copied to b -> m
9 copying a to b
9 merging a and b
10 merging a and b
10 my a@e300d1c794ec+ other b@735846fee2d7 ancestor a@924404dff337
11 my a@e300d1c794ec+ other b@735846fee2d7 ancestor a@924404dff337
11 copying a to b
12 merging rev
12 merging rev
13 my rev@e300d1c794ec+ other rev@735846fee2d7 ancestor rev@924404dff337
13 my rev@e300d1c794ec+ other rev@735846fee2d7 ancestor rev@924404dff337
14 0 files updated, 2 files merged, 0 files removed, 0 files unresolved
14 0 files updated, 2 files merged, 0 files removed, 0 files unresolved
15 (branch merge, don't forget to commit)
15 (branch merge, don't forget to commit)
16 --------------
16 --------------
17 M a
18 M b
17 M b
19 a
18 a
19 C a
20 --------------
20 --------------
21
21
22 --------------
22 --------------
@@ -49,9 +49,9 b' resolving manifests'
49 ancestor 924404dff337 local e300d1c794ec+ remote e03727d2d66b
49 ancestor 924404dff337 local e300d1c794ec+ remote e03727d2d66b
50 rev: versions differ -> m
50 rev: versions differ -> m
51 a: remote moved to b -> m
51 a: remote moved to b -> m
52 copying a to b
52 merging a and b
53 merging a and b
53 my a@e300d1c794ec+ other b@e03727d2d66b ancestor a@924404dff337
54 my a@e300d1c794ec+ other b@e03727d2d66b ancestor a@924404dff337
54 copying a to b
55 removing a
55 removing a
56 merging rev
56 merging rev
57 my rev@e300d1c794ec+ other rev@e03727d2d66b ancestor rev@924404dff337
57 my rev@e300d1c794ec+ other rev@e03727d2d66b ancestor rev@924404dff337
@@ -357,9 +357,9 b' resolving manifests'
357 ancestor 924404dff337 local e300d1c794ec+ remote 79cc6877a3b7
357 ancestor 924404dff337 local e300d1c794ec+ remote 79cc6877a3b7
358 rev: versions differ -> m
358 rev: versions differ -> m
359 a: remote moved to b -> m
359 a: remote moved to b -> m
360 copying a to b
360 merging a and b
361 merging a and b
361 my a@e300d1c794ec+ other b@79cc6877a3b7 ancestor a@924404dff337
362 my a@e300d1c794ec+ other b@79cc6877a3b7 ancestor a@924404dff337
362 copying a to b
363 removing a
363 removing a
364 merging rev
364 merging rev
365 my rev@e300d1c794ec+ other rev@79cc6877a3b7 ancestor rev@924404dff337
365 my rev@e300d1c794ec+ other rev@79cc6877a3b7 ancestor rev@924404dff337
General Comments 0
You need to be logged in to leave comments. Login now