[Pkg-bazaar-commits] ./bzr-gtk/unstable r175: Add very simple gmissing command.
Jelmer Vernooij
jelmer at samba.org
Fri Apr 10 07:45:37 UTC 2009
------------------------------------------------------------
revno: 175
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Tue 2007-03-20 20:36:35 +0100
message:
Add very simple gmissing command.
added:
missing.py
modified:
__init__.py
logview.py
-------------- next part --------------
=== modified file '__init__.py'
--- a/__init__.py 2007-03-17 23:58:03 +0000
+++ b/__init__.py 2007-03-20 19:36:35 +0000
@@ -443,6 +443,44 @@
register_command(cmd_gpreferences)
+
+class cmd_gmissing(Command):
+ """ GTK+ missing revisions dialog.
+
+ """
+ takes_args = ["other_branch?"]
+ def run(self, other_branch=None):
+ pygtk = import_pygtk()
+ try:
+ import gtk
+ except RuntimeError, e:
+ if str(e) == "could not open display":
+ raise NoDisplayError
+
+ from bzrlib.plugins.gtk.missing import MissingWindow
+ from bzrlib.branch import Branch
+
+ local_branch = Branch.open_containing(".")[0]
+ if other_branch is None:
+ other_branch = local_branch.get_parent()
+
+ if other_branch is None:
+ raise errors.BzrCommandError("No peer location known or specified.")
+ remote_branch = Branch.open_containing(other_branch)[0]
+ set_ui_factory()
+ local_branch.lock_read()
+ try:
+ remote_branch.lock_read()
+ try:
+ dialog = MissingWindow(local_branch, remote_branch)
+ dialog.run()
+ finally:
+ remote_branch.unlock()
+ finally:
+ local_branch.unlock()
+
+register_command(cmd_gmissing)
+
import gettext
gettext.install('olive-gtk')
=== modified file 'logview.py'
--- a/logview.py 2007-02-03 12:41:33 +0000
+++ b/logview.py 2007-03-20 19:36:35 +0000
@@ -1,4 +1,5 @@
# Copyright (C) 2005 Dan Loda <danloda at gmail.com>
+# Copyright (C) 2007 Jelmer Vernooij <jelmer at samba.org>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
=== added file 'missing.py'
--- a/missing.py 1970-01-01 00:00:00 +0000
+++ b/missing.py 2007-03-20 19:36:35 +0000
@@ -0,0 +1,76 @@
+# Copyright (C) 2007 Jelmer Vernooij <jelmer at samba.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+try:
+ import pygtk
+ pygtk.require("2.0")
+except:
+ pass
+
+import gtk
+
+from bzrlib.config import GlobalConfig
+from bzrlib.missing import find_unmerged
+
+from logview import LogView
+
+class MissingWindow(gtk.Dialog):
+ """Displays revisions present in one branch but missing in
+ another."""
+ def __init__(self, local_branch, remote_branch):
+ """ Initialize the Status window. """
+ super(MissingWindow, self).__init__(flags=gtk.DIALOG_MODAL)
+ self.set_title("Missing Revisions")
+ self.local_branch = local_branch
+ self.remote_branch = remote_branch
+ (self.local_extra, self.remote_extra) = find_unmerged(
+ local_branch, remote_branch)
+ self._create()
+
+ def _create_revisions_frame(self, revisions):
+ extra_revs = gtk.ScrolledWindow()
+ vbox = gtk.VBox()
+ for rev in revisions:
+ vbox.pack_start(LogView(rev), True, True)
+ extra_revs.add_with_viewport(vbox)
+ extra_revs.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
+ return extra_revs
+
+ def _create(self):
+ self.set_default_size(600, 600)
+
+ frame = gtk.Frame("You have the following extra revisions:")
+
+ extra_revs = self._create_revisions_frame(
+ self.local_branch.repository.get_revisions(
+ map(lambda (x,y):y, self.local_extra)))
+ frame.add(extra_revs)
+ self.vbox.pack_start(frame, True, True)
+
+ missing_revs = self._create_revisions_frame(
+ self.remote_branch.repository.get_revisions(
+ map(lambda (x,y):y, self.remote_extra)))
+
+ frame = gtk.Frame("You are missing following revisions:")
+ frame.add(missing_revs)
+ self.vbox.pack_start(frame, True, True)
+ self.vbox.show_all()
+
+ def display(self):
+ self.window.show_all()
+
+ def close(self, widget=None):
+ self.window.destroy()
More information about the Pkg-bazaar-commits
mailing list