Mercurial > public > mercurial-scm > hg
comparison mercurial/context.py @ 19607:056a949799ac
basefilectx: move p2 from filectx
author | Sean Farley <sean.michael.farley@gmail.com> |
---|---|
date | Sun, 11 Aug 2013 23:00:11 -0500 |
parents | 284f91230c07 |
children | 896193a9cab4 |
comparison
equal
deleted
inserted
replaced
19606:284f91230c07 | 19607:056a949799ac |
---|---|
551 for p, n, l in pl if n != nullid] | 551 for p, n, l in pl if n != nullid] |
552 | 552 |
553 def p1(self): | 553 def p1(self): |
554 return self.parents()[0] | 554 return self.parents()[0] |
555 | 555 |
556 def p2(self): | |
557 p = self.parents() | |
558 if len(p) == 2: | |
559 return p[1] | |
560 return filectx(self._repo, self._path, fileid=-1, filelog=self._filelog) | |
561 | |
556 class filectx(basefilectx): | 562 class filectx(basefilectx): |
557 """A filecontext object makes access to data related to a particular | 563 """A filecontext object makes access to data related to a particular |
558 filerevision convenient.""" | 564 filerevision convenient.""" |
559 def __init__(self, repo, path, changeid=None, fileid=None, | 565 def __init__(self, repo, path, changeid=None, fileid=None, |
560 filelog=None, changectx=None): | 566 filelog=None, changectx=None): |
635 if fnode == p.filenode(name): | 641 if fnode == p.filenode(name): |
636 return None | 642 return None |
637 except error.LookupError: | 643 except error.LookupError: |
638 pass | 644 pass |
639 return renamed | 645 return renamed |
640 | |
641 def p2(self): | |
642 p = self.parents() | |
643 if len(p) == 2: | |
644 return p[1] | |
645 return filectx(self._repo, self._path, fileid=-1, filelog=self._filelog) | |
646 | 646 |
647 def children(self): | 647 def children(self): |
648 # hard for renames | 648 # hard for renames |
649 c = self._filelog.children(self._filenode) | 649 c = self._filelog.children(self._filenode) |
650 return [filectx(self._repo, self._path, fileid=x, | 650 return [filectx(self._repo, self._path, fileid=x, |