comparison mercurial/commands.py @ 16551:ebf6d38c9063 stable

localrepo: add setparents() to adjust dirstate copies (issue3407) The fix introduced in eab9119c5dee was only partially successful. It is correct to turn dirstate 'm' merge records into normal/dirty ones but copy records are lost in the process. To adjust them as well, we need to look in the first parent manifest to know which files were added and preserve only related records. But the dirstate does not have access to changesets, the logic has to moved at another level, in localrepo.
author Patrick Mezard <patrick@mezard.eu>
date Sun, 29 Apr 2012 22:25:55 +0200
parents db85c24dcdea
children 770190bff625
comparison
equal deleted inserted replaced
16550:0d494a38c586 16551:ebf6d38c9063
2268 r1 = scmutil.revsingle(repo, rev1).node() 2268 r1 = scmutil.revsingle(repo, rev1).node()
2269 r2 = scmutil.revsingle(repo, rev2, 'null').node() 2269 r2 = scmutil.revsingle(repo, rev2, 'null').node()
2270 2270
2271 wlock = repo.wlock() 2271 wlock = repo.wlock()
2272 try: 2272 try:
2273 repo.dirstate.setparents(r1, r2) 2273 repo.setparents(r1, r2)
2274 finally: 2274 finally:
2275 wlock.release() 2275 wlock.release()
2276 2276
2277 @command('debugstate', 2277 @command('debugstate',
2278 [('', 'nodates', None, _('do not display the saved mtime')), 2278 [('', 'nodates', None, _('do not display the saved mtime')),
2691 stats = mergemod.update(repo, ctx.node(), True, True, False, 2691 stats = mergemod.update(repo, ctx.node(), True, True, False,
2692 ctx.p1().node()) 2692 ctx.p1().node())
2693 finally: 2693 finally:
2694 ui.setconfig('ui', 'forcemerge', '') 2694 ui.setconfig('ui', 'forcemerge', '')
2695 # drop the second merge parent 2695 # drop the second merge parent
2696 repo.dirstate.setparents(current.node(), nullid) 2696 repo.setparents(current.node(), nullid)
2697 repo.dirstate.write() 2697 repo.dirstate.write()
2698 # fix up dirstate for copies and renames 2698 # fix up dirstate for copies and renames
2699 cmdutil.duplicatecopies(repo, ctx.rev(), ctx.p1().rev()) 2699 cmdutil.duplicatecopies(repo, ctx.rev(), ctx.p1().rev())
2700 # report any conflicts 2700 # report any conflicts
2701 if stats and stats[3] > 0: 2701 if stats and stats[3] > 0:
3633 n = None 3633 n = None
3634 if update: 3634 if update:
3635 if p1 != parents[0]: 3635 if p1 != parents[0]:
3636 hg.clean(repo, p1.node()) 3636 hg.clean(repo, p1.node())
3637 if p2 != parents[1]: 3637 if p2 != parents[1]:
3638 repo.dirstate.setparents(p1.node(), p2.node()) 3638 repo.setparents(p1.node(), p2.node())
3639 3639
3640 if opts.get('exact') or opts.get('import_branch'): 3640 if opts.get('exact') or opts.get('import_branch'):
3641 repo.dirstate.setbranch(branch or 'default') 3641 repo.dirstate.setbranch(branch or 'default')
3642 3642
3643 files = set() 3643 files = set()