##// END OF EJS Templates
merge: warn user about divergent renames
Matt Mackall -
r4674:723e0ddb default
parent child Browse files
Show More
@@ -155,11 +155,15 b' def findcopies(repo, m1, m2, ma, limit):'
155
155
156 copy = {}
156 copy = {}
157 fullcopy = {}
157 fullcopy = {}
158 diverge = {}
158
159
159 def checkcopies(c, man):
160 def checkcopies(c, man):
160 '''check possible copies for filectx c'''
161 '''check possible copies for filectx c'''
161 for of in findold(c):
162 for of in findold(c):
163 fullcopy[c.path()] = of # remember for dir rename detection
162 if of not in man: # original file not in other manifest?
164 if of not in man: # original file not in other manifest?
165 if of in ma:
166 diverge.setdefault(of, []).append(c.path())
163 continue
167 continue
164 c2 = ctx(of, man[of])
168 c2 = ctx(of, man[of])
165 ca = c.ancestor(c2)
169 ca = c.ancestor(c2)
@@ -167,17 +171,16 b' def findcopies(repo, m1, m2, ma, limit):'
167 continue
171 continue
168 # named changed on only one side?
172 # named changed on only one side?
169 if ca.path() == c.path() or ca.path() == c2.path():
173 if ca.path() == c.path() or ca.path() == c2.path():
170 fullcopy[c.path()] = of # remember for dir rename detection
171 if c == ca or c2 == ca: # no merge needed, ignore copy
174 if c == ca or c2 == ca: # no merge needed, ignore copy
172 continue
175 continue
173 copy[c.path()] = of
176 copy[c.path()] = of
174
177
175 if not repo.ui.configbool("merge", "followcopies", True):
178 if not repo.ui.configbool("merge", "followcopies", True):
176 return {}
179 return {}, {}
177
180
178 # avoid silly behavior for update from empty dir
181 # avoid silly behavior for update from empty dir
179 if not m1 or not m2 or not ma:
182 if not m1 or not m2 or not ma:
180 return {}
183 return {}, {}
181
184
182 u1 = nonoverlap(m1, m2, ma)
185 u1 = nonoverlap(m1, m2, ma)
183 u2 = nonoverlap(m2, m1, ma)
186 u2 = nonoverlap(m2, m1, ma)
@@ -188,8 +191,16 b' def findcopies(repo, m1, m2, ma, limit):'
188 for f in u2:
191 for f in u2:
189 checkcopies(ctx(f, m2[f]), m1)
192 checkcopies(ctx(f, m2[f]), m1)
190
193
194 d2 = {}
195 for of, fl in diverge.items():
196 for f in fl:
197 fo = list(fl)
198 fo.remove(f)
199 d2[f] = (of, fo)
200 #diverge = d2
201
191 if not fullcopy or not repo.ui.configbool("merge", "followdirs", True):
202 if not fullcopy or not repo.ui.configbool("merge", "followdirs", True):
192 return copy
203 return copy, diverge
193
204
194 # generate a directory move map
205 # generate a directory move map
195 d1, d2 = dirs(m1), dirs(m2)
206 d1, d2 = dirs(m1), dirs(m2)
@@ -223,7 +234,7 b' def findcopies(repo, m1, m2, ma, limit):'
223 del d1, d2, invalid
234 del d1, d2, invalid
224
235
225 if not dirmove:
236 if not dirmove:
226 return copy
237 return copy, diverge
227
238
228 # check unaccounted nonoverlapping files against directory moves
239 # check unaccounted nonoverlapping files against directory moves
229 for f in u1 + u2:
240 for f in u1 + u2:
@@ -234,7 +245,7 b' def findcopies(repo, m1, m2, ma, limit):'
234 copy[f] = dirmove[d] + f[len(d):]
245 copy[f] = dirmove[d] + f[len(d):]
235 break
246 break
236
247
237 return copy
248 return copy, diverge
238
249
239 def manifestmerge(repo, p1, p2, pa, overwrite, partial):
250 def manifestmerge(repo, p1, p2, pa, overwrite, partial):
240 """
251 """
@@ -254,6 +265,7 b' def manifestmerge(repo, p1, p2, pa, over'
254 backwards = (pa == p2)
265 backwards = (pa == p2)
255 action = []
266 action = []
256 copy = {}
267 copy = {}
268 diverge = {}
257
269
258 def fmerge(f, f2=None, fa=None):
270 def fmerge(f, f2=None, fa=None):
259 """merge flags"""
271 """merge flags"""
@@ -273,7 +285,11 b' def manifestmerge(repo, p1, p2, pa, over'
273 action.append((f, m) + args)
285 action.append((f, m) + args)
274
286
275 if not (backwards or overwrite):
287 if not (backwards or overwrite):
276 copy = findcopies(repo, m1, m2, ma, pa.rev())
288 copy, diverge = findcopies(repo, m1, m2, ma, pa.rev())
289
290 for of, fl in diverge.items():
291 act("divergent renames", "dr", of, fl)
292
277 copied = dict.fromkeys(copy.values())
293 copied = dict.fromkeys(copy.values())
278
294
279 # Compare manifests
295 # Compare manifests
@@ -410,6 +426,11 b' def applyupdates(repo, action, wctx, mct'
410 t = mctx.filectx(f2).data()
426 t = mctx.filectx(f2).data()
411 repo.wwrite(fd, t, flags)
427 repo.wwrite(fd, t, flags)
412 updated += 1
428 updated += 1
429 elif m == "dr": # divergent renames
430 fl = a[2]
431 repo.ui.warn("warning: detected divergent renames of %s to:\n" % f)
432 for nf in fl:
433 repo.ui.warn(" %s\n" % nf)
413 elif m == "e": # exec
434 elif m == "e": # exec
414 flags = a[2]
435 flags = a[2]
415 util.set_exec(repo.wjoin(f), flags)
436 util.set_exec(repo.wjoin(f), flags)
@@ -197,6 +197,9 b' checking manifests'
197 crosschecking files in changesets and manifests
197 crosschecking files in changesets and manifests
198 checking files
198 checking files
199 3 files, 7 changesets, 6 total revisions
199 3 files, 7 changesets, 6 total revisions
200 warning: detected divergent renames of afile to:
201 anotherfile
202 adifferentfile
200 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
203 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
201 (branch merge, don't forget to commit)
204 (branch merge, don't forget to commit)
202 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
205 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
@@ -4,12 +4,16 b' merge'
4 resolving manifests
4 resolving manifests
5 overwrite None partial False
5 overwrite None partial False
6 ancestor af1939970a1c local f26ec4fc3fa3+ remote 8e765a822af2
6 ancestor af1939970a1c local f26ec4fc3fa3+ remote 8e765a822af2
7 a2: divergent renames -> dr
7 a: remote moved to b -> m
8 a: remote moved to b -> m
8 b2: remote created -> g
9 b2: remote created -> g
9 merging a and b
10 merging a and b
10 my a@f26ec4fc3fa3+ other b@8e765a822af2 ancestor a@af1939970a1c
11 my a@f26ec4fc3fa3+ other b@8e765a822af2 ancestor a@af1939970a1c
11 copying a to b
12 copying a to b
12 removing a
13 removing a
14 warning: detected divergent renames of a2 to:
15 c2
16 b2
13 getting b2
17 getting b2
14 1 files updated, 1 files merged, 0 files removed, 0 files unresolved
18 1 files updated, 1 files merged, 0 files removed, 0 files unresolved
15 (branch merge, don't forget to commit)
19 (branch merge, don't forget to commit)
@@ -173,8 +173,12 b' test L:nm a b R:nm a c W: - 11 get'
173 resolving manifests
173 resolving manifests
174 overwrite None partial False
174 overwrite None partial False
175 ancestor 924404dff337 local ecf3cb2a4219+ remote e6abcc1a30c2
175 ancestor 924404dff337 local ecf3cb2a4219+ remote e6abcc1a30c2
176 a: divergent renames -> dr
176 rev: versions differ -> m
177 rev: versions differ -> m
177 c: remote created -> g
178 c: remote created -> g
179 warning: detected divergent renames of a to:
180 b
181 c
178 getting c
182 getting c
179 merging rev
183 merging rev
180 my rev@ecf3cb2a4219+ other rev@e6abcc1a30c2 ancestor rev@924404dff337
184 my rev@ecf3cb2a4219+ other rev@e6abcc1a30c2 ancestor rev@924404dff337
General Comments 0
You need to be logged in to leave comments. Login now