I wrote the following code to generate a pretty printed diff from bzr. It just currently has hard-coded branch name and dumps to stdout. I was wondering if it would make more sense to generate the diff on commit, rather than generating them on demand.
#!/usr/bin/python
from bzrlib.branch import Branch
from bzrlib.diff import show_diff_trees
from bzrlib.revisiontree import RevisionTree
I wrote the following code to generate a pretty printed diff from bzr. It just currently has hard-coded branch name and dumps to stdout. I was wondering if it would make more sense to generate the diff on commit, rather than generating them on demand.
#!/usr/bin/python
from bzrlib.branch import Branch
from bzrlib.diff import show_diff_trees
from bzrlib.revisiontree import RevisionTree
import StringIO
diff = StringIO.StringIO()
b = Branch.open("http:// svn.twistedmatr ix.com/ bzr/Twisted/ branches/ check-zi- version- 5935") svn.twistedmatr ix.com/ bzr/Twisted/ trunk")
t = Branch.open("http://
b.lock_read()
t.lock_read()
try: get_graph( t.repository) unique_ lca(rev_ b, rev_t)
rev_b = b.last_revision()
rev_t = t.last_revision()
graph = b.repository.
rev_id = graph.find_
revtree_b = b.basis_tree() b.repository, rev_id) revision_ tree(rev_ id) diff_trees( revtree_ a, revtree_b, diff)
revtree_a = RevisionTree(
revtree_a = b.repository.
show_
finally:
b.unlock()
t.unlock()
from pygments import highlight
from pygments.lexers import DiffLexer as PythonLexer
from pygments.formatters import HtmlFormatter
print highlight( diff.getvalue( ), PythonLexer(), HtmlFormatter( full=True) )