##// END OF EJS Templates
merge: simplify actions with helper function
Matt Mackall -
r3121:2ef0b3aa default
parent child Browse files
Show More
@@ -106,6 +106,10 b' def manifestmerge(ui, m1, m2, ma, overwr'
106
106
107 action = []
107 action = []
108
108
109 def act(msg, f, m, *args):
110 ui.debug(" %s: %s -> %s\n" % (f, msg, m))
111 action.append((f, m) + args)
112
109 # Filter manifests
113 # Filter manifests
110 if partial:
114 if partial:
111 for f in m1.keys():
115 for f in m1.keys():
@@ -121,56 +125,44 b' def manifestmerge(ui, m1, m2, ma, overwr'
121 a = ma.get(f, nullid)
125 a = ma.get(f, nullid)
122 # are both different from the ancestor?
126 # are both different from the ancestor?
123 if not overwrite and n != a and m2[f] != a:
127 if not overwrite and n != a and m2[f] != a:
124 ui.debug(_(" %s versions differ, resolve\n") % f)
128 act("versions differ", f, "m", fmerge(f), n[:20], m2[f])
125 action.append((f, "m", fmerge(f), n[:20], m2[f]))
126 # are we clobbering?
129 # are we clobbering?
127 # is remote's version newer?
130 # is remote's version newer?
128 # or are we going back in time and clean?
131 # or are we going back in time and clean?
129 elif overwrite or m2[f] != a or (backwards and not n[20:]):
132 elif overwrite or m2[f] != a or (backwards and not n[20:]):
130 ui.debug(_(" remote %s is newer, get\n") % f)
133 act("remote is newer", f, "g", m2.execf(f), m2[f])
131 action.append((f, "g", m2.execf(f), m2[f]))
132 # local is newer, not overwrite, check mode bits
134 # local is newer, not overwrite, check mode bits
133 elif fmerge(f) != m1.execf(f):
135 elif fmerge(f) != m1.execf(f):
134 ui.debug(_(" updating permissions for %s\n") % f)
136 act("update permissions", f, "e", m2.execf(f))
135 action.append((f, "e", m2.execf(f)))
136 # contents same, check mode bits
137 # contents same, check mode bits
137 elif m1.execf(f) != m2.execf(f):
138 elif m1.execf(f) != m2.execf(f):
138 if overwrite or fmerge(f) != m1.execf(f):
139 if overwrite or fmerge(f) != m1.execf(f):
139 ui.debug(_(" updating permissions for %s\n") % f)
140 act("update permissions", f, "e", m2.execf(f))
140 action.append((f, "e", m2.execf(f)))
141 del m2[f]
141 del m2[f]
142 elif f in ma:
142 elif f in ma:
143 if n != ma[f] and not overwrite:
143 if n != ma[f] and not overwrite:
144 if ui.prompt(
144 if ui.prompt(
145 (_(" local changed %s which remote deleted\n") % f) +
145 (_(" local changed %s which remote deleted\n") % f) +
146 _("(k)eep or (d)elete?"), _("[kd]"), _("k")) == _("d"):
146 _("(k)eep or (d)elete?"), _("[kd]"), _("k")) == _("d"):
147 action.append((f, "r"))
147 act("prompt delete", f, "r")
148 else:
148 else:
149 ui.debug(_("other deleted %s\n") % f)
149 act("other deleted", f, "r")
150 action.append((f, "r"))
151 else:
150 else:
152 # file is created on branch or in working directory
151 # file is created on branch or in working directory
153 if (overwrite and n[20:] != "u") or (backwards and not n[20:]):
152 if (overwrite and n[20:] != "u") or (backwards and not n[20:]):
154 ui.debug(_("remote deleted %s, clobbering\n") % f)
153 act("remote deleted", f, "r")
155 action.append((f, "r"))
156 else:
157 ui.debug(_("local created %s, keeping\n") % f)
158
154
159 for f, n in m2.iteritems():
155 for f, n in m2.iteritems():
160 if f in ma:
156 if f in ma:
161 if overwrite or backwards:
157 if overwrite or backwards:
162 ui.debug(_("local deleted %s, recreating\n") % f)
158 act("recreating", f, "g", m2.execf(f), n)
163 action.append((f, "g", m2.execf(f), n))
164 elif n != ma[f]:
159 elif n != ma[f]:
165 if ui.prompt(
160 if ui.prompt(
166 (_("remote changed %s which local deleted\n") % f) +
161 (_("remote changed %s which local deleted\n") % f) +
167 _("(k)eep or (d)elete?"), _("[kd]"), _("k")) == _("k"):
162 _("(k)eep or (d)elete?"), _("[kd]"), _("k")) == _("k"):
168 action.append((f, "g", m2.execf(f), n))
163 act("prompt recreating", f, "g", m2.execf(f), n)
169 else:
170 ui.debug(_("local deleted %s\n") % f)
171 else:
164 else:
172 ui.debug(_("remote created %s\n") % f)
165 act("remote created", f, "g", m2.execf(f), n)
173 action.append((f, "g", m2.execf(f), n))
174
166
175 return action
167 return action
176
168
@@ -24,7 +24,7 b' merge: warning: conflicts during merge'
24 resolving manifests
24 resolving manifests
25 overwrite None branchmerge True partial False
25 overwrite None branchmerge True partial False
26 ancestor 451c744aabcc local a070d41e8360 remote faaea63e63a9
26 ancestor 451c744aabcc local a070d41e8360 remote faaea63e63a9
27 test.txt versions differ, resolve
27 test.txt: versions differ -> m
28 merging test.txt
28 merging test.txt
29 resolving test.txt
29 resolving test.txt
30 file test.txt: my fc3148072371 other d40249267ae3 ancestor 8fe46a3eb557
30 file test.txt: my fc3148072371 other d40249267ae3 ancestor 8fe46a3eb557
@@ -17,8 +17,8 b' summary: 1'
17 resolving manifests
17 resolving manifests
18 overwrite False branchmerge False partial False
18 overwrite False branchmerge False partial False
19 ancestor 33aaa84a386b local 802f095af299 remote 33aaa84a386b
19 ancestor 33aaa84a386b local 802f095af299 remote 33aaa84a386b
20 a versions differ, resolve
20 a: versions differ -> m
21 remote created b
21 b: remote created -> g
22 merging a
22 merging a
23 resolving a
23 resolving a
24 file a: my b789fdd96dc2 other d730145abbf9 ancestor b789fdd96dc2
24 file a: my b789fdd96dc2 other d730145abbf9 ancestor b789fdd96dc2
@@ -33,7 +33,7 b' summary: 2'
33 resolving manifests
33 resolving manifests
34 overwrite False branchmerge False partial False
34 overwrite False branchmerge False partial False
35 ancestor 802f095af299 local 33aaa84a386b remote 33aaa84a386b
35 ancestor 802f095af299 local 33aaa84a386b remote 33aaa84a386b
36 remote deleted b, clobbering
36 b: remote deleted -> r
37 removing b
37 removing b
38 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
38 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
39 changeset: 0:33aaa84a386b
39 changeset: 0:33aaa84a386b
@@ -51,8 +51,8 b' summary: 1'
51 resolving manifests
51 resolving manifests
52 overwrite False branchmerge False partial False
52 overwrite False branchmerge False partial False
53 ancestor 33aaa84a386b local 802f095af299 remote 33aaa84a386b
53 ancestor 33aaa84a386b local 802f095af299 remote 33aaa84a386b
54 a versions differ, resolve
54 a: versions differ -> m
55 remote created b
55 b: remote created -> g
56 merging a
56 merging a
57 resolving a
57 resolving a
58 file a: my b789fdd96dc2 other d730145abbf9 ancestor b789fdd96dc2
58 file a: my b789fdd96dc2 other d730145abbf9 ancestor b789fdd96dc2
@@ -102,8 +102,8 b' failed'
102 resolving manifests
102 resolving manifests
103 overwrite False branchmerge True partial False
103 overwrite False branchmerge True partial False
104 ancestor 802f095af299 local 030602aee63d remote 33aaa84a386b
104 ancestor 802f095af299 local 030602aee63d remote 33aaa84a386b
105 a versions differ, resolve
105 a: versions differ -> m
106 b versions differ, resolve
106 b: versions differ -> m
107 merging a
107 merging a
108 resolving a
108 resolving a
109 file a: my d730145abbf9 other 13e0d5f949fa ancestor b789fdd96dc2
109 file a: my d730145abbf9 other 13e0d5f949fa ancestor b789fdd96dc2
@@ -42,9 +42,9 b' side2'
42 resolving manifests
42 resolving manifests
43 overwrite True branchmerge False partial False
43 overwrite True branchmerge False partial False
44 ancestor ded32b0db104 local 221226fb2bd8 remote 537353581d3d
44 ancestor ded32b0db104 local 221226fb2bd8 remote 537353581d3d
45 remote deleted side2, clobbering
45 side2: remote deleted -> r
46 remote deleted side1, clobbering
46 side1: remote deleted -> r
47 remote created main
47 main: remote created -> g
48 getting main
48 getting main
49 removing side1
49 removing side1
50 removing side2
50 removing side2
General Comments 0
You need to be logged in to leave comments. Login now