def reposetup(ui, repo):
    if not repo.local():
        return

    # Only change behavior on repositories that are clones of a Firefox
    # repository.
    if not isfirefoxrepo(repo):
        return

    repo.prepushoutgoinghooks.add('firefoxtree', prepushoutgoinghook)

    repo.firefoxtrees = readfirefoxtrees(repo)

    def listnames(r):
        return r.firefoxtrees.keys()

    def namemap(r, name):
        node = r.firefoxtrees.get(name)
        if node:
            return [node]
        return []

    def nodemap(r, node):
        return [name for name, n in r.firefoxtrees.iteritems()
                if n == node]

    n = namespaces.namespace('fxtrees',
                             templatename='fxtree',
                             listnames=listnames,
                             namemap=namemap,
                             nodemap=nodemap)

    repo.names.addnamespace(n)
Beispiel #2
0
def reposetup(ui, repo):
    names = {'r%d' % rev: repo[rev].node() for rev in repo}
    namemap = lambda r, name: names.get(name)
    nodemap = lambda r, node: ['r%d' % repo[node].rev()]

    ns = namespaces.namespace('revnames', templatename='revname',
                              logname='revname',
                              listnames=lambda r: names.keys(),
                              namemap=namemap, nodemap=nodemap)
    repo.names.addnamespace(ns)
Beispiel #3
0
def reposetup(ui, repo):
    if not repo.local():
        return

    class firefoxtreesrepo(repo.__class__):
        # Wrap _restrictcapabilities so capabilities are exposed to local peers.
        def _restrictcapabilities(self, caps):
            caps = super(firefoxtreesrepo, self)._restrictcapabilities(caps)

            if (isfirefoxrepo(self) and
                    self.ui.configbool('firefoxtree', 'servetags', False)):
                caps.add('firefoxtrees')

            return caps

        @util.propertycache
        def firefoxtrees(self):
            trees = {}

            try:
                with open(self._firefoxtreespath, 'rb') as fh:
                    data = fh.read()
            except IOError as e:
                if e.errno != errno.ENOENT:
                    raise

                data = None

            if not data:
                return trees

            cl = self.changelog

            for line in data.splitlines():
                line = line.strip()
                if not line:
                    continue

                tree, hexnode = line.split()

                # Filter out try repos because they are special.
                if tree in TRY_TREES:
                    continue

                binnode = bin(hexnode)

                # Filter out unknown nodes. Since this function is used as part
                # of writing, it means that unknown nodes will silently be
                # dropped on next write.
                try:
                    if cl.rev(binnode) == nullrev:
                        continue
                except error.LookupError:
                    continue

                trees[tree] = binnode

            return trees

        @property
        def _firefoxtreespath(self):
            shared = {s.strip() for s in repo.vfs.tryread('shared').splitlines()}

            if 'firefoxtrees' in shared and repo.sharedpath != repo.path:
                return os.path.join(repo.sharedpath, 'firefoxtrees')
            else:
                return self.vfs.join('firefoxtrees')

    repo.__class__ = firefoxtreesrepo

    # Only change behavior on repositories that are clones of a Firefox
    # repository.
    if not isfirefoxrepo(repo):
        return

    repo.prepushoutgoinghooks.add('firefoxtree', prepushoutgoinghook)

    def listnames(r):
        return r.firefoxtrees.keys()

    def namemap(r, name):
        node = r.firefoxtrees.get(name)
        if node:
            return [node]
        return []

    def nodemap(r, node):
        return [name for name, n in r.firefoxtrees.iteritems()
                if n == node]

    n = namespaces.namespace('fxtrees',
                             templatename='fxtree',
                             listnames=listnames,
                             namemap=namemap,
                             nodemap=nodemap)

    repo.names.addnamespace(n)
def reposetup(ui, repo):
    if not repo.local():
        return

    class firefoxtreesrepo(repo.__class__):
        # Wrap _restrictcapabilities so capabilities are exposed to local peers.
        def _restrictcapabilities(self, caps):
            caps = super(firefoxtreesrepo, self)._restrictcapabilities(caps)

            if (isfirefoxrepo(self) and
                    self.ui.configbool('firefoxtree', 'servetags', False)):
                caps.add('firefoxtrees')

            return caps

        @util.propertycache
        def firefoxtrees(self):
            trees = {}

            try:
                with open(self._firefoxtreespath, 'rb') as fh:
                    data = fh.read()
            except IOError as e:
                if e.errno != errno.ENOENT:
                    raise

                data = None

            if not data:
                return trees

            for line in data.splitlines():
                line = line.strip()
                if not line:
                    continue

                tree, hexnode = line.split()

                # Filter out try repos because they are special.
                if tree in TRY_TREES:
                    continue

                trees[tree] = bin(hexnode)

            return trees

        @property
        def _firefoxtreespath(self):
            shared = {s.strip() for s in repo.vfs.tryread('shared').splitlines()}

            if 'firefoxtrees' in shared and repo.sharedpath != repo.path:
                return os.path.join(repo.sharedpath, 'firefoxtrees')
            else:
                return self.vfs.join('firefoxtrees')

    repo.__class__ = firefoxtreesrepo

    # Only change behavior on repositories that are clones of a Firefox
    # repository.
    if not isfirefoxrepo(repo):
        return

    repo.prepushoutgoinghooks.add('firefoxtree', prepushoutgoinghook)

    def listnames(r):
        return r.firefoxtrees.keys()

    def namemap(r, name):
        node = r.firefoxtrees.get(name)
        if node:
            return [node]
        return []

    def nodemap(r, node):
        return [name for name, n in r.firefoxtrees.iteritems()
                if n == node]

    n = namespaces.namespace('fxtrees',
                             templatename='fxtree',
                             listnames=listnames,
                             namemap=namemap,
                             nodemap=nodemap)

    repo.names.addnamespace(n)