def logsummary(repo=".", paths=None, outstream=sys.stdout, max_entries=None, reverse=False, stats=False): """Write commit logs with optional diff stat summaries Args: repo: Path to repository paths: Optional set of specific paths to print entries for outstream: Stream to write log output to reverse: Reverse order in which entries are printed max_entries: Optional maximum number of entries to display stats: Print diff stats """ with open_repo_closing(repo) as r: walker = r.get_walker(max_entries=max_entries, paths=paths, reverse=reverse) for entry in walker: def decode(x): return commit_decode(entry.commit, x) print_commit(entry.commit, decode, outstream) if stats: commit = entry.commit if commit.parents: parent_commit = r[commit.parents[0]] base_tree = parent_commit.tree else: base_tree = None adiff = b"" with BytesIO() as diffstream: write_tree_diff( diffstream, r.object_store, base_tree, commit.tree) diffstream.seek(0) adiff = diffstream.getvalue() dsum = diffstat(adiff.split(b'\n')) outstream.write(dsum.decode('utf-8')) outstream.write("\n\n")
Delete a branch. Parameters repo Path to the repository name Name of the branch """ porcelain.branch_delete(repoPath, branch) elif command == "printcommit": """ def print_commit(commit, decode, outstream=sys.stdout): Write a human-readable commit log entry. Parameters commit A Commit object outstream A stream file to write to """ print >> sys.stderr, "handle command printcommit" print >> sys.stderr, commit decode = lambda x: commit_decode(entry.commit, x) porcelain.print_commit(commit, decode=decode) elif command == "diff-tree": """ diff_tree(repo, old_tree, new_tree, outstream=sys.stdout): Compares the content and mode of blobs found via two tree objects. :param repo: Path to repository :param old_tree: Id of old tree :param new_tree: Id of new tree :param outstream: Stream to write to """ print >> sys.stderr, "handle command diff-tree" print >> sys.stderr, "old tree: " + str(sys.argv[2]) print >> sys.stderr, "new tree: " + str(sys.argv[3]) porcelain.diff_tree(repoPath, sys.argv[2], sys.argv[3]) elif command == "ls-tree": try: