Пример #1
0
    def fctx_annotate(self, wire, revision, path):
        repo = self._factory.repo(wire)
        ctx = repo[revision]
        fctx = ctx.filectx(path)

        result = []
        for i, annotate_data in enumerate(fctx.annotate()):
            ln_no = i + 1
            sha = hex(annotate_data[0].node())
            result.append((ln_no, sha, annotate_data[1]))
        return result
Пример #2
0
    def file_history_untill(self, wire, revision, path, limit):
        repo = self._factory.repo(wire)
        ctx = repo[revision]
        fctx = ctx.filectx(path)

        file_log = list(fctx.filelog())
        if limit:
            # Limit to the last n items
            file_log = file_log[-limit:]

        return [hex(fctx.filectx(cs).node()) for cs in reversed(file_log)]
Пример #3
0
    def rev_range_hash(self, wire, node):
        repo = self._factory.repo(wire)

        def get_revs(repo, rev_opt):
            if rev_opt:
                revs = revrange(repo, rev_opt)
                if len(revs) == 0:
                    return (nullrev, nullrev)
                return max(revs), min(revs)
            else:
                return len(repo) - 1, 0

        stop, start = get_revs(repo, [node + ':'])
        revs = [hex(repo[r].node()) for r in xrange(start, stop + 1)]
        return revs
Пример #4
0
    def commitctx(
            self, wire, message, parents, commit_time, commit_timezone,
            user, files, extra, removed, updated):

        def _filectxfn(_repo, memctx, path):
            """
            Marks given path as added/changed/removed in a given _repo. This is
            for internal mercurial commit function.
            """

            # check if this path is removed
            if path in removed:
                # returning None is a way to mark node for removal
                return None

            # check if this path is added
            for node in updated:
                if node['path'] == path:
                    return memfilectx(
                        _repo,
                        path=node['path'],
                        data=node['content'],
                        islink=False,
                        isexec=bool(node['mode'] & stat.S_IXUSR),
                        copied=False,
                        memctx=memctx)

            raise exceptions.AbortException(
                "Given path haven't been marked as added, "
                "changed or removed (%s)" % path)

        repo = self._factory.repo(wire)

        commit_ctx = memctx(
            repo=repo,
            parents=parents,
            text=message,
            files=files,
            filectxfn=_filectxfn,
            user=user,
            date=(commit_time, commit_timezone),
            extra=extra)

        n = repo.commitctx(commit_ctx)
        new_id = hex(n)

        return new_id
Пример #5
0
    def file_history(self, wire, revision, path, limit):
        repo = self._factory.repo(wire)

        ctx = repo[revision]
        fctx = ctx.filectx(path)

        def history_iter():
            limit_rev = fctx.rev()
            for obj in reversed(list(fctx.filelog())):
                obj = fctx.filectx(obj)
                if limit_rev >= obj.rev():
                    yield obj

        history = []
        for cnt, obj in enumerate(history_iter()):
            if limit and cnt >= limit:
                break
            history.append(hex(obj.node()))

        return [x for x in history]
Пример #6
0
 def get_all_commit_ids(self, wire, name):
     repo = self._factory.repo(wire)
     revs = repo.filtered(name).changelog.index
     return map(lambda x: hex(x[7]), revs)[:-1]