Mercurial > public > mercurial-scm > hg
comparison mercurial/context.py @ 22916:cfa8d7561938
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.
author | Martin von Zweigbergk <martinvonz@gmail.com> |
---|---|
date | Sat, 04 Oct 2014 21:05:41 -0700 |
parents | c95db3208a33 |
children | d81792872984 |
comparison
equal
deleted
inserted
replaced
22915:4d680deb0d9e | 22916:cfa8d7561938 |
---|---|
1049 else: | 1049 else: |
1050 getman = lambda f: man | 1050 getman = lambda f: man |
1051 | 1051 |
1052 copied = self._repo.dirstate.copies() | 1052 copied = self._repo.dirstate.copies() |
1053 ff = self._flagfunc | 1053 ff = self._flagfunc |
1054 modified, added, removed, deleted = self._status[:4] | 1054 for i, l in (("a", self._status.added), ("m", self._status.modified)): |
1055 for i, l in (("a", added), ("m", modified)): | |
1056 for f in l: | 1055 for f in l: |
1057 orig = copied.get(f, f) | 1056 orig = copied.get(f, f) |
1058 man[f] = getman(orig).get(orig, nullid) + i | 1057 man[f] = getman(orig).get(orig, nullid) + i |
1059 try: | 1058 try: |
1060 man.set(f, ff(f)) | 1059 man.set(f, ff(f)) |
1061 except OSError: | 1060 except OSError: |
1062 pass | 1061 pass |
1063 | 1062 |
1064 for f in deleted + removed: | 1063 for f in self._status.deleted + self._status.removed: |
1065 if f in man: | 1064 if f in man: |
1066 del man[f] | 1065 del man[f] |
1067 | 1066 |
1068 return man | 1067 return man |
1069 | 1068 |
1087 def date(self): | 1086 def date(self): |
1088 return self._date | 1087 return self._date |
1089 def description(self): | 1088 def description(self): |
1090 return self._text | 1089 return self._text |
1091 def files(self): | 1090 def files(self): |
1092 return sorted(self._status[0] + self._status[1] + self._status[2]) | 1091 return sorted(self._status.modified + self._status.added + |
1092 self._status.removed) | |
1093 | 1093 |
1094 def modified(self): | 1094 def modified(self): |
1095 return self._status[0] | 1095 return self._status.modified |
1096 def added(self): | 1096 def added(self): |
1097 return self._status[1] | 1097 return self._status.added |
1098 def removed(self): | 1098 def removed(self): |
1099 return self._status[2] | 1099 return self._status.removed |
1100 def deleted(self): | 1100 def deleted(self): |
1101 return self._status[3] | 1101 return self._status.deleted |
1102 def unknown(self): | 1102 def unknown(self): |
1103 return self._status[4] | 1103 return self._status.unknown |
1104 def ignored(self): | 1104 def ignored(self): |
1105 return self._status[5] | 1105 return self._status.ignored |
1106 def clean(self): | 1106 def clean(self): |
1107 return self._status[6] | 1107 return self._status.clean |
1108 def branch(self): | 1108 def branch(self): |
1109 return encoding.tolocal(self._extra['branch']) | 1109 return encoding.tolocal(self._extra['branch']) |
1110 def closesbranch(self): | 1110 def closesbranch(self): |
1111 return 'close' in self._extra | 1111 return 'close' in self._extra |
1112 def extra(self): | 1112 def extra(self): |
1405 We use this poststatus hook to filter out symlinks that might have | 1405 We use this poststatus hook to filter out symlinks that might have |
1406 accidentally ended up with the entire contents of the file they are | 1406 accidentally ended up with the entire contents of the file they are |
1407 susposed to be linking to. | 1407 susposed to be linking to. |
1408 """ | 1408 """ |
1409 s[0] = self._filtersuspectsymlink(s[0]) | 1409 s[0] = self._filtersuspectsymlink(s[0]) |
1410 self._status = s[:] | 1410 self._status = scmutil.status(*s) |
1411 return s | 1411 return s |
1412 | 1412 |
1413 def _dirstatestatus(self, match=None, ignored=False, clean=False, | 1413 def _dirstatestatus(self, match=None, ignored=False, clean=False, |
1414 unknown=False): | 1414 unknown=False): |
1415 '''Gets the status from the dirstate -- internal use only.''' | 1415 '''Gets the status from the dirstate -- internal use only.''' |
1611 self._node = None | 1611 self._node = None |
1612 parents = [(p or nullid) for p in parents] | 1612 parents = [(p or nullid) for p in parents] |
1613 p1, p2 = parents | 1613 p1, p2 = parents |
1614 self._parents = [changectx(self._repo, p) for p in (p1, p2)] | 1614 self._parents = [changectx(self._repo, p) for p in (p1, p2)] |
1615 files = sorted(set(files)) | 1615 files = sorted(set(files)) |
1616 self._status = [files, [], [], [], []] | 1616 self._status = scmutil.status(files, [], [], [], [], [], []) |
1617 self._filectxfn = filectxfn | 1617 self._filectxfn = filectxfn |
1618 self.substate = {} | 1618 self.substate = {} |
1619 | 1619 |
1620 # if store is not callable, wrap it in a function | 1620 # if store is not callable, wrap it in a function |
1621 if not callable(filectxfn): | 1621 if not callable(filectxfn): |