mercurial/commands.py
changeset 460 6409d9a0df43
parent 452 a1e91c24dab5
child 461 9ae0034f2772
equal deleted inserted replaced
459:7c1952b29656 460:6409d9a0df43
   273 
   273 
   274 def copy(ui, repo, source, dest):
   274 def copy(ui, repo, source, dest):
   275     """mark a file as copied or renamed for the next commit"""
   275     """mark a file as copied or renamed for the next commit"""
   276     return repo.copy(*relpath(repo, (source, dest)))
   276     return repo.copy(*relpath(repo, (source, dest)))
   277 
   277 
       
   278 def debugcheckdirstate(ui, repo):
       
   279     parent1, parent2 = repo.dirstate.parents()
       
   280     dc = repo.dirstate.dup()
       
   281     keys = dc.keys()
       
   282     keys.sort()
       
   283     m1n = repo.changelog.read(parent1)[0]
       
   284     m2n = repo.changelog.read(parent2)[0]
       
   285     m1 = repo.manifest.read(m1n)
       
   286     m2 = repo.manifest.read(m2n)
       
   287     errors = 0
       
   288     for f in dc:
       
   289         state = repo.dirstate.state(f)
       
   290         if state in "nr" and f not in m1:
       
   291             print "%s in state %s, but not listed in manifest1" % (f, state)
       
   292             errors += 1
       
   293         if state in "a" and f in m1:
       
   294             print "%s in state %s, but also listed in manifest1" % (f, state)
       
   295             errors += 1
       
   296         if state in "m" and f not in m1 and f not in m2:
       
   297             print "%s in state %s, but not listed in either manifest" % (f, state)
       
   298             errors += 1
       
   299     for f in m1:
       
   300         state = repo.dirstate.state(f)
       
   301         if state not in "nrm":
       
   302             print "%s in manifest1, but listed as state %s" % (f, state)
       
   303             errors += 1
       
   304     if errors:
       
   305         print ".hg/dirstate inconsistent with current parent's manifest, aborting"
       
   306         sys.exit(1)
       
   307 
       
   308 def debugdumpdirstate(ui, repo):
       
   309     dc = repo.dirstate.dup()
       
   310     keys = dc.keys()
       
   311     keys.sort()
       
   312     for file in keys:
       
   313         print "%s => %c" % (file, dc[file][0])
       
   314 
   278 def debugindex(ui, file):
   315 def debugindex(ui, file):
   279     r = hg.revlog(hg.opener(""), file, "")
   316     r = hg.revlog(hg.opener(""), file, "")
   280     print "   rev    offset  length   base linkrev"+\
   317     print "   rev    offset  length   base linkrev"+\
   281           " p1           p2           nodeid"
   318           " p1           p2           nodeid"
   282     for i in range(r.count()):
   319     for i in range(r.count()):
   675                    ('l', 'logfile', "", 'commit text file'),
   712                    ('l', 'logfile', "", 'commit text file'),
   676                    ('d', 'date', "", 'data'),
   713                    ('d', 'date', "", 'data'),
   677                    ('u', 'user', "", 'user')],
   714                    ('u', 'user', "", 'user')],
   678                   'hg commit [files]'),
   715                   'hg commit [files]'),
   679     "copy": (copy, [], 'hg copy <source> <dest>'),
   716     "copy": (copy, [], 'hg copy <source> <dest>'),
       
   717     "debugcheckdirstate": (debugcheckdirstate, [], 'debugcheckdirstate'),
       
   718     "debugdumpdirstate": (debugdumpdirstate, [], 'debugdumpdirstate'),
   680     "debugindex": (debugindex, [], 'debugindex <file>'),
   719     "debugindex": (debugindex, [], 'debugindex <file>'),
   681     "debugindexdot": (debugindexdot, [], 'debugindexdot <file>'),
   720     "debugindexdot": (debugindexdot, [], 'debugindexdot <file>'),
   682     "diff": (diff, [('r', 'rev', [], 'revision')],
   721     "diff": (diff, [('r', 'rev', [], 'revision')],
   683              'hg diff [-r A] [-r B] [files]'),
   722              'hg diff [-r A] [-r B] [files]'),
   684     "export": (export, [], "hg export <changeset>"),
   723     "export": (export, [], "hg export <changeset>"),