Rev 227: Add push item in revision menu, clean up push code. in file:///data/jelmer/bzr-gtk/trunk/

Jelmer Vernooij jelmer at samba.org
Sun Jul 15 17:23:45 BST 2007


At file:///data/jelmer/bzr-gtk/trunk/

------------------------------------------------------------
revno: 227
revision-id: jelmer at samba.org-20070715162345-c8a8lq27g1euw83u
parent: jelmer at samba.org-20070715160201-zpf3tvlpvvfxylck
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Sun 2007-07-15 18:23:45 +0200
message:
  Add push item in revision menu, clean up push code.
modified:
  push.py                        push.py-20060721181724-0mfkrqwpsa09q1t3-4
  revisionmenu.py                revisionmenu.py-20070715160146-pd4ew0wtlevga2mx-1
  viz/branchwin.py               branchwin.py-20051016222514-15fd120652fcf25c
=== modified file 'push.py'
--- a/push.py	2007-07-15 15:05:06 +0000
+++ b/push.py	2007-07-15 16:23:45 +0000
@@ -1,4 +1,5 @@
 # Copyright (C) 2006 by Szilveszter Farkas (Phanatic) <szilveszter.farkas at gmail.com>
+# Copyright (C) 2007 by 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
@@ -33,7 +34,7 @@
 
 class PushDialog(gtk.Dialog):
     """ New implementation of the Push dialog. """
