Explorar o código

Add example showing the use of diff.

Jelmer Vernooij %!s(int64=11) %!d(string=hai) anos
pai
achega
5ac940c1ec
Modificáronse 1 ficheiros con 16 adicións e 0 borrados
  1. 16 0
      examples/diff.py

+ 16 - 0
examples/diff.py

@@ -0,0 +1,16 @@
+#!/usr/bin/python
+# This trivial script demonstrates how to extract the unified diff for a single
+# commit in a local repository.
+
+from dulwich.repo import Repo
+from dulwich.patch import write_tree_diff
+import sys
+
+repo_path = "."
+commit_id = "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)