[Pkg-bazaar-commits] ./bzr-gtk/unstable r62: [merge] gannotate/gdiff improvements from Aaron.
Jelmer Vernooij
jelmer at samba.org
Fri Apr 10 07:16:17 UTC 2009
------------------------------------------------------------
revno: 62
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: bzr-gtk
timestamp: Mon 2006-06-19 18:38:46 +0200
message:
[merge] gannotate/gdiff improvements from Aaron.
modified:
__init__.py
annotate/gannotate.py
viz/diffwin.py
------------------------------------------------------------
revno: 59.2.1
committer: Aaron Bentley <abentley at panoramicfeedback.com>
branch nick: bzr-gtk
timestamp: Mon 2006-06-19 10:18:52 -0400
message:
Gannotate takes a line number
modified:
__init__.py
annotate/gannotate.py
------------------------------------------------------------
revno: 59.2.2
committer: Aaron Bentley <abentley at panoramicfeedback.com>
branch nick: bzr-gtk
timestamp: Mon 2006-06-19 11:44:33 -0400
message:
Annotate launches a diff for the particular revision
modified:
annotate/gannotate.py
------------------------------------------------------------
revno: 59.2.3
committer: Aaron Bentley <abentley at panoramicfeedback.com>
branch nick: bzr-gtk
timestamp: Mon 2006-06-19 12:04:41 -0400
message:
Gannotate-launched diffs now jump to correct file
modified:
annotate/gannotate.py
viz/diffwin.py
------------------------------------------------------------
revno: 59.2.4
committer: Aaron Bentley <abentley at panoramicfeedback.com>
branch nick: bzr-gtk
timestamp: Mon 2006-06-19 12:25:43 -0400
message:
Teach gdiff to accept a single file argument
modified:
__init__.py
viz/diffwin.py
-------------- next part --------------
=== modified file '__init__.py'
--- a/__init__.py 2006-06-11 21:03:56 +0000
+++ b/__init__.py 2006-06-19 16:25:43 +0000
@@ -16,7 +16,7 @@
"""GTK+ frontends to Bazaar commands """
from bzrlib.commands import Command, register_command, display_command
-from bzrlib.errors import NotVersionedError, BzrCommandError
+from bzrlib.errors import NotVersionedError, BzrCommandError, NoSuchFile
from bzrlib.commands import Command, register_command
from bzrlib.option import Option
from bzrlib.branch import Branch
@@ -51,11 +51,11 @@
Otherwise, all changes for the tree are listed.
"""
- takes_args = []
+ takes_args = ['filename?']
takes_options = ['revision']
@display_command
- def run(self, revision=None, file_list=None):
+ def run(self, revision=None, filename=None):
wt = WorkingTree.open_containing(".")[0]
branch = wt.branch
if revision is not None:
@@ -77,6 +77,16 @@
window = DiffWindow()
window.connect("destroy", lambda w: gtk.main_quit())
window.set_diff("Working Tree", tree1, tree2)
+ if filename is not None:
+ tree_filename = tree1.relpath(filename)
+ try:
+ window.set_file(tree_filename)
+ except NoSuchFile:
+ if (tree1.inventory.path2id(tree_filename) is None and
+ tree2.inventory.path2id(tree_filename) is None):
+ raise NotVersionedError(filename)
+ raise BzrCommandError('No changes found for file "%s"' %
+ filename)
window.show()
gtk.main()
@@ -129,7 +139,7 @@
Browse changes to FILENAME line by line in a GTK+ window.
"""
- takes_args = ["filename"]
+ takes_args = ["filename", "line?"]
takes_options = [
Option("all", help="show annotations on all lines"),
Option("plain", help="don't highlight annotation lines"),
@@ -138,7 +148,7 @@
]
aliases = ["gblame", "gpraise"]
- def run(self, filename, all=False, plain=False, line=1):
+ def run(self, filename, all=False, plain=False, line='1'):
import pygtk
pygtk.require("2.0")
@@ -148,6 +158,12 @@
if str(e) == "could not open display":
raise NoDisplayError
+ try:
+ line = int(line)
+ except ValueError:
+ raise BzrCommandError('Line argument ("%s") is not a number.' %
+ line)
+
from annotate.gannotate import GAnnotateWindow
from annotate.config import GAnnotateConfig
=== modified file 'annotate/gannotate.py'
--- a/annotate/gannotate.py 2006-05-19 16:56:46 +0000
+++ b/annotate/gannotate.py 2006-06-19 16:04:41 +0000
@@ -58,6 +58,9 @@
def annotate(self, branch, file_id):
self.revisions = {}
+ self.annotations = []
+ self.branch = branch
+ self.file_id = file_id
# [revision id, line number, committer, revno, highlight color, line]
self.annomodel = gtk.ListStore(gobject.TYPE_STRING,
@@ -89,6 +92,7 @@
None,
line.rstrip("\r\n")
])
+ self.annotations.append(revision)
if not self.plain:
self._set_oldest_newest()
@@ -113,6 +117,7 @@
row = lineno - 1
self.annoview.set_cursor(row)
+ self.annoview.scroll_to_cell(row, use_align=True)
def _annotate(self, branch, file_id):
rev_hist = branch.revision_history()
@@ -180,6 +185,7 @@
sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
sw.set_shadow_type(gtk.SHADOW_IN)
sw.add(self.annoview)
+ self.annoview.gwindow = self
sw.show()
self.pane = pane = gtk.VPaned()
@@ -196,11 +202,24 @@
self.add(vbox)
+ def row_diff(self, tv, path, tvc):
+ row = path[0]
+ revision = self.annotations[row]
+ tree1 = self.branch.repository.revision_tree(revision.revision_id)
+ tree2 = self.branch.repository.revision_tree(revision.parent_ids[0])
+ from bzrlib.plugins.gtk.viz.diffwin import DiffWindow
+ window = DiffWindow()
+ window.set_diff("Diff for row %d" % row, tree1, tree2)
+ window.set_file(tree1.id2path(self.file_id))
+ window.show()
+
+
def _create_annotate_view(self):
tv = gtk.TreeView()
tv.set_rules_hint(False)
tv.connect("cursor-changed", self._show_log)
tv.show()
+ tv.connect("row-activated", self.row_diff)
cell = gtk.CellRendererText()
cell.set_property("xalign", 1.0)
=== modified file 'viz/diffwin.py'
--- a/viz/diffwin.py 2006-06-07 09:06:10 +0000
+++ b/viz/diffwin.py 2006-06-19 16:25:43 +0000
@@ -23,6 +23,7 @@
from bzrlib.delta import compare_trees
from bzrlib.diff import show_diff_trees
+from bzrlib.errors import NoSuchFile
class DiffWindow(gtk.Window):
@@ -136,6 +137,17 @@
self.treeview.expand_all()
self.set_title(description + " - bzrk diff")
+ def set_file(self, file_path):
+ tv_path = None
+ for data in self.model:
+ for child in data.iterchildren():
+ if child[0] == file_path:
+ tv_path = child.path
+ break
+ if tv_path is None:
+ raise NoSuchFile(file_path)
+ self.treeview.set_cursor(tv_path)
+
def _treeview_cursor_cb(self, *args):
"""Callback for when the treeview cursor changes."""
(path, col) = self.treeview.get_cursor()
More information about the Pkg-bazaar-commits
mailing list