-    def __init__(self, branch, parent=None):
+    def __init__(self, repository, revid, branch=None, parent=None):
         """ Initialize the Push dialog. """
         gtk.Dialog.__init__(self, title="Push - Olive",
                                   parent=parent,
@@ -41,17 +42,15 @@
                                   buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
         
         # Get arguments
+        self.repository = repository
+        self.revid = revid
         self.branch = branch
         
         # Create the widgets
         self._label_location = gtk.Label(_("Location:"))
         self._label_test = gtk.Label(_("(click the Test button to check write access)"))
-        self._check_remember = gtk.CheckButton(_("_Remember as default location"),
-                                               use_underline=True)
         self._check_prefix = gtk.CheckButton(_("Create the path _leading up to the location"),
                                              use_underline=True)
-        self._check_overwrite = gtk.CheckButton(_("_Overwrite target if diverged"),
-                                                use_underline=True)
         self._combo = gtk.ComboBoxEntry()
         self._button_test = gtk.Button(_("_Test"), use_underline=True)
         self._button_push = gtk.Button(_("_Push"), use_underline=True)
@@ -77,9 +76,7 @@
         self._hbox_test.pack_start(self._image_test, False, False)
         self._hbox_test.pack_start(self._label_test, True, True)
         self.vbox.pack_start(self._hbox_location)
-        self.vbox.pack_start(self._check_remember)
         self.vbox.pack_start(self._check_prefix)
-        self.vbox.pack_start(self._check_overwrite)
         self.vbox.pack_start(self._hbox_test)
         self.action_area.pack_start(self._button_test)
         self.action_area.pack_end(self._button_push)
@@ -99,9 +96,10 @@
         self._combo.set_model(self._combo_model)
         self._combo.set_text_column(0)
         
-        location = self.branch.get_push_location()
-        if location:
-            self._combo.get_child().set_text(location)
+        if self.branch is not None:
+            location = self.branch.get_push_location()
+            if location is not None:
+                self._combo.get_child().set_text(location)
     
     def _on_test_clicked(self, widget):
         """ Test button clicked handler. """
@@ -133,17 +131,25 @@
         """ Push button clicked handler. """
         location = self._combo.get_child().get_text()
         revs = 0
+        if self.branch is not None and self.branch.get_push_location() is None:
+            response = question_dialog(_('Set default push location'),
+                                       _('There is no default push location set.\nSet %r as default now?') % location)
+            if response == gtk.REPONSE_OK:
+                self.branch.set_push_location(location)
+
         try:
             revs = do_push(self.branch,
                            location=location,
-                           overwrite=self._check_overwrite.get_active(),
-                           remember=self._check_remember.get_active(),
+                           overwrite=False,
                            create_prefix=self._check_prefix.get_active())
         except errors.DivergedBranches:
             response = question_dialog(_('Branches have been diverged'),
                                        _('You cannot push if branches have diverged.\nOverwrite?'))
             if response == gtk.RESPONSE_OK:
-                revs = do_push(self.branch, overwrite=True)
+                revs = do_push(self.branch, location=location,
+                               overwrite=True,
+                               create_prefix=self._check_prefix.get_active()
+                               )
             return
         
         self._history.add_entry(location)
@@ -152,16 +158,13 @@
         
         self.response(gtk.RESPONSE_OK)
 
-def do_push(branch, location=None, remember=False, overwrite=False,
-         create_prefix=False):
+def do_push(branch, location, overwrite, create_prefix):
     """ Update a mirror of a branch.
     
     :param branch: the source branch
     
     :param location: the location of the branch that you'd like to update
     
-    :param remember: if set, the location will be stored
-    
     :param overwrite: overwrite target location if it diverged
     
     :param create_prefix: create the path leading up to the branch if it doesn't exist
@@ -171,23 +174,9 @@
     from bzrlib.bzrdir import BzrDir
     from bzrlib.transport import get_transport
         
-    br_from = branch
-    
-    stored_loc = br_from.get_push_location()
-    if location is None:
-        if stored_loc is None:
-            error_dialog(_('Push location is unknown'),
-                         _('Please specify a location manually.'))
-            return
-        else:
-            location = stored_loc
-
     transport = get_transport(location)
     location_url = transport.base
 
-    if br_from.get_push_location() is None or remember:
-        br_from.set_push_location(location_url)
-
     old_rh = []
 
     try:
@@ -230,8 +219,6 @@
             tree_to = dir_to.open_workingtree()
         except errors.NotLocalUrl:
             # FIXME - what to do here? how should we warn the user?
-            #warning('This transport does not update the working '
-            #        'tree of: %s' % (br_to.base,))
             count = br_to.pull(br_from, overwrite)
         except errors.NoWorkingTree:
             count = br_to.pull(br_from, overwrite)

=== modified file 'revisionmenu.py'
--- a/revisionmenu.py	2007-07-15 16:02:01 +0000
+++ b/revisionmenu.py	2007-07-15 16:23:45 +0000
@@ -25,17 +25,22 @@
 import gtk
 
 class RevisionPopupMenu(gtk.Menu):
-    def __init__(self, repository, revid):
+    def __init__(self, repository, revid, branch=None):
         super(RevisionPopupMenu, self).__init__()
-        self.create_items()
+        self.branch = branch
         self.repository = repository
         self.revid = revid
+        self.create_items()
 
     def create_items(self):
         item = gtk.MenuItem("View _Diff")
         item.connect('activate', self.show_diff)
         self.append(item)
         self.show_all()
+        item = gtk.MenuItem("_Push")
+        item.connect('activate', self.show_push)
+        self.append(item)
+        self.show_all()
 
     def show_diff(self, item):
         from bzrlib.plugins.gtk.diff import DiffWindow
@@ -45,3 +50,8 @@
                                                                    self.revid])
         window.set_diff(self.revid, rev_tree, parent_tree)
         window.show()
+
+    def show_push(self, item):
+        from bzrlib.plugins.gtk.push import PushDialog
+        dialog = PushDialog(self.repository, self.revid, self.branch)
+        dialog.run()

=== modified file 'viz/branchwin.py'
--- a/viz/branchwin.py	2007-07-15 16:02:01 +0000
+++ b/viz/branchwin.py	2007-07-15 16:23:45 +0000
@@ -263,7 +263,8 @@
         from bzrlib.plugins.gtk.revisionmenu import RevisionPopupMenu
         # FIXME: Support multiple revisions
         menu = RevisionPopupMenu(self.branch.repository, 
-                                 self.selected_revisions()[0].revision_id)
+                                 self.selected_revisions()[0].revision_id, 
+                                 self.branch)
         menu.popup(None, None, None, event.button, event.get_time())
 
     def selected_revision(self, path):




More information about the bazaar-commits mailing list