##// END OF EJS Templates
manifestmerge: use dicthelpers.diff and join...
Siddharth Agarwal -
r18822:381c0ef7 default
parent child Browse files
Show More
@@ -7,7 +7,7 b''
7 7
8 8 from node import nullid, nullrev, hex, bin
9 9 from i18n import _
10 import error, util, filemerge, copies, subrepo, worker
10 import error, util, filemerge, copies, subrepo, worker, dicthelpers
11 11 import errno, os, shutil
12 12
13 13 class mergestate(object):
@@ -238,17 +238,27 b' def manifestmerge(repo, wctx, p2, pa, br'
238 238
239 239 aborts, prompts = [], []
240 240 # Compare manifests
241 for f, n1 in m1.iteritems():
241 fdiff = dicthelpers.diff(m1, m2)
242 flagsdiff = m1.flagsdiff(m2)
243 diff12 = dicthelpers.join(fdiff, flagsdiff)
244
245 for f, (n12, fl12) in diff12.iteritems():
246 if n12:
247 n1, n2 = n12
248 else: # file contents didn't change, but flags did
249 n1 = n2 = m1[f]
250 if fl12:
251 fl1, fl2 = fl12
252 else: # flags didn't change, file contents did
253 fl1 = fl2 = m1.flags(f)
254
242 255 if partial and not partial(f):
243 256 continue
244 if f in m2:
245 n2 = m2[f]
246 fl1, fl2, fla = m1.flags(f), m2.flags(f), ma.flags(f)
257 if n1 and n2:
258 fla = ma.flags(f)
247 259 nol = 'l' not in fl1 + fl2 + fla
248 260 a = ma.get(f, nullid)
249 if n1 == n2 and fl1 == fl2:
250 pass # same - keep local
251 elif n2 == a and fl2 == fla:
261 if n2 == a and fl2 == fla:
252 262 pass # remote unchanged - keep local
253 263 elif n1 == a and fl1 == fla: # local unchanged - use remote
254 264 if n1 == n2: # optimization: keep local content
@@ -263,32 +273,26 b' def manifestmerge(repo, wctx, p2, pa, br'
263 273 actions.append((f, "m", (f, f, False), "versions differ"))
264 274 elif f in copied: # files we'll deal with on m2 side
265 275 pass
266 elif f in movewithdir: # directory rename
276 elif n1 and f in movewithdir: # directory rename
267 277 f2 = movewithdir[f]
268 278 actions.append((f, "d", (None, f2, m1.flags(f)),
269 279 "remote renamed directory to " + f2))
270 elif f in copy:
280 elif n1 and f in copy:
271 281 f2 = copy[f]
272 282 actions.append((f, "m", (f2, f, False),
273 283 "local copied/moved to " + f2))
274 elif f in ma: # clean, a different, no remote
284 elif n1 and f in ma: # clean, a different, no remote
275 285 if n1 != ma[f]:
276 286 prompts.append((f, "cd")) # prompt changed/deleted
277 287 elif n1[20:] == "a": # added, no remote
278 288 actions.append((f, "f", None, "remote deleted"))
279 289 else:
280 290 actions.append((f, "r", None, "other deleted"))
281
282 for f, n2 in m2.iteritems():
283 if partial and not partial(f):
284 continue
285 if f in m1 or f in copied: # files already visited
286 continue
287 if f in movewithdir:
291 elif n2 and f in movewithdir:
288 292 f2 = movewithdir[f]
289 293 actions.append((None, "d", (f, f2, m2.flags(f)),
290 294 "local renamed directory to " + f2))
291 elif f in copy:
295 elif n2 and f in copy:
292 296 f2 = copy[f]
293 297 if f2 in m2:
294 298 actions.append((f2, "m", (f, f, False),
@@ -296,7 +300,7 b' def manifestmerge(repo, wctx, p2, pa, br'
296 300 else:
297 301 actions.append((f2, "m", (f, f, True),
298 302 "remote moved to " + f))
299 elif f not in ma:
303 elif n2 and f not in ma:
300 304 # local unknown, remote created: the logic is described by the
301 305 # following table:
302 306 #
@@ -320,7 +324,7 b' def manifestmerge(repo, wctx, p2, pa, br'
320 324 aborts.append((f, "ud"))
321 325 else:
322 326 actions.append((f, "g", (m2.flags(f),), "remote created"))
323 elif n2 != ma[f]:
327 elif n2 and n2 != ma[f]:
324 328 prompts.append((f, "dc")) # prompt deleted/changed
325 329
326 330 for f, m in sorted(aborts):
General Comments 0
You need to be logged in to leave comments. Login now