diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1340,11 +1340,15 @@ def debugsetparents(ui, repo, rev1, rev2 finally: wlock.release() -def debugstate(ui, repo, nodates=None): +def debugstate(ui, repo, nodates=None, datesort=None): """show the contents of the current dirstate""" timestr = "" showdate = not nodates - for file_, ent in sorted(repo.dirstate._map.iteritems()): + if datesort: + keyfunc = lambda x: (x[1][3], x[0]) # sort by mtime, then by filename + else: + keyfunc = None # sort by filename + for file_, ent in sorted(repo.dirstate._map.iteritems(), key=keyfunc): if showdate: if ent[3] == -1: # Pad or slice to locale representation @@ -4512,7 +4516,8 @@ table = { (debugsetparents, [], _('REV1 [REV2]')), "debugstate": (debugstate, - [('', 'nodates', None, _('do not display the saved mtime'))], + [('', 'nodates', None, _('do not display the saved mtime')), + ('', 'datesort', None, _('sort by saved mtime'))], _('[OPTION]...')), "debugsub": (debugsub, diff --git a/tests/test-debugcomplete.t b/tests/test-debugcomplete.t --- a/tests/test-debugcomplete.t +++ b/tests/test-debugcomplete.t @@ -231,7 +231,7 @@ Show all commands + options debugrename: rev debugrevspec: debugsetparents: - debugstate: nodates + debugstate: nodates, datesort debugsub: rev debugwalk: include, exclude debugwireargs: three, four, ssh, remotecmd, insecure