##// END OF EJS Templates
contexts: use __getattr__ rather than try/except in changectx
Matt Mackall -
r3215:931288cf default
parent child Browse files
Show More
@@ -44,26 +44,25 b' class changectx(object):'
44 44 def __nonzero__(self):
45 45 return self._rev != -1
46 46
47 def changeset(self):
48 try:
49 return self._changeset
50 except AttributeError:
47 def __getattr__(self, name):
48 if name == '_changeset':
51 49 self._changeset = self._repo.changelog.read(self.node())
52 50 return self._changeset
53
54 def manifest(self):
55 try:
51 elif name == '_manifest':
52 self._manifest = self._repo.manifest.read(self._changeset[0])
56 53 return self._manifest
57 except AttributeError:
58 self._manifest = self._repo.manifest.read(self.changeset()[0])
59 return self._manifest
54 else:
55 raise AttributeError, name
56
57 def changeset(self): return self._changeset
58 def manifest(self): return self._manifest
60 59
61 60 def rev(self): return self._rev
62 61 def node(self): return self._node
63 def user(self): return self.changeset()[1]
64 def date(self): return self.changeset()[2]
65 def files(self): return self.changeset()[3]
66 def description(self): return self.changeset()[4]
62 def user(self): return self._changeset[1]
63 def date(self): return self._changeset[2]
64 def files(self): return self._changeset[3]
65 def description(self): return self._changeset[4]
67 66
68 67 def parents(self):
69 68 """return contexts for each parent changeset"""
@@ -76,7 +75,9 b' class changectx(object):'
76 75 return [ changectx(self._repo, x) for x in c ]
77 76
78 77 def filenode(self, path):
79 node, flag = self._repo.manifest.find(self.changeset()[0], path)
78 if hasattr(self, "_manifest"):
79 return self._manifest[path]
80 node, flag = self._repo.manifest.find(self._changeset[0], path)
80 81 return node
81 82
82 83 def filectx(self, path, fileid=None):
General Comments 0
You need to be logged in to leave comments. Login now