comparison mercurial/commands.py @ 15511:6cae68a361ed stable

import: fix parent selection when importing merges With "wp1" and "wp2" the current working directory parents, "p1" and "p2" the patch parents and "parents" the resulting commit parents, the current behaviour is: --bypass --exact p2 parents 0 0 0 [wp1, wp2] 0 0 1 [wp1, wp2]/buggy 0 1 0 [p1] 0 1 1 [p1, p2] 1 0 0 [wp1, wp2] 1 0 1 [p1, p2] 1 1 0 [p1] 1 1 1 [p1, p2] The original behaviour before f53dc0787424 was: --bypass --exact p2 parents 0 0 0 [wp1, wp2] 0 0 1 if p1 == wp1 then [p1, p2] otherwise [wp1, wp2] 0 1 0 [p1] 0 1 1 [p1, p2] This patch restores the previous behaviour when --bypass is not set, and align --bypass behaviour when --exact is not set with merge diffs.
author Patrick Mezard <pmezard@gmail.com>
date Wed, 16 Nov 2011 12:53:10 +0100
parents 00276525e2b7
children 646759147717 09b200396384
comparison
equal deleted inserted replaced
15509:3774e1453ef4 15511:6cae68a361ed
3508 p2 = repo[p2 or nullid] 3508 p2 = repo[p2 or nullid]
3509 elif p2: 3509 elif p2:
3510 try: 3510 try:
3511 p1 = repo[p1] 3511 p1 = repo[p1]
3512 p2 = repo[p2] 3512 p2 = repo[p2]
3513 # Without any options, consider p2 only if the
3514 # patch is being applied on top of the recorded
3515 # first parent.
3516 if p1 != parents[0]:
3517 p1 = parents[0]
3518 p2 = repo[nullid]
3513 except error.RepoError: 3519 except error.RepoError:
3514 p1, p2 = parents 3520 p1, p2 = parents
3515 else: 3521 else:
3516 p1, p2 = parents 3522 p1, p2 = parents
3517 3523
3518 n = None 3524 n = None
3519 if update: 3525 if update:
3520 if opts.get('exact') and p1 != parents[0]: 3526 if p1 != parents[0]:
3521 hg.clean(repo, p1.node()) 3527 hg.clean(repo, p1.node())
3522 if p1 != parents[0] and p2 != parents[1]: 3528 if p2 != parents[1]:
3523 repo.dirstate.setparents(p1.node(), p2.node()) 3529 repo.dirstate.setparents(p1.node(), p2.node())
3524 3530
3525 if opts.get('exact') or opts.get('import_branch'): 3531 if opts.get('exact') or opts.get('import_branch'):
3526 repo.dirstate.setbranch(branch or 'default') 3532 repo.dirstate.setbranch(branch or 'default')
3527 3533
3531 files = list(files) 3537 files = list(files)
3532 if opts.get('no_commit'): 3538 if opts.get('no_commit'):
3533 if message: 3539 if message:
3534 msgs.append(message) 3540 msgs.append(message)
3535 else: 3541 else:
3536 if opts.get('exact'): 3542 if opts.get('exact') or p2:
3543 # If you got here, you either use --force and know what
3544 # you are doing or used --exact or a merge patch while
3545 # being updated to its first parent.
3537 m = None 3546 m = None
3538 else: 3547 else:
3539 m = scmutil.matchfiles(repo, files or []) 3548 m = scmutil.matchfiles(repo, files or [])
3540 n = repo.commit(message, opts.get('user') or user, 3549 n = repo.commit(message, opts.get('user') or user,
3541 opts.get('date') or date, match=m, 3550 opts.get('date') or date, match=m,