comparison mercurial/merge.py @ 23396:6a254a2dd37c

merge: separate out "both created" cases When 'f' is not in 'ma', 'a' will be 'nullid' and all the if/elif conditions that check whether some one nodeid is equal to 'a' will fail, and the else-clause will instead apply. We can make that more explicit by creating a separate 'm' action for the case where 'a' is 'nullid'. While it does mean copying some code, perhaps it makes it a little clearer which codepaths are possible, and which cases the "Note:" in the code refers to. It also lets us make the debug action messages a little more specific.
author Martin von Zweigbergk <martinvonz@google.com>
date Mon, 24 Nov 2014 16:16:34 -0800
parents d9ebb475eede
children c7c95838be9a
comparison
equal deleted inserted replaced
23395:d9ebb475eede 23396:6a254a2dd37c
413 413
414 for f, ((n1, fl1), (n2, fl2)) in diff.iteritems(): 414 for f, ((n1, fl1), (n2, fl2)) in diff.iteritems():
415 if partial and not partial(f): 415 if partial and not partial(f):
416 continue 416 continue
417 if n1 and n2: 417 if n1 and n2:
418 if True: 418 if f not in ma:
419 fa = f 419 # Note: f as ancestor is wrong - we can't really make a 3-way
420 a = ma.get(f, nullid) 420 # merge without an ancestor file.
421 if a == nullid: 421 fa = copy.get(f, f)
422 fa = copy.get(f, f) 422 actions['m'].append((f, (f, f, fa, False, pa.node()),
423 # Note: f as default is wrong - we can't really make a 3-way 423 "both created"))
424 # merge without an ancestor file. 424 else:
425 fla = ma.flags(fa) 425 a = ma[f]
426 fla = ma.flags(f)
426 nol = 'l' not in fl1 + fl2 + fla 427 nol = 'l' not in fl1 + fl2 + fla
427 if n2 == a and fl2 == fla: 428 if n2 == a and fl2 == fla:
428 actions['k'].append((f, (), "keep")) # remote unchanged 429 actions['k'].append((f, (), "keep")) # remote unchanged
429 elif n1 == a and fl1 == fla: # local unchanged - use remote 430 elif n1 == a and fl1 == fla: # local unchanged - use remote
430 if n1 == n2: # optimization: keep local content 431 if n1 == n2: # optimization: keep local content
434 elif nol and n2 == a: # remote only changed 'x' 435 elif nol and n2 == a: # remote only changed 'x'
435 actions['e'].append((f, (fl2,), "update permissions")) 436 actions['e'].append((f, (fl2,), "update permissions"))
436 elif nol and n1 == a: # local only changed 'x' 437 elif nol and n1 == a: # local only changed 'x'
437 actions['g'].append((f, (fl1,), "remote is newer")) 438 actions['g'].append((f, (fl1,), "remote is newer"))
438 else: # both changed something 439 else: # both changed something
439 actions['m'].append((f, (f, f, fa, False, pa.node()), 440 actions['m'].append((f, (f, f, f, False, pa.node()),
440 "versions differ")) 441 "versions differ"))
441 elif f in copied: # files we'll deal with on m2 side 442 elif f in copied: # files we'll deal with on m2 side
442 pass 443 pass
443 elif n1 and f in movewithdir: # directory rename, move local 444 elif n1 and f in movewithdir: # directory rename, move local
444 f2 = movewithdir[f] 445 f2 = movewithdir[f]