Patchwork D10988: dirstate-item: use the v1_serialization method in debugstate

login
register
mail settings
Submitter phabricator
Date July 5, 2021, 9:35 a.m.
Message ID <differential-rev-PHID-DREV-dwg56kf7gdijvngztp4j-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49306/
State Superseded
Headers show

Comments

phabricator - July 5, 2021, 9:35 a.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  I am assuming the debug command are looking into the serialized format so I am
  using the `v1_` variants. This assumption might be wrong.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D10988

AFFECTED FILES
  mercurial/debugcommands.py

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -954,7 +954,10 @@ 
     datesort = opts.get('datesort')
 
     if datesort:
-        keyfunc = lambda x: (x[1][3], x[0])  # sort by mtime, then by filename
+        keyfunc = lambda x: (
+            x[1].v1_mtime(),
+            x[0],
+        )  # sort by mtime, then by filename
     else:
         keyfunc = None  # sort by filename
     entries = list(pycompat.iteritems(repo.dirstate))
@@ -962,20 +965,23 @@ 
         entries.extend(repo.dirstate.directories())
     entries.sort(key=keyfunc)
     for file_, ent in entries:
-        if ent[3] == -1:
+        if ent.v1_mtime() == -1:
             timestr = b'unset               '
         elif nodates:
             timestr = b'set                 '
         else:
             timestr = time.strftime(
-                "%Y-%m-%d %H:%M:%S ", time.localtime(ent[3])
+                "%Y-%m-%d %H:%M:%S ", time.localtime(ent.v1_mtime())
             )
             timestr = encoding.strtolocal(timestr)
-        if ent[1] & 0o20000:
+        if ent.mode & 0o20000:
             mode = b'lnk'
         else:
-            mode = b'%3o' % (ent[1] & 0o777 & ~util.umask)
-        ui.write(b"%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_))
+            mode = b'%3o' % (ent.v1_mode() & 0o777 & ~util.umask)
+        ui.write(
+            b"%c %s %10d %s%s\n"
+            % (ent.v1_state(), mode, ent.v1_size(), timestr, file_)
+        )
     for f in repo.dirstate.copies():
         ui.write(_(b"copy: %s -> %s\n") % (repo.dirstate.copied(f), f))