Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.py @ 23840:ddc17eaf0f1b
debugdirstate: don't hide date field with --nodate, just show 'set'/'unset'
The value of the dirstate date field cannot be used in tests and we thus have
to use debugdirstate with --nodate. It is however still very helpful to be able
to see whether the date field has been set or still is unset. The absence of
that information made it hard to debug some largefile dirstate issues.
This change _could_ make the test suite more unstable ... but that would be
places where the test suite or the code should be made more stable. (Note:
'unset' with the magic negative sizes is reliable. 'unset' for normal sizes
would probably not be reliable, but there is no such occurrences in the test
suite and it should thus be reliable.)
This output wastes more horizontal space in the --nodate output, but it also
makes things simpler that the output format always is the same. It is just a
debug command so let's keep it simple.
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Fri, 09 Jan 2015 18:38:02 +0100 |
parents | ff6b5b058fa0 |
children | 7cc77030c557 |
comparison
equal
deleted
inserted
replaced
23839:ff6b5b058fa0 | 23840:ddc17eaf0f1b |
---|---|
2885 ('', 'datesort', None, _('sort by saved mtime'))], | 2885 ('', 'datesort', None, _('sort by saved mtime'))], |
2886 _('[OPTION]...')) | 2886 _('[OPTION]...')) |
2887 def debugstate(ui, repo, nodates=None, datesort=None): | 2887 def debugstate(ui, repo, nodates=None, datesort=None): |
2888 """show the contents of the current dirstate""" | 2888 """show the contents of the current dirstate""" |
2889 timestr = "" | 2889 timestr = "" |
2890 showdate = not nodates | |
2891 if datesort: | 2890 if datesort: |
2892 keyfunc = lambda x: (x[1][3], x[0]) # sort by mtime, then by filename | 2891 keyfunc = lambda x: (x[1][3], x[0]) # sort by mtime, then by filename |
2893 else: | 2892 else: |
2894 keyfunc = None # sort by filename | 2893 keyfunc = None # sort by filename |
2895 for file_, ent in sorted(repo.dirstate._map.iteritems(), key=keyfunc): | 2894 for file_, ent in sorted(repo.dirstate._map.iteritems(), key=keyfunc): |
2896 if showdate: | 2895 if ent[3] == -1: |
2897 if ent[3] == -1: | 2896 timestr = 'unset ' |
2898 timestr = 'unset ' | 2897 elif nodates: |
2899 else: | 2898 timestr = 'set ' |
2900 timestr = time.strftime("%Y-%m-%d %H:%M:%S ", | 2899 else: |
2901 time.localtime(ent[3])) | 2900 timestr = time.strftime("%Y-%m-%d %H:%M:%S ", |
2901 time.localtime(ent[3])) | |
2902 if ent[1] & 020000: | 2902 if ent[1] & 020000: |
2903 mode = 'lnk' | 2903 mode = 'lnk' |
2904 else: | 2904 else: |
2905 mode = '%3o' % (ent[1] & 0777 & ~util.umask) | 2905 mode = '%3o' % (ent[1] & 0777 & ~util.umask) |
2906 ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_)) | 2906 ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_)) |