comparison mercurial/commands.py @ 30503:6bfb333a6f2f

debugcommands: move 'debugcheckstate' in the new module
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 17 Aug 2016 20:38:29 -0700
parents 6da030496667
children c3bdc27121d1
comparison
equal deleted inserted replaced
30502:6da030496667 30503:6bfb333a6f2f
1865 Returns 0 on success, 1 if errors are encountered. 1865 Returns 0 on success, 1 if errors are encountered.
1866 """ 1866 """
1867 with repo.wlock(False): 1867 with repo.wlock(False):
1868 return cmdutil.copy(ui, repo, pats, opts) 1868 return cmdutil.copy(ui, repo, pats, opts)
1869 1869
1870 @command('debugcheckstate', [], '')
1871 def debugcheckstate(ui, repo):
1872 """validate the correctness of the current dirstate"""
1873 parent1, parent2 = repo.dirstate.parents()
1874 m1 = repo[parent1].manifest()
1875 m2 = repo[parent2].manifest()
1876 errors = 0
1877 for f in repo.dirstate:
1878 state = repo.dirstate[f]
1879 if state in "nr" and f not in m1:
1880 ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state))
1881 errors += 1
1882 if state in "a" and f in m1:
1883 ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state))
1884 errors += 1
1885 if state in "m" and f not in m1 and f not in m2:
1886 ui.warn(_("%s in state %s, but not in either manifest\n") %
1887 (f, state))
1888 errors += 1
1889 for f in m1:
1890 state = repo.dirstate[f]
1891 if state not in "nrm":
1892 ui.warn(_("%s in manifest1, but listed as state %s") % (f, state))
1893 errors += 1
1894 if errors:
1895 error = _(".hg/dirstate inconsistent with current parent's manifest")
1896 raise error.Abort(error)
1897
1898 @command('debugcommands', [], _('[COMMAND]'), norepo=True) 1870 @command('debugcommands', [], _('[COMMAND]'), norepo=True)
1899 def debugcommands(ui, cmd='', *args): 1871 def debugcommands(ui, cmd='', *args):
1900 """list all available commands and options""" 1872 """list all available commands and options"""
1901 for cmd, vals in sorted(table.iteritems()): 1873 for cmd, vals in sorted(table.iteritems()):
1902 cmd = cmd.split('|')[0].strip('^') 1874 cmd = cmd.split('|')[0].strip('^')