当前位置: 首页>>代码示例>>Python>>正文


Python Jagare.rev_list方法代码示例

本文整理汇总了Python中ellen.repo.Jagare.rev_list方法的典型用法代码示例。如果您正苦于以下问题:Python Jagare.rev_list方法的具体用法?Python Jagare.rev_list怎么用?Python Jagare.rev_list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ellen.repo.Jagare的用法示例。


在下文中一共展示了Jagare.rev_list方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: rev_list

# 需要导入模块: from ellen.repo import Jagare [as 别名]
# 或者: from ellen.repo.Jagare import rev_list [as 别名]
 def rev_list(self, path, to_ref, from_ref, file_path, skip, max_count,
              author, query, first_parent, since, no_merges):
     try:
         repo = Jagare(path)
         commit_list = repo.rev_list(to_ref=to_ref, from_ref=from_ref,
                                     path=file_path, skip=skip,
                                     max_count=max_count, author=author,
                                     query=query, first_parent=first_parent,
                                     since=since, no_merges=no_merges)
         return [CommitConverter(**commit_dict).convert()
                 for commit_dict in commit_list]
     except Exception as e:
         raise ServiceUnavailable(repr(e))
开发者ID:tclh123,项目名称:jagare-rpc,代码行数:15,代码来源:jagare_handler.py

示例2: Repo

# 需要导入模块: from ellen.repo import Jagare [as 别名]
# 或者: from ellen.repo.Jagare import rev_list [as 别名]
class Repo(object):
    provided_features = []

    def __init__(self, path):
        self.type = "repo"
        self.path = path
        self.repo = Jagare(self.path)

    def provide(self, name):
        '''检查是否提供某功能,即是否提供某接口'''
        return name in self.provided_features

    @property
    def is_empty(self):
        return self.repo.empty

    @property
    def default_branch(self):
        branch = None
        head = self.repo.head
        if head:
            branch = head.name.rpartition('/')[-1]
        return branch

    def update_default_branch(self, name):
        branches = self.repo.branches
        if name not in branches:
            return None
        self.repo.update_head(name)

    def clone(self, path, bare=None, branch=None, mirror=None, env=None):
        self.repo.clone(path,
                        bare=bare, branch=branch,
                        mirror=mirror, env=env)

    def archive(self, name):
        content = self.repo.archive(name)
        outbuffer = StringIO()
        zipfile = gzip.GzipFile(mode='wb', compresslevel=6, fileobj=outbuffer)
        zipfile.writelines(content)
        zipfile.close()
        out = outbuffer.getvalue()
        return out

    def get_submodule(self, ref, path):
        path = path.strip()
        gitmodules = self.repo.show("%s:%s" % (ref, '.gitmodules'))
        if not gitmodules:
            return None
        submodules_lines = gitmodules["data"].split('\n')
        modules_str = '\n'.join([line.strip() for line in submodules_lines])
        config = ConfigParser.RawConfigParser()
        config.readfp(StringIO(modules_str))
        for section in config.sections():
            if config.has_option(section, 'path') and config.get(section, 'path')==path:
                url = config.get(section, 'url')
                return Submodule(url, path)
        return None


    def get_file(self, ref, path):
        blob = self.repo.show("%s:%s" % (ref, path))
        if not blob:
            return None
        if blob['type'] != 'blob':
            return None
        # TODO: validate blob
        return Blob(self, blob)

    def get_file_by_lines(self, ref, path):
        blob = self.get_file(ref, path)
        # TODO: blob.size < xxx
        if not blob or blob.binary:
            return None
        if not blob.data:
            return []
        src = blob.data
        return src.splitlines()

    def get_file_n_lines(self, ref, path):
        lines = self.get_file_by_lines(ref, path)
        if lines:
            return len(lines)
        return 0

    def get_commits(self, *w, **kw):
        commits = self.repo.rev_list(*w, **kw)
        # TODO: validate commits
        return [Commit(self, commit) for commit in commits]

    def get_raw_diff(self, ref, from_ref=None, **kw):
        ''' get Jagare formated diff dict '''
        return self.repo.diff(ref, from_ref=from_ref, **kw)

    def get_diff(self, ref=None, from_ref=None,
                 linecomments=[], raw_diff=None, **kw):
        ''' get ngit wrapped diff object '''
        _raw_diff = None
        if raw_diff:
            _raw_diff = raw_diff
#.........这里部分代码省略.........
开发者ID:4T-Shirt,项目名称:code,代码行数:103,代码来源:repo.py

示例3: ProjectRepo

# 需要导入模块: from ellen.repo import Jagare [as 别名]
# 或者: from ellen.repo.Jagare import rev_list [as 别名]

#.........这里部分代码省略.........
    def get_temp_branch(self):
        commit = self.get_commit('HEAD')
        return 'patch_tmp' + time.strftime('%Y%m%d%H%M%S-') + commit.sha[10]

    def get_patch_file(self, ref, from_ref=None):
        return self.repo.format_patch(ref, from_ref)

    def get_diff_file(self, ref, from_ref=None):
        _raw_diff = self.get_raw_diff(ref, from_ref)
        if not _raw_diff:
            return ''
        return _raw_diff['diff'].patch

    def get_last_update_timestamp(self):
        commit = self.get_last_commit('HEAD')
        if not commit:
            return 0
        return int(commit.author_timestamp)

    @classmethod
    def init(cls, path, work_path=None, bare=True):
        return Jagare.init(path, work_path=work_path, bare=bare)

    @classmethod
    def mirror(cls, url, path, env=None):
        Jagare.mirror(url, path, env=env)

    def add_remote(self, name, url):
        return self.repo.add_remote(name, url)

    def add_remote_hub(self, name, url):
        self.add_remote('hub/%s' % name, url)

    def update_ref(self, ref, value):
        return self.repo.update_ref(ref, value)

    def sha(self, rev='HEAD'):
        return self.repo.sha(rev)

    def merge_base(self, to_sha, from_sha):
        return self.repo.merge_base(to_sha, from_sha)

    def remotes(self):
        return self.repo.remotes()

    def fetch_all(self):
        self.repo.fetch_all()

    def fetch(self, name):
        self.repo.fetch(name)

    def archive(self):
        super(ProjectRepo, self).archive(self.project.name)

    def get_latest_update_branches(self):
        refs = self.repo.listall_references()
        refs = filter(lambda r:r.startswith('refs/heads'), refs)
        current_time = time.time()
        latest_branches = []
        for ref in refs:
            commit_time = self.repo.lookup_reference(ref).get_object().commit_time
            delta = current_time - commit_time
            if delta < LATEST_UPDATE_REF_THRESHOLD:
                latest_branches.append((commit_time, ref.split('/')[-1]))
        return sorted(latest_branches, key=lambda r:r[0], reverse=True)

    def get_all_src_objects(self):
        refs = self.repo.listall_references()
        refs = filter(lambda r: r.startswith('refs/heads'), refs)
        commits_dict = {}
        for ref in refs:
            commits = self.repo.rev_list(ref)
            commits = {c['sha']: c for c in commits}
            commits_dict.update(commits)
        commits = sorted(commits_dict.values(), key=lambda x: x['time'], reverse=True)

        pruned_set = set()
        objects_dict = {}
        treenode_list = [(commit['sha'], commit['tree'], '') for commit in commits]
        while treenode_list:
            commit_id, tree_id, path = treenode_list.pop()
            if tree_id in pruned_set:
                continue
            pruned_set.add(tree_id)
            objects = self.repo.ls_tree(tree_id, size=True)
            for obj in objects:
                obj_id = obj['id']
                obj_path = '%s/%s' % (path, obj['name'])
                if obj['type'] == 'tree':
                    treenode_list.append((commit_id, obj_id, obj_path))
                elif obj['type'] == 'blob':
                    if obj_id not in objects_dict:
                        commit = commits_dict[commit_id]
                        objects_dict[obj_id] = dict(path=obj_path[1:],
                                                    commit=commit_id,
                                                    size=obj['size'],
                                                    commit_time=commit['time'],
                                                    committer=commit['committer']['name']
                                                    )
        return objects_dict
开发者ID:4T-Shirt,项目名称:code,代码行数:104,代码来源:repo.py

示例4: Repo

