Patchwork [05,of,17,V4] context: store status class instead of plain tuple in self._status

login
register
mail settings
Submitter Martin von Zweigbergk
Date Oct. 12, 2014, 5:44 a.m.
Message ID <853d838b996c74be6533.1413092662@handduk2.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/6222/
State Accepted
Headers show

Comments

Martin von Zweigbergk - Oct. 12, 2014, 5:44 a.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@gmail.com>
# Date 1412481941 25200
#      Sat Oct 04 21:05:41 2014 -0700
# Node ID 853d838b996c74be6533003027c3a6e17eb52571
# Parent  ba0e941771480511e8dee5b5c3c303f8de668ecc
context: store status class instead of plain tuple in self._status

This improves readability a bit by allowing us to refer to statuses by
name rather than index.

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -1051,8 +1051,7 @@ 
 
         copied = self._repo.dirstate.copies()
         ff = self._flagfunc
-        modified, added, removed, deleted = self._status[:4]
-        for i, l in (("a", added), ("m", modified)):
+        for i, l in (("a", self._status.added), ("m", self._status.modified)):
             for f in l:
                 orig = copied.get(f, f)
                 man[f] = getman(orig).get(orig, nullid) + i
@@ -1061,7 +1060,7 @@ 
                 except OSError:
                     pass
 
-        for f in deleted + removed:
+        for f in self._status.deleted + self._status.removed:
             if f in man:
                 del man[f]
 
@@ -1089,22 +1088,23 @@ 
     def description(self):
         return self._text
     def files(self):
-        return sorted(self._status[0] + self._status[1] + self._status[2])
+        return sorted(self._status.modified + self._status.added +
+                      self._status.removed)
 
     def modified(self):
-        return self._status[0]
+        return self._status.modified
     def added(self):
-        return self._status[1]
+        return self._status.added
     def removed(self):
-        return self._status[2]
+        return self._status.removed
     def deleted(self):
-        return self._status[3]
+        return self._status.deleted
     def unknown(self):
-        return self._status[4]
+        return self._status.unknown
     def ignored(self):
-        return self._status[5]
+        return self._status.ignored
     def clean(self):
-        return self._status[6]
+        return self._status.clean
     def branch(self):
         return encoding.tolocal(self._extra['branch'])
     def closesbranch(self):
@@ -1407,7 +1407,7 @@ 
         susposed to be linking to.
         """
         s[0] = self._filtersuspectsymlink(s[0])
-        self._status = s[:]
+        self._status = dirstate.status(*s)
         return s
 
     def _dirstatestatus(self, match=None, ignored=False, clean=False,
@@ -1613,7 +1613,7 @@ 
         p1, p2 = parents
         self._parents = [changectx(self._repo, p) for p in (p1, p2)]
         files = sorted(set(files))
-        self._status = [files, [], [], [], []]
+        self._status = dirstate.status(files, [], [], [], [], [], [])
         self._filectxfn = filectxfn
         self.substate = {}