##// END OF EJS Templates
Clean up some merge logic...
mpm@selenic.com -
r993:6f274afc default
parent child Browse files
Show More
@@ -1749,7 +1749,7 b' class localrepository:'
1749
1749
1750 if linear_path or force:
1750 if linear_path or force:
1751 # we don't need to do any magic, just jump to the new rev
1751 # we don't need to do any magic, just jump to the new rev
1752 mode = 'n'
1752 branch_merge = False
1753 p1, p2 = p2, nullid
1753 p1, p2 = p2, nullid
1754 else:
1754 else:
1755 if not allow:
1755 if not allow:
@@ -1765,7 +1765,7 b' class localrepository:'
1765 self.ui.status("(use update -m to merge across branches" +
1765 self.ui.status("(use update -m to merge across branches" +
1766 " or -C to lose changes)\n")
1766 " or -C to lose changes)\n")
1767 return 1
1767 return 1
1768 mode = 'm'
1768 branch_merge = True
1769
1769
1770 if moddirstate:
1770 if moddirstate:
1771 self.dirstate.setparents(p1, p2)
1771 self.dirstate.setparents(p1, p2)
@@ -1784,8 +1784,8 b' class localrepository:'
1784 self.wfile(f, "w").write(t)
1784 self.wfile(f, "w").write(t)
1785 util.set_exec(self.wjoin(f), mf2[f])
1785 util.set_exec(self.wjoin(f), mf2[f])
1786 if moddirstate:
1786 if moddirstate:
1787 if mode == 'm':
1787 if branch_merge:
1788 self.dirstate.update([f], 'n', st_mtime=0)
1788 self.dirstate.update([f], 'n', st_mtime=-1)
1789 else:
1789 else:
1790 self.dirstate.update([f], 'n')
1790 self.dirstate.update([f], 'n')
1791
1791
@@ -1794,23 +1794,22 b' class localrepository:'
1794 files.sort()
1794 files.sort()
1795 for f in files:
1795 for f in files:
1796 self.ui.status("merging %s\n" % f)
1796 self.ui.status("merging %s\n" % f)
1797 m, o, flag = merge[f]
1797 my, other, flag = merge[f]
1798 self.merge3(f, m, o)
1798 self.merge3(f, my, other)
1799 util.set_exec(self.wjoin(f), flag)
1799 util.set_exec(self.wjoin(f), flag)
1800 if moddirstate:
1800 if moddirstate:
1801 if mode == 'm':
1801 if branch_merge:
1802 # only update dirstate on branch merge, otherwise we
1802 # We've done a branch merge, mark this file as merged
1803 # could mark files with changes as unchanged
1803 # so that we properly record the merger later
1804 self.dirstate.update([f], mode)
1804 self.dirstate.update([f], 'm')
1805 elif p2 == nullid:
1806 # update dirstate from parent1's manifest
1807 m1n = self.changelog.read(p1)[0]
1808 m1 = self.manifest.read(m1n)
1809 f_len = len(self.file(f).read(m1[f]))
1810 self.dirstate.update([f], mode, st_size=f_len, st_mtime=0)
1811 else:
1805 else:
1812 self.ui.warn("Second parent without branch merge!?\n"
1806 # We've update-merged a locally modified file, so
1813 "Dirstate for file %s may be wrong.\n" % f)
1807 # we set the dirstate to emulate a normal checkout
1808 # of that file some time in the past. Thus our
1809 # merge will appear as a normal local file
1810 # modification.
1811 f_len = len(self.file(f).read(other))
1812 self.dirstate.update([f], 'n', st_size=f_len, st_mtime=-1)
1814
1813
1815 remove.sort()
1814 remove.sort()
1816 for f in remove:
1815 for f in remove:
@@ -1823,10 +1822,10 b' class localrepository:'
1823 try: os.removedirs(os.path.dirname(self.wjoin(f)))
1822 try: os.removedirs(os.path.dirname(self.wjoin(f)))
1824 except: pass
1823 except: pass
1825 if moddirstate:
1824 if moddirstate:
1826 if mode == 'n':
1825 if branch_merge:
1826 self.dirstate.update(remove, 'r')
1827 else:
1827 self.dirstate.forget(remove)
1828 self.dirstate.forget(remove)
1828 else:
1829 self.dirstate.update(remove, 'r')
1830
1829
1831 def merge3(self, fn, my, other):
1830 def merge3(self, fn, my, other):
1832 """perform a 3-way merge in the working directory"""
1831 """perform a 3-way merge in the working directory"""
@@ -41,7 +41,7 b' hg debugstate | cut -b 1-16,35-'
41
41
42 echo merging
42 echo merging
43 hg pull ../a
43 hg pull ../a
44 env HGMERGE=../merge hg update -vm --debug
44 env HGMERGE=../merge hg update -vm
45
45
46 echo 2m > foo
46 echo 2m > foo
47 echo 2b > baz
47 echo 2b > baz
@@ -55,6 +55,9 b' hg ci -m "merge" -d "0 0"'
55 echo "main: we should have a merge here"
55 echo "main: we should have a merge here"
56 hg debugindex .hg/00changelog.i
56 hg debugindex .hg/00changelog.i
57
57
58 echo "log should show foo and quux changed"
59 hg log -v -r tip
60
58 echo "foo: we should have a merge here"
61 echo "foo: we should have a merge here"
59 hg debugindex .hg/data/foo.i
62 hg debugindex .hg/data/foo.i
60
63
@@ -67,6 +70,9 b' hg debugindex .hg/data/baz.i'
67 echo "quux: we shouldn't have a merge here"
70 echo "quux: we shouldn't have a merge here"
68 hg debugindex .hg/data/quux.i
71 hg debugindex .hg/data/quux.i
69
72
73 echo "manifest entries should match tips of all files"
74 hg manifest
75
70 echo "everything should be clean now"
76 echo "everything should be clean now"
71 hg status
77 hg status
72
78
@@ -16,14 +16,9 b' added 1 changesets with 2 changes to 2 f'
16 (run 'hg update' to get a working copy)
16 (run 'hg update' to get a working copy)
17 merging for foo
17 merging for foo
18 resolving manifests
18 resolving manifests
19 force None allow 1 moddirstate True linear False
20 ancestor a0486579db29 local ef1b4dbe2193 remote 336d8406d617
21 remote bar is newer, get
22 foo versions differ, resolve
23 getting bar
19 getting bar
24 merging foo
20 merging foo
25 resolving foo
21 resolving foo
26 file foo: other 33d1fb69067a ancestor b8e02f643373
27 we shouldn't have anything but foo in merge state here
22 we shouldn't have anything but foo in merge state here
28 m 644 3 foo
23 m 644 3 foo
29 main: we should have a merge here
24 main: we should have a merge here
@@ -31,7 +26,19 b' main: we should have a merge here'
31 0 0 73 0 0 cdca01651b96 000000000000 000000000000
26 0 0 73 0 0 cdca01651b96 000000000000 000000000000
32 1 73 68 1 1 f6718a9cb7f3 cdca01651b96 000000000000
27 1 73 68 1 1 f6718a9cb7f3 cdca01651b96 000000000000
33 2 141 68 2 2 bdd988058d16 cdca01651b96 000000000000
28 2 141 68 2 2 bdd988058d16 cdca01651b96 000000000000
34 3 209 66 3 3 9da9fbd62226 f6718a9cb7f3 bdd988058d16
29 3 209 66 3 3 d8a521142a3c f6718a9cb7f3 bdd988058d16
30 log should show foo and quux changed
31 changeset: 3:d8a521142a3c02186ee6c7254738a7e6427ed4c8
32 tag: tip
33 parent: 1:f6718a9cb7f31f1a92d27bd6544c71617d6d4e4f
34 parent: 2:bdd988058d16e2d7392958eace7b64817e44a54e
35 user: test
36 date: Thu Jan 1 00:00:00 1970 +0000
37 files: foo quux
38 description:
39 merge
40
41
35 foo: we should have a merge here
42 foo: we should have a merge here
36 rev offset length base linkrev nodeid p1 p2
43 rev offset length base linkrev nodeid p1 p2
37 0 0 3 0 0 b8e02f643373 000000000000 000000000000
44 0 0 3 0 0 b8e02f643373 000000000000 000000000000
@@ -50,6 +57,11 b" quux: we shouldn't have a merge here"
50 rev offset length base linkrev nodeid p1 p2
57 rev offset length base linkrev nodeid p1 p2
51 0 0 3 0 0 b8e02f643373 000000000000 000000000000
58 0 0 3 0 0 b8e02f643373 000000000000 000000000000
52 1 3 5 1 3 6128c0f33108 b8e02f643373 000000000000
59 1 3 5 1 3 6128c0f33108 b8e02f643373 000000000000
60 manifest entries should match tips of all files
61 33d1fb69067a0139622a3fa3b7ba1cdb1367972e 644 bar
62 2ffeddde1b65b4827f6746174a145474129fa2ce 644 baz
63 aa27919ee4303cfd575e1fb932dd64d75aa08be4 644 foo
64 6128c0f33108e8cfbb4e0824d13ae48b466d7280 644 quux
53 everything should be clean now
65 everything should be clean now
54 checking changesets
66 checking changesets
55 checking manifests
67 checking manifests
@@ -6,7 +6,7 b' adding file changes'
6 added 1 changesets with 1 changes to 1 files
6 added 1 changesets with 1 changes to 1 files
7 (run 'hg update' to get a working copy)
7 (run 'hg update' to get a working copy)
8 bar should remain deleted.
8 bar should remain deleted.
9 f405ac83a5611071d6b54dd5eb26943b1fdc4460 644 foo
9 f9b0e817f6a48de3564c6b2957687c5e7297c5a0 644 foo
10 pulling from ../A2
10 pulling from ../A2
11 searching for changes
11 searching for changes
12 adding changesets
12 adding changesets
@@ -11,7 +11,7 b' summary: 2'
11
11
12 05f9e54f4c9b86b09099803d8b49a50edcb4eaab 644 a
12 05f9e54f4c9b86b09099803d8b49a50edcb4eaab 644 a
13 76d5e637cbec1bcc04a5a3fa4bcc7d13f6847c00 644 c
13 76d5e637cbec1bcc04a5a3fa4bcc7d13f6847c00 644 c
14 changeset: 3:c8225a106186
14 changeset: 3:142428fbbcc5
15 tag: tip
15 tag: tip
16 user: test
16 user: test
17 date: Thu Jan 1 00:00:00 1970 +0000
17 date: Thu Jan 1 00:00:00 1970 +0000
@@ -19,7 +19,7 b' summary: 3'
19
19
20 d6e3c4976c13feb1728cd3ac851abaf7256a5c23 644 a
20 d6e3c4976c13feb1728cd3ac851abaf7256a5c23 644 a
21 76d5e637cbec1bcc04a5a3fa4bcc7d13f6847c00 644 c
21 76d5e637cbec1bcc04a5a3fa4bcc7d13f6847c00 644 c
22 changeset: 4:8dfeee82a94b
22 changeset: 4:4d450f9aa680
23 tag: tip
23 tag: tip
24 user: test
24 user: test
25 date: Thu Jan 1 00:00:00 1970 +0000
25 date: Thu Jan 1 00:00:00 1970 +0000
@@ -28,16 +28,16 b' summary: 4'
28 05f9e54f4c9b86b09099803d8b49a50edcb4eaab 644 a
28 05f9e54f4c9b86b09099803d8b49a50edcb4eaab 644 a
29 54837d97f2932a8194e69745a280a2c11e61ff9c 644 b
29 54837d97f2932a8194e69745a280a2c11e61ff9c 644 b
30 3570202ceac2b52517df64ebd0a062cb0d8fe33a 644 c
30 3570202ceac2b52517df64ebd0a062cb0d8fe33a 644 c
31 changeset: 4:8dfeee82a94b
31 changeset: 4:4d450f9aa680
32 user: test
32 user: test
33 date: Thu Jan 1 00:00:00 1970 +0000
33 date: Thu Jan 1 00:00:00 1970 +0000
34 summary: 4
34 summary: 4
35
35
36 d6e3c4976c13feb1728cd3ac851abaf7256a5c23 644 a
36 d6e3c4976c13feb1728cd3ac851abaf7256a5c23 644 a
37 76d5e637cbec1bcc04a5a3fa4bcc7d13f6847c00 644 c
37 76d5e637cbec1bcc04a5a3fa4bcc7d13f6847c00 644 c
38 changeset: 6:c0e932ecae5e
38 changeset: 6:b4b8b9afa8cc
39 tag: tip
39 tag: tip
40 parent: 4:8dfeee82a94b
40 parent: 4:4d450f9aa680
41 parent: 5:a7925a42d0df
41 parent: 5:a7925a42d0df
42 user: test
42 user: test
43 date: Thu Jan 1 00:00:00 1970 +0000
43 date: Thu Jan 1 00:00:00 1970 +0000
@@ -45,7 +45,7 b' summary: 6'
45
45
46 d6e3c4976c13feb1728cd3ac851abaf7256a5c23 644 a
46 d6e3c4976c13feb1728cd3ac851abaf7256a5c23 644 a
47 76d5e637cbec1bcc04a5a3fa4bcc7d13f6847c00 644 c
47 76d5e637cbec1bcc04a5a3fa4bcc7d13f6847c00 644 c
48 changeset: 7:3a157da4365d
48 changeset: 7:f84d0b1b024e
49 tag: tip
49 tag: tip
50 user: test
50 user: test
51 date: Thu Jan 1 00:00:00 1970 +0000
51 date: Thu Jan 1 00:00:00 1970 +0000
@@ -10,4 +10,5 b' acb14030fe0a+ first'
10 acb14030fe0a21b60322c440ad2d20cf7685a376+ first
10 acb14030fe0a21b60322c440ad2d20cf7685a376+ first
11 M a
11 M a
12 c8edf04160c7 tip
12 c8edf04160c7 tip
13 c8edf04160c7+b9154636be93 tip
13 c8edf04160c7+b9154636be93+ tip
14 M .hgtags
General Comments 0
You need to be logged in to leave comments. Login now