コード例 #1
0
ファイル: context.py プロジェクト: carlgao/lenga
    def ancestor(self, fc2):
        """
        find the common ancestor file context, if any, of self, and fc2
        """

        acache = {}

        # prime the ancestor cache for the working directory
        for c in (self, fc2):
            if c._filerev == None:
                pl = [(n.path(), n.filenode()) for n in c.parents()]
                acache[(c._path, None)] = pl

        flcache = {self._repopath:self._filelog, fc2._repopath:fc2._filelog}
        def parents(vertex):
            if vertex in acache:
                return acache[vertex]
            f, n = vertex
            if f not in flcache:
                flcache[f] = self._repo.file(f)
            fl = flcache[f]
            pl = [(f, p) for p in fl.parents(n) if p != nullid]
            re = fl.renamed(n)
            if re:
                pl.append(re)
            acache[vertex] = pl
            return pl

        a, b = (self._path, self._filenode), (fc2._path, fc2._filenode)
        v = ancestor.ancestor(a, b, parents)
        if v:
            f, n = v
            return filectx(self._repo, f, fileid=n, filelog=flcache[f])

        return None
コード例 #2
0
ファイル: revlog.py プロジェクト: saminigod/cygwin
    def ancestor(self, a, b):
        """calculate the least common ancestor of nodes a and b"""
        def parents(rev):
            return [p for p in self.parentrevs(rev) if p != nullrev]

        c = ancestor.ancestor(self.rev(a), self.rev(b), parents)
        if c is None:
            return nullid

        return self.node(c)
コード例 #3
0
ファイル: revlog.py プロジェクト: pombredanne/SmartNotes
    def ancestor(self, a, b):
        """calculate the least common ancestor of nodes a and b"""

        def parents(rev):
            return [p for p in self.parentrevs(rev) if p != nullrev]

        c = ancestor.ancestor(self.rev(a), self.rev(b), parents)
        if c is None:
            return nullid

        return self.node(c)
コード例 #4
0
    def ancestor(self, fc2, actx=None):
        """
        find the common ancestor file context, if any, of self, and fc2

        If actx is given, it must be the changectx of the common ancestor
        of self's and fc2's respective changesets.
        """

        if actx is None:
            actx = self.changectx().ancestor(fc2.changectx())

        # the trivial case: changesets are unrelated, files must be too
        if not actx:
            return None

        # the easy case: no (relevant) renames
        if fc2.path() == self.path() and self.path() in actx:
            return actx[self.path()]
        acache = {}

        # prime the ancestor cache for the working directory
        for c in (self, fc2):
            if c._filerev is None:
                pl = [(n.path(), n.filenode()) for n in c.parents()]
                acache[(c._path, None)] = pl

        flcache = {self._repopath: self._filelog, fc2._repopath: fc2._filelog}

        def parents(vertex):
            if vertex in acache:
                return acache[vertex]
            f, n = vertex
            if f not in flcache:
                flcache[f] = self._repo.file(f)
            fl = flcache[f]
            pl = [(f, p) for p in fl.parents(n) if p != nullid]
            re = fl.renamed(n)
            if re:
                pl.append(re)
            acache[vertex] = pl
            return pl

        a, b = (self._path, self._filenode), (fc2._path, fc2._filenode)
        v = ancestor.ancestor(a, b, parents)
        if v:
            f, n = v
            return filectx(self._repo, f, fileid=n, filelog=flcache[f])

        return None
コード例 #5
0
    def ancestor(self, fc2, actx=None):
        """
        find the common ancestor file context, if any, of self, and fc2

        If actx is given, it must be the changectx of the common ancestor
        of self's and fc2's respective changesets.
        """

        if actx is None:
            actx = self.changectx().ancestor(fc2.changectx())

        # the trivial case: changesets are unrelated, files must be too
        if not actx:
            return None

        # the easy case: no (relevant) renames
        if fc2.path() == self.path() and self.path() in actx:
            return actx[self.path()]
        acache = {}

        # prime the ancestor cache for the working directory
        for c in (self, fc2):
            if c._filerev is None:
                pl = [(n.path(), n.filenode()) for n in c.parents()]
                acache[(c._path, None)] = pl

        flcache = {self._repopath: self._filelog, fc2._repopath: fc2._filelog}

        def parents(vertex):
            if vertex in acache:
                return acache[vertex]
            f, n = vertex
            if f not in flcache:
                flcache[f] = self._repo.file(f)
            fl = flcache[f]
            pl = [(f, p) for p in fl.parents(n) if p != nullid]
            re = fl.renamed(n)
            if re:
                pl.append(re)
            acache[vertex] = pl
            return pl

        a, b = (self._path, self._filenode), (fc2._path, fc2._filenode)
        v = ancestor.ancestor(a, b, parents)
        if v:
            f, n = v
            return filectx(self._repo, f, fileid=n, filelog=flcache[f])

        return None
コード例 #6
0
ファイル: revlog.py プロジェクト: mortonfox/cr48
    def ancestor(self, a, b):
        """calculate the least common ancestor of nodes a and b"""

        # fast path, check if it is a descendant
        a, b = self.rev(a), self.rev(b)
        start, end = sorted((a, b))
        if self.descendant(start, end):
            return self.node(start)

        def parents(rev):
            return [p for p in self.parentrevs(rev) if p != nullrev]

        c = ancestor.ancestor(a, b, parents)
        if c is None:
            return nullid

        return self.node(c)
コード例 #7
0
    def ancestor(self, a, b):
        """calculate the least common ancestor of nodes a and b"""

        # fast path, check if it is a descendant
        a, b = self.rev(a), self.rev(b)
        start, end = sorted((a, b))
        if self.descendant(start, end):
            return self.node(start)

        def parents(rev):
            return [p for p in self.parentrevs(rev) if p != nullrev]

        c = ancestor.ancestor(a, b, parents)
        if c is None:
            return nullid

        return self.node(c)
コード例 #8
0
ファイル: context.py プロジェクト: saminigod/cygwin
    def ancestor(self, fc2):
        """
        find the common ancestor file context, if any, of self, and fc2
        """

        acache = {}

        # prime the ancestor cache for the working directory
        for c in (self, fc2):
            if c._filerev == None:
                pl = [(n.path(), n.filenode()) for n in c.parents()]
                acache[(c._path, None)] = pl

        flcache = {self._repopath: self._filelog, fc2._repopath: fc2._filelog}

        def parents(vertex):
            if vertex in acache:
                return acache[vertex]
            f, n = vertex
            if f not in flcache:
                flcache[f] = self._repo.file(f)
            fl = flcache[f]
            pl = [(f, p) for p in fl.parents(n) if p != nullid]
            re = fl.renamed(n)
            if re:
                pl.append(re)
            acache[vertex] = pl
            return pl

        a, b = (self._path, self._filenode), (fc2._path, fc2._filenode)
        v = ancestor.ancestor(a, b, parents)
        if v:
            f, n = v
            return filectx(self._repo, f, fileid=n, filelog=flcache[f])

        return None