[Commented On] D10949: dirstate-entry: turn dirstate tuple into a real object (like in C)
baymax (Baymax, Your Personal Patch-care Companion)
phabricator at mercurial-scm.org
Tue Jul 6 18:08:45 UTC 2021
baymax added a comment.
baymax updated this revision to Diff 28851.
✅ refresh by Heptapod after a successful CI run (🐙 💚)
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D10949?vs=28770&id=28851
BRANCH
default
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D10949/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D10949
AFFECTED FILES
mercurial/pure/parsers.py
CHANGE DETAILS
diff --git a/mercurial/pure/parsers.py b/mercurial/pure/parsers.py
--- a/mercurial/pure/parsers.py
+++ b/mercurial/pure/parsers.py
@@ -32,18 +32,37 @@
_compress = zlib.compress
_decompress = zlib.decompress
-# Some code below makes tuples directly because it's more convenient. However,
-# code outside this module should always use dirstatetuple.
-def dirstatetuple(*x):
- """the four items are:
+
+class dirstatetuple(object):
+ """represent a dirstate entry
+
+ It contains:
+
- state (one of 'n', 'a', 'r', 'm')
- mode,
- size,
- mtime,
"""
- # x is a tuple
- return x
+ __slot__ = ('_state', '_mode', '_size', '_mtime')
+
+ def __init__(self, state, mode, size, mtime):
+ self._state = state
+ self._mode = mode
+ self._size = size
+ self._mtime = mtime
+
+ def __getitem__(self, idx):
+ if idx == 0 or idx == -4:
+ return self._state
+ elif idx == 1 or idx == -3:
+ return self._mode
+ elif idx == 2 or idx == -2:
+ return self._size
+ elif idx == 3 or idx == -1:
+ return self._mtime
+ else:
+ raise IndexError(idx)
def gettype(q):
To: marmoute, #hg-reviewers, SimonSapin
Cc: pulkit, mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20210706/659ef2e2/attachment-0002.html>
More information about the Mercurial-patches
mailing list