comparison mercurial/context.py @ 20984:f4a87d1ee1aa

context: remove unused filectx.ancestor
author Mads Kiilerich <madski@unity3d.com>
date Mon, 07 Apr 2014 23:17:48 +0200
parents f0137d994c83
children a63958bcf63a
comparison
equal deleted inserted replaced
20983:2778616de7ce 20984:f4a87d1ee1aa
5 # This software may be used and distributed according to the terms of the 5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version. 6 # GNU General Public License version 2 or any later version.
7 7
8 from node import nullid, nullrev, short, hex, bin 8 from node import nullid, nullrev, short, hex, bin
9 from i18n import _ 9 from i18n import _
10 import ancestor, mdiff, error, util, scmutil, subrepo, patch, encoding, phases 10 import mdiff, error, util, scmutil, subrepo, patch, encoding, phases
11 import match as matchmod 11 import match as matchmod
12 import os, errno, stat 12 import os, errno, stat
13 import obsolete as obsmod 13 import obsolete as obsmod
14 import repoview 14 import repoview
15 import fileset 15 import fileset
686 hist[f] = curr 686 hist[f] = curr
687 pcache[f] = [] 687 pcache[f] = []
688 688
689 return zip(hist[base][0], hist[base][1].splitlines(True)) 689 return zip(hist[base][0], hist[base][1].splitlines(True))
690 690
691 def ancestor(self, fc2, actx):
692 """
693 find the common ancestor file context, if any, of self, and fc2
694
695 actx must be the changectx of the common ancestor
696 of self's and fc2's respective changesets.
697 """
698
699 # the easy case: no (relevant) renames
700 if fc2.path() == self.path() and self.path() in actx:
701 return actx[self.path()]
702
703 # the next easiest cases: unambiguous predecessor (name trumps
704 # history)
705 if self.path() in actx and fc2.path() not in actx:
706 return actx[self.path()]
707 if fc2.path() in actx and self.path() not in actx:
708 return actx[fc2.path()]
709
710 # prime the ancestor cache for the working directory
711 acache = {}
712 for c in (self, fc2):
713 if c.filenode() is None:
714 pl = [(n.path(), n.filenode()) for n in c.parents()]
715 acache[(c._path, None)] = pl
716
717 flcache = {self._repopath:self._filelog, fc2._repopath:fc2._filelog}
718 def parents(vertex):
719 if vertex in acache:
720 return acache[vertex]
721 f, n = vertex
722 if f not in flcache:
723 flcache[f] = self._repo.file(f)
724 fl = flcache[f]
725 pl = [(f, p) for p in fl.parents(n) if p != nullid]
726 re = fl.renamed(n)
727 if re:
728 pl.append(re)
729 acache[vertex] = pl
730 return pl
731
732 a, b = (self._path, self._filenode), (fc2._path, fc2._filenode)
733 v = ancestor.genericancestor(a, b, parents)
734 if v:
735 f, n = v
736 return filectx(self._repo, f, fileid=n, filelog=flcache[f])
737
738 return None
739
740 def ancestors(self, followfirst=False): 691 def ancestors(self, followfirst=False):
741 visit = {} 692 visit = {}
742 c = self 693 c = self
743 cut = followfirst and 1 or None 694 cut = followfirst and 1 or None
744 while True: 695 while True: