comparison mercurial/commands.py @ 1755:a8f7791e3680

add 'debugrebuildstate' to rebuild the dirstate from a given revision - added and removed files will be lost while recreating the dirstate - modifications are not lost
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Mon, 20 Feb 2006 19:04:56 +0100
parents fdfe89a3962d
children 23012d48ae91 13f8e068d13c
comparison
equal deleted inserted replaced
1754:fdfe89a3962d 1755:a8f7791e3680
982 def debugancestor(ui, index, rev1, rev2): 982 def debugancestor(ui, index, rev1, rev2):
983 """find the ancestor revision of two revisions in a given index""" 983 """find the ancestor revision of two revisions in a given index"""
984 r = revlog.revlog(util.opener(os.getcwd()), index, "") 984 r = revlog.revlog(util.opener(os.getcwd()), index, "")
985 a = r.ancestor(r.lookup(rev1), r.lookup(rev2)) 985 a = r.ancestor(r.lookup(rev1), r.lookup(rev2))
986 ui.write("%d:%s\n" % (r.rev(a), hex(a))) 986 ui.write("%d:%s\n" % (r.rev(a), hex(a)))
987
988 def debugrebuildstate(ui, repo, rev=None):
989 """rebuild the dirstate as it would look like for the given revision"""
990 if not rev:
991 rev = repo.changelog.tip()
992 else:
993 rev = repo.lookup(rev)
994 change = repo.changelog.read(rev)
995 n = change[0]
996 files = repo.manifest.readflags(n)
997 wlock = self.repo.wlock()
998 repo.dirstate.rebuild(rev, files.iteritems())
987 999
988 def debugcheckstate(ui, repo): 1000 def debugcheckstate(ui, repo):
989 """validate the correctness of the current dirstate""" 1001 """validate the correctness of the current dirstate"""
990 parent1, parent2 = repo.dirstate.parents() 1002 parent1, parent2 = repo.dirstate.parents()
991 repo.dirstate.read() 1003 repo.dirstate.read()
2357 ('A', 'after', None, _('record a copy that has already occurred')), 2369 ('A', 'after', None, _('record a copy that has already occurred')),
2358 ('f', 'force', None, 2370 ('f', 'force', None,
2359 _('forcibly copy over an existing managed file'))], 2371 _('forcibly copy over an existing managed file'))],
2360 _('hg copy [OPTION]... [SOURCE]... DEST')), 2372 _('hg copy [OPTION]... [SOURCE]... DEST')),
2361 "debugancestor": (debugancestor, [], _('debugancestor INDEX REV1 REV2')), 2373 "debugancestor": (debugancestor, [], _('debugancestor INDEX REV1 REV2')),
2374 "debugrebuildstate":
2375 (debugrebuildstate,
2376 [('r', 'rev', "", _("revision to rebuild to"))],
2377 _('debugrebuildstate [-r REV] [REV]')),
2362 "debugcheckstate": (debugcheckstate, [], _('debugcheckstate')), 2378 "debugcheckstate": (debugcheckstate, [], _('debugcheckstate')),
2363 "debugconfig": (debugconfig, [], _('debugconfig')), 2379 "debugconfig": (debugconfig, [], _('debugconfig')),
2364 "debugsetparents": (debugsetparents, [], _('debugsetparents REV1 [REV2]')), 2380 "debugsetparents": (debugsetparents, [], _('debugsetparents REV1 [REV2]')),
2365 "debugstate": (debugstate, [], _('debugstate')), 2381 "debugstate": (debugstate, [], _('debugstate')),
2366 "debugdata": (debugdata, [], _('debugdata FILE REV')), 2382 "debugdata": (debugdata, [], _('debugdata FILE REV')),