Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.py @ 30954:dad968920130
debugcommands: move 'debugstate' in the new module
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Thu, 02 Feb 2017 10:04:34 +0100 |
parents | 5b09e9bc0902 |
children | 8e38fa360a12 |
comparison
equal
deleted
inserted
replaced
30953:5b09e9bc0902 | 30954:dad968920130 |
---|---|
9 | 9 |
10 import difflib | 10 import difflib |
11 import errno | 11 import errno |
12 import os | 12 import os |
13 import re | 13 import re |
14 import time | |
15 | 14 |
16 from .i18n import _ | 15 from .i18n import _ |
17 from .node import ( | 16 from .node import ( |
18 hex, | 17 hex, |
19 nullid, | 18 nullid, |
1853 Returns 0 on success, 1 if errors are encountered. | 1852 Returns 0 on success, 1 if errors are encountered. |
1854 """ | 1853 """ |
1855 with repo.wlock(False): | 1854 with repo.wlock(False): |
1856 return cmdutil.copy(ui, repo, pats, opts) | 1855 return cmdutil.copy(ui, repo, pats, opts) |
1857 | 1856 |
1858 @command('debugdirstate|debugstate', | |
1859 [('', 'nodates', None, _('do not display the saved mtime')), | |
1860 ('', 'datesort', None, _('sort by saved mtime'))], | |
1861 _('[OPTION]...')) | |
1862 def debugstate(ui, repo, **opts): | |
1863 """show the contents of the current dirstate""" | |
1864 | |
1865 nodates = opts.get('nodates') | |
1866 datesort = opts.get('datesort') | |
1867 | |
1868 timestr = "" | |
1869 if datesort: | |
1870 keyfunc = lambda x: (x[1][3], x[0]) # sort by mtime, then by filename | |
1871 else: | |
1872 keyfunc = None # sort by filename | |
1873 for file_, ent in sorted(repo.dirstate._map.iteritems(), key=keyfunc): | |
1874 if ent[3] == -1: | |
1875 timestr = 'unset ' | |
1876 elif nodates: | |
1877 timestr = 'set ' | |
1878 else: | |
1879 timestr = time.strftime("%Y-%m-%d %H:%M:%S ", | |
1880 time.localtime(ent[3])) | |
1881 if ent[1] & 0o20000: | |
1882 mode = 'lnk' | |
1883 else: | |
1884 mode = '%3o' % (ent[1] & 0o777 & ~util.umask) | |
1885 ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_)) | |
1886 for f in repo.dirstate.copies(): | |
1887 ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f)) | |
1888 | |
1889 @command('debugsub', | 1857 @command('debugsub', |
1890 [('r', 'rev', '', | 1858 [('r', 'rev', '', |
1891 _('revision to check'), _('REV'))], | 1859 _('revision to check'), _('REV'))], |
1892 _('[-r REV] [REV]')) | 1860 _('[-r REV] [REV]')) |
1893 def debugsub(ui, repo, rev=None): | 1861 def debugsub(ui, repo, rev=None): |