changeset 6296:a9e6b8875805

debugstate: add --nodates This can be useful for tests.
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Tue, 18 Mar 2008 04:07:39 -0300
parents bace1990ab12
children fed1a9c22076
files mercurial/commands.py tests/test-filebranch tests/test-rebuildstate
diffstat 3 files changed, 20 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Mon Mar 17 23:36:45 2008 +0100
+++ b/mercurial/commands.py	Tue Mar 18 04:07:39 2008 -0300
@@ -697,23 +697,26 @@
     finally:
         del wlock
 
-def debugstate(ui, repo):
+def debugstate(ui, repo, nodates=None):
     """show the contents of the current dirstate"""
     k = repo.dirstate._map.items()
     k.sort()
+    timestr = ""
+    showdate = not nodates
     for file_, ent in k:
-        if ent[3] == -1:
-            # Pad or slice to locale representation
-            locale_len = len(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(0)))
-            timestr = 'unset'
-            timestr = timestr[:locale_len] + ' '*(locale_len - len(timestr))
-        else:
-            timestr = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(ent[3]))
+        if showdate:
+            if ent[3] == -1:
+                # Pad or slice to locale representation
+                locale_len = len(time.strftime("%Y-%m-%d %H:%M:%S ", time.localtime(0)))
+                timestr = 'unset'
+                timestr = timestr[:locale_len] + ' '*(locale_len - len(timestr))
+            else:
+                timestr = time.strftime("%Y-%m-%d %H:%M:%S ", time.localtime(ent[3]))
         if ent[1] & 020000:
             mode = 'lnk'
         else:
             mode = '%3o' % (ent[1] & 0777)
-        ui.write("%c %s %10d %s %s\n" % (ent[0], mode, ent[2], timestr, file_))
+        ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_))
     for f in repo.dirstate.copies():
         ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f))
 
@@ -2944,7 +2947,10 @@
         (debugsetparents,
          [],
          _('hg debugsetparents REV1 [REV2]')),
-    "debugstate": (debugstate, [], _('hg debugstate')),
+    "debugstate":
+        (debugstate,
+         [('', 'nodates', None, _('do not display the saved mtime'))],
+         _('hg debugstate [OPTS]')),
     "debugwalk": (debugwalk, walkopts, _('hg debugwalk [OPTION]... [FILE]...')),
     "^diff":
         (diff,
--- a/tests/test-filebranch	Mon Mar 17 23:36:45 2008 +0100
+++ b/tests/test-filebranch	Tue Mar 18 04:07:39 2008 -0300
@@ -37,7 +37,7 @@
 hg commit -m "branch b" -d "1000000 0"
 
 echo "we shouldn't have anything but n state here"
-hg debugstate | cut -b 1-16,37-
+hg debugstate --nodates
 
 echo merging
 hg pull ../a
@@ -48,7 +48,7 @@
 echo new > quux
 
 echo "we shouldn't have anything but foo in merge state here"
-hg debugstate | cut -b 1-16,37- | grep "^m"
+hg debugstate --nodates | grep "^m"
 
 hg ci -m "merge" -d "1000000 0"
 
--- a/tests/test-rebuildstate	Mon Mar 17 23:36:45 2008 +0100
+++ b/tests/test-rebuildstate	Tue Mar 18 04:07:39 2008 -0300
@@ -12,13 +12,13 @@
 hg rm bar
 
 echo '% state dump'
-hg debugstate | cut -b 1-16,37- | sort
+hg debugstate --nodates | sort
 echo '% status'
 hg st -A
 
 hg debugrebuildstate
 echo '% state dump'
-hg debugstate | cut -b 1-16,37- | sort
+hg debugstate --nodates | sort
 echo '% status'
 hg st -A