Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/context.py @ 8157:77c5877a668c
context: use Python 2.4 decorator syntax
author | Martin Geisler <mg@lazybytes.net> |
---|---|
date | Fri, 24 Apr 2009 18:47:15 +0200 |
parents | 127281884959 |
children | dd8d5be57d65 |
comparison
equal
deleted
inserted
replaced
8156:9fd0822c2ec3 | 8157:77c5877a668c |
---|---|
58 return not (self == other) | 58 return not (self == other) |
59 | 59 |
60 def __nonzero__(self): | 60 def __nonzero__(self): |
61 return self._rev != nullrev | 61 return self._rev != nullrev |
62 | 62 |
63 @propertycache | |
63 def _changeset(self): | 64 def _changeset(self): |
64 return self._repo.changelog.read(self.node()) | 65 return self._repo.changelog.read(self.node()) |
65 _changeset = propertycache(_changeset) | 66 |
66 | 67 @propertycache |
67 def _manifest(self): | 68 def _manifest(self): |
68 return self._repo.manifest.read(self._changeset[0]) | 69 return self._repo.manifest.read(self._changeset[0]) |
69 _manifest = propertycache(_manifest) | 70 |
70 | 71 @propertycache |
71 def _manifestdelta(self): | 72 def _manifestdelta(self): |
72 return self._repo.manifest.readdelta(self._changeset[0]) | 73 return self._repo.manifest.readdelta(self._changeset[0]) |
73 _manifestdelta = propertycache(_manifestdelta) | 74 |
74 | 75 @propertycache |
75 def _parents(self): | 76 def _parents(self): |
76 p = self._repo.changelog.parentrevs(self._rev) | 77 p = self._repo.changelog.parentrevs(self._rev) |
77 if p[1] == nullrev: | 78 if p[1] == nullrev: |
78 p = p[:-1] | 79 p = p[:-1] |
79 return [changectx(self._repo, x) for x in p] | 80 return [changectx(self._repo, x) for x in p] |
80 _parents = propertycache(_parents) | |
81 | 81 |
82 def __contains__(self, key): | 82 def __contains__(self, key): |
83 return key in self._manifest | 83 return key in self._manifest |
84 | 84 |
85 def __getitem__(self, key): | 85 def __getitem__(self, key): |
199 if changectx is not None: | 199 if changectx is not None: |
200 self._changectx = changectx | 200 self._changectx = changectx |
201 if fileid is not None: | 201 if fileid is not None: |
202 self._fileid = fileid | 202 self._fileid = fileid |
203 | 203 |
204 @propertycache | |
204 def _changectx(self): | 205 def _changectx(self): |
205 return changectx(self._repo, self._changeid) | 206 return changectx(self._repo, self._changeid) |
206 _changectx = propertycache(_changectx) | 207 |
207 | 208 @propertycache |
208 def _filelog(self): | 209 def _filelog(self): |
209 return self._repo.file(self._path) | 210 return self._repo.file(self._path) |
210 _filelog = propertycache(_filelog) | 211 |
211 | 212 @propertycache |
212 def _changeid(self): | 213 def _changeid(self): |
213 if '_changectx' in self.__dict__: | 214 if '_changectx' in self.__dict__: |
214 return self._changectx.rev() | 215 return self._changectx.rev() |
215 else: | 216 else: |
216 return self._filelog.linkrev(self._filerev) | 217 return self._filelog.linkrev(self._filerev) |
217 _changeid = propertycache(_changeid) | 218 |
218 | 219 @propertycache |
219 def _filenode(self): | 220 def _filenode(self): |
220 if '_fileid' in self.__dict__: | 221 if '_fileid' in self.__dict__: |
221 return self._filelog.lookup(self._fileid) | 222 return self._filelog.lookup(self._fileid) |
222 else: | 223 else: |
223 return self._changectx.filenode(self._path) | 224 return self._changectx.filenode(self._path) |
224 _filenode = propertycache(_filenode) | 225 |
225 | 226 @propertycache |
226 def _filerev(self): | 227 def _filerev(self): |
227 return self._filelog.rev(self._filenode) | 228 return self._filelog.rev(self._filenode) |
228 _filerev = propertycache(_filerev) | 229 |
229 | 230 @propertycache |
230 def _repopath(self): | 231 def _repopath(self): |
231 return self._path | 232 return self._path |
232 _repopath = propertycache(_repopath) | |
233 | 233 |
234 def __nonzero__(self): | 234 def __nonzero__(self): |
235 try: | 235 try: |
236 self._filenode | 236 self._filenode |
237 return True | 237 return True |
513 return True | 513 return True |
514 | 514 |
515 def __contains__(self, key): | 515 def __contains__(self, key): |
516 return self._repo.dirstate[key] not in "?r" | 516 return self._repo.dirstate[key] not in "?r" |
517 | 517 |
518 @propertycache | |
518 def _manifest(self): | 519 def _manifest(self): |
519 """generate a manifest corresponding to the working directory""" | 520 """generate a manifest corresponding to the working directory""" |
520 | 521 |
521 man = self._parents[0].manifest().copy() | 522 man = self._parents[0].manifest().copy() |
522 copied = self._repo.dirstate.copies() | 523 copied = self._repo.dirstate.copies() |
534 for f in deleted + removed: | 535 for f in deleted + removed: |
535 if f in man: | 536 if f in man: |
536 del man[f] | 537 del man[f] |
537 | 538 |
538 return man | 539 return man |
539 _manifest = propertycache(_manifest) | 540 |
540 | 541 @propertycache |
541 def _status(self): | 542 def _status(self): |
542 return self._repo.status(unknown=True) | 543 return self._repo.status(unknown=True) |
543 _status = propertycache(_status) | 544 |
544 | 545 @propertycache |
545 def _user(self): | 546 def _user(self): |
546 return self._repo.ui.username() | 547 return self._repo.ui.username() |
547 _user = propertycache(_user) | 548 |
548 | 549 @propertycache |
549 def _date(self): | 550 def _date(self): |
550 return util.makedate() | 551 return util.makedate() |
551 _date = propertycache(_date) | 552 |
552 | 553 @propertycache |
553 def _parents(self): | 554 def _parents(self): |
554 p = self._repo.dirstate.parents() | 555 p = self._repo.dirstate.parents() |
555 if p[1] == nullid: | 556 if p[1] == nullid: |
556 p = p[:-1] | 557 p = p[:-1] |
557 self._parents = [changectx(self._repo, x) for x in p] | 558 self._parents = [changectx(self._repo, x) for x in p] |
558 return self._parents | 559 return self._parents |
559 _parents = propertycache(_parents) | |
560 | 560 |
561 def manifest(self): return self._manifest | 561 def manifest(self): return self._manifest |
562 | 562 |
563 def user(self): return self._user or self._repo.ui.username() | 563 def user(self): return self._user or self._repo.ui.username() |
564 def date(self): return self._date | 564 def date(self): return self._date |
629 if filelog: | 629 if filelog: |
630 self._filelog = filelog | 630 self._filelog = filelog |
631 if workingctx: | 631 if workingctx: |
632 self._changectx = workingctx | 632 self._changectx = workingctx |
633 | 633 |
634 @propertycache | |
634 def _changectx(self): | 635 def _changectx(self): |
635 return workingctx(self._repo) | 636 return workingctx(self._repo) |
636 _changectx = propertycache(_changectx) | 637 |
637 | 638 @propertycache |
638 def _repopath(self): | 639 def _repopath(self): |
639 return self._repo.dirstate.copied(self._path) or self._path | 640 return self._repo.dirstate.copied(self._path) or self._path |
640 _repopath = propertycache(_repopath) | 641 |
641 | 642 @propertycache |
642 def _filelog(self): | 643 def _filelog(self): |
643 return self._repo.file(self._repopath) | 644 return self._repo.file(self._repopath) |
644 _filelog = propertycache(_filelog) | |
645 | 645 |
646 def __nonzero__(self): | 646 def __nonzero__(self): |
647 return True | 647 return True |
648 | 648 |
649 def __str__(self): | 649 def __str__(self): |