diff --git a/examples/diff.py b/examples/diff.py index 1dd9bbf4..fabcd621 100644 --- a/examples/diff.py +++ b/examples/diff.py @@ -1,19 +1,20 @@ #!/usr/bin/python # This trivial script demonstrates how to extract the unified diff for a single # commit in a local repository. # # Example usage: # python examples/diff.py from dulwich.repo import Repo from dulwich.patch import write_tree_diff import sys repo_path = "." -commit_id = "a6602654997420bcfd0bee2a0563d9416afe34b4" +commit_id = b"a6602654997420bcfd0bee2a0563d9416afe34b4" r = Repo(repo_path) commit = r[commit_id] parent_commit = r[commit.parents[0]] -write_tree_diff(sys.stdout, r.object_store, parent_commit.tree, commit.tree) +outstream = getattr(sys.stdout, 'buffer', sys.stdout) +write_tree_diff(outstream, r.object_store, parent_commit.tree, commit.tree) diff --git a/examples/latest_change.py b/examples/latest_change.py index 0f876def..d0c5c4b9 100644 --- a/examples/latest_change.py +++ b/examples/latest_change.py @@ -1,21 +1,23 @@ #!/usr/bin/python # Example printing the last author of a specified file import sys import time from dulwich.repo import Repo if len(sys.argv) < 2: print("usage: %s filename" % (sys.argv[0], )) sys.exit(1) r = Repo(".") -w = r.get_walker(paths=[sys.argv[1]], max_entries=1) +path = sys.argv[1].encode('utf-8') + +w = r.get_walker(paths=[path], max_entries=1) try: c = next(iter(w)).commit except StopIteration: print("No file %s anywhere in history." % sys.argv[1]) else: print("%s was last changed by %s at %s (commit %s)" % ( sys.argv[1], c.author, time.ctime(c.author_time), c.id))