コード例 #1
0
ファイル: porcelain.py プロジェクト: ols3er/dulwich
def ls_tree(repo,
            treeish=b"HEAD",
            outstream=sys.stdout,
            recursive=False,
            name_only=False):
    """List contents of a tree.

    :param repo: Path to the repository
    :param tree_ish: Tree id to list
    :param outstream: Output stream (defaults to stdout)
    :param recursive: Whether to recursively list files
    :param name_only: Only print item name
    """
    def list_tree(store, treeid, base):
        for (name, mode, sha) in store[treeid].iteritems():
            if base:
                name = posixpath.join(base, name)
            if name_only:
                outstream.write(name + b"\n")
            else:
                outstream.write(pretty_format_tree_entry(name, mode, sha))
            if stat.S_ISDIR(mode) and recursive:
                list_tree(store, sha, name)

    with open_repo_closing(repo) as r:
        tree = parse_tree(r, treeish)
        list_tree(r.object_store, tree.id, "")
コード例 #2
0
ファイル: dulwich_tree.py プロジェクト: garyvdm/dulwich-tree
 def reset(self):
     try:
         self.org_commit_id = self.repo.refs[self.ref]
     except KeyError:
         self.org_commit_id = None
         self.tree = Tree()
     else:
         self.tree = parse_tree(self.repo, self.org_commit_id)
         self.org_tree_id = self.tree.id
     self.changed_objects = {}
コード例 #3
0
ファイル: porcelain.py プロジェクト: ols3er/dulwich
def reset(repo, mode, treeish="HEAD"):
    """Reset current HEAD to the specified state.

    :param repo: Path to repository
    :param mode: Mode ("hard", "soft", "mixed")
    :param treeish: Treeish to reset to
    """

    if mode != "hard":
        raise ValueError("hard is the only mode currently supported")

    with open_repo_closing(repo) as r:
        tree = parse_tree(r, treeish)
        r.reset_index(tree.id)
コード例 #4
0
ファイル: porcelain.py プロジェクト: jelmer/dulwich
def reset(repo, mode, treeish="HEAD"):
    """Reset current HEAD to the specified state.

    :param repo: Path to repository
    :param mode: Mode ("hard", "soft", "mixed")
    :param treeish: Treeish to reset to
    """

    if mode != "hard":
        raise ValueError("hard is the only mode currently supported")

    with open_repo_closing(repo) as r:
        tree = parse_tree(r, treeish)
        r.reset_index(tree.id)
コード例 #5
0
ファイル: porcelain.py プロジェクト: jelmer/dulwich
def ls_tree(repo, treeish=b"HEAD", outstream=sys.stdout, recursive=False,
            name_only=False):
    """List contents of a tree.

    :param repo: Path to the repository
    :param tree_ish: Tree id to list
    :param outstream: Output stream (defaults to stdout)
    :param recursive: Whether to recursively list files
    :param name_only: Only print item name
    """
    def list_tree(store, treeid, base):
        for (name, mode, sha) in store[treeid].iteritems():
            if base:
                name = posixpath.join(base, name)
            if name_only:
                outstream.write(name + b"\n")
            else:
                outstream.write(pretty_format_tree_entry(name, mode, sha))
            if stat.S_ISDIR(mode) and recursive:
                list_tree(store, sha, name)
    with open_repo_closing(repo) as r:
        tree = parse_tree(r, treeish)
        list_tree(r.object_store, tree.id, "")
コード例 #6
0
    def get_tree_obj(self, rev: str, **kwargs) -> DulwichObject:
        from dulwich.objectspec import parse_tree

        tree = parse_tree(self.repo, rev)
        return DulwichObject(self.repo, ".", stat.S_IFDIR, tree.id)
コード例 #7
0
 def test_from_commit(self):
     r = MemoryRepo()
     c1, c2, c3 = build_commit_graph(r.object_store,
                                     [[1], [2, 1], [3, 1, 2]])
     self.assertEqual(r[c1.tree], parse_tree(r, c1.id))
     self.assertEqual(r[c1.tree], parse_tree(r, c1.tree))
コード例 #8
0
ファイル: dulwich_tree.py プロジェクト: garyvdm/dulwich-tree
 def reset(self):
     self.tree = parse_tree(self.repo, self.treeish)
コード例 #9
0
ファイル: test_objectspec.py プロジェクト: paddie/dulwich
 def test_from_commit(self):
     r = MemoryRepo()
     c1, c2, c3 = build_commit_graph(
             r.object_store, [[1], [2, 1], [3, 1, 2]])
     self.assertEqual(r[c1.tree], parse_tree(r, c1.id))
     self.assertEqual(r[c1.tree], parse_tree(r, c1.tree))
コード例 #10
0
 def test_from_ref(self):
     r = MemoryRepo()
     c1, c2, c3 = build_commit_graph(r.object_store, [[1], [2, 1], [3, 1, 2]])
     r.refs[b'refs/heads/foo'] = c1.id
     self.assertEqual(r[c1.tree], parse_tree(r, b'foo'))