# 需要导入模块: from ellen.repo import Jagare [as 别名]
# 或者: from ellen.repo.Jagare import rev_list [as 别名]
class Repo(object):
    provided_features = []

    def __init__(self, path):
        self.type = "repo"
        self.path = path
        self.repo = Jagare(self.path)

    def provide(self, name):
        '''检查是否提供某功能,即是否提供某接口'''
        return name in self.provided_features

    @property
    def empty(self):
        return self.is_empty

    @property
    def is_empty(self):
        return self.repo.empty

    @property
    def default_branch(self):
        branch = ''
        head = self.repo.head
        if head:
            branch = head.name[REFS_HEADS_PREFIX_LENGTH:]
        return branch

    def update_default_branch(self, name):
        branches = self.repo.branches
        if name not in branches:
            return None
        self.repo.update_head(name)

    def clone(self, path, bare=None, branch=None,
              mirror=None, env=None, shared=None):
        self.repo.clone(path,
                        bare=bare, branch=branch,
                        mirror=mirror, env=env)
        # shared=shared) why?

    def archive(self, name, ref='master', ext='tar.gz'):
        content = self.repo.archive(name, ref=ref)
        if ext == 'tar':
            return content
        outbuffer = StringIO()
        zipfile = gzip.GzipFile(mode='wb', compresslevel=6, fileobj=outbuffer)
        zipfile.write(content)
        zipfile.close()
        out = outbuffer.getvalue()
        return out

    def get_submodule(self, ref, path):
        path = path.strip()
        gitmodules = self.repo.show("%s:%s" % (ref, '.gitmodules'))
        if not gitmodules:
            return None
        submodules_lines = gitmodules["data"].split('\n')
        modules_str = '\n'.join([line.strip() for line in submodules_lines])
        config = ConfigParser.RawConfigParser()
        config.readfp(StringIO(modules_str))
        for section in config.sections():
            if config.has_option(section, 'path') and config.get(
                    section, 'path') == path:
                url = config.get(section, 'url')
                return Submodule(url, path)
        return None

    def get_file(self, ref, path):
        blob = self.repo.show("%s:%s" % (ref, path))
        if not blob:
            return None
        if blob['type'] != 'blob':
            return None
        # TODO: validate blob
        return Blob(self, blob)

    def get_file_by_lines(self, ref, path):
        blob = self.get_file(ref, path)
        # TODO: blob.size < xxx
        if not blob or blob.binary:
            return None
        if not blob.data:
            return []
        src = blob.data
        return src.splitlines()

    def get_file_n_lines(self, ref, path):
        lines = self.get_file_by_lines(ref, path)
        if lines:
            return len(lines)
        return 0

    def get_commits(self, to_ref, from_ref=None, path=None, skip=0,
                    max_count=0, author=None, query=None, first_parent=None,
                    since=0, no_merges=None):
        commits = self.repo.rev_list(to_ref=to_ref, from_ref=from_ref,
                                     path=path, skip=skip,
                                     max_count=max_count, author=author,
                                     query=query, first_parent=first_parent,
#.........这里部分代码省略.........
开发者ID:000fan000,项目名称:code,代码行数:103,代码来源:repo.py

示例5: ProjectRepo

# 需要导入模块: from ellen.repo import Jagare [as 别名]
# 或者: from ellen.repo.Jagare import rev_list [as 别名]

#.........这里部分代码省略.........

    def get_diff_file(self, ref, from_ref=None):
        _raw_diff = self.get_raw_diff(ref, from_ref)
        if not _raw_diff:
            return ""
        patch = _raw_diff["diff"].patch
        if not patch:
            return ""
        return patch

    @classmethod
    def init(cls, path, work_path=None, bare=True):
        return Jagare.init(path, work_path=work_path, bare=bare)

    @classmethod
    def mirror(cls, url, path, env=None):
        Jagare.mirror(url, path, env=env)

    def add_remote(self, name, url):
        return self.repo.add_remote(name, url)

    def add_remote_hub(self, name, url):
        self.add_remote("hub/%s" % name, url)

    def update_ref(self, ref, value):
        result = None
        try:
            result = self.repo.update_ref(ref, value)
        except JagareError:
            # FIXME: logging
            # FIXME: more meaningful error (JagareError)
            pass
        return result

    def sha(self, rev="HEAD"):
        return self.repo.sha(rev)

    def merge_base(self, to_sha, from_sha):
        return self.repo.merge_base(to_sha, from_sha)

    @property
    def remotes(self):
        return self.repo.remotes

    def fetch_all(self):
        self.repo.fetch_all()

    def fetch(self, name):
        self.repo.fetch(name)

    def fetch_(self, *w, **kw):
        return self.repo.fetch_(*w, **kw)

    def get_latest_update_branches(self):
        refs = self.repo.listall_references()
        refs = filter(lambda r: r.startswith("refs/heads"), refs)
        current_time = time.time()
        latest_branches = []
        for ref in refs:
            commit_time = self.repo.lookup_reference(ref).get_object().commit_time  # noqa
            delta = current_time - commit_time
            if delta < LATEST_UPDATE_REF_THRESHOLD:
                latest_branches.append((commit_time, ref.split("/")[-1]))
        return sorted(latest_branches, key=lambda r: r[0], reverse=True)

    def get_all_src_objects(self):
        refs = self.repo.listall_references()
        refs = filter(lambda r: r.startswith("refs/heads"), refs)
        commits_dict = {}
        for ref in refs:
            commits = self.repo.rev_list(ref)
            commits = {c["sha"]: c for c in commits}
            commits_dict.update(commits)
        commits = sorted(commits_dict.values(), key=lambda x: x["committer"]["time"], reverse=True)

        pruned_set = set()
        objects_dict = {}
        treenode_list = [(commit["sha"], commit["tree"], "") for commit in commits]
        while treenode_list:
            commit_id, tree_id, path = treenode_list.pop()
            if tree_id in pruned_set:
                continue
            pruned_set.add(tree_id)
            objects = self.repo.ls_tree(tree_id, size=True)
            for obj in objects:
                obj_id = obj["id"]
                obj_path = "%s/%s" % (path, obj["name"])
                if obj["type"] == "tree":
                    treenode_list.append((commit_id, obj_id, obj_path))
                elif obj["type"] == "blob":
                    if obj_id not in objects_dict:
                        commit = commits_dict[commit_id]
                        objects_dict[obj_id] = dict(
                            path=obj_path[1:],
                            commit=commit_id,
                            size=obj["size"],
                            commit_time=datetime.fromtimestamp(commit["committer"]["time"]),
                            committer=commit["committer"]["name"],
                        )
        return objects_dict
开发者ID:mozillazg,项目名称:code,代码行数:104,代码来源:repo.py


注:本文中的ellen.repo.Jagare.rev_list方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。