[Pkg-bazaar-commits] ./bzr-gtk/unstable r138: Merge fixes from Szilvester.

Jelmer Vernooij jelmer at samba.org
Fri Apr 10 07:45:46 UTC 2009


------------------------------------------------------------
revno: 138
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Tue 2007-01-30 19:29:07 +0100
message:
  Merge fixes from Szilvester.
modified:
  cmenu.ui
  olive.glade
  olive/__init__.py
  olive/commit.py
  olive/menu.py
    ------------------------------------------------------------
    revno: 126.1.10
    committer: Szilveszter Farkas (Phanatic) <Szilveszter.Farkas at gmail.com>
    branch nick: bzr-gtk
    timestamp: Tue 2007-01-30 12:33:28 +0100
    message:
      Allow to commit single files from the context menu (Fixed: #54983)
    modified:
      olive/commit.py
      olive/menu.py
    ------------------------------------------------------------
    revno: 126.1.11
    committer: Szilveszter Farkas (Phanatic) <Szilveszter.Farkas at gmail.com>
    branch nick: bzr-gtk
    timestamp: Tue 2007-01-30 16:15:28 +0100
    message:
      Add revert all functionality and fix another regression.
    modified:
      olive.glade
      olive/__init__.py
    ------------------------------------------------------------
    revno: 126.1.12
    committer: Szilveszter Farkas (Phanatic) <Szilveszter.Farkas at gmail.com>
    branch nick: bzr-gtk
    timestamp: Tue 2007-01-30 17:05:15 +0100
    message:
      Added revert functionality to the context menu.
    modified:
      cmenu.ui
      olive/__init__.py
      olive/menu.py
-------------- next part --------------
=== modified file 'cmenu.ui'
--- a/cmenu.ui	2006-12-10 20:16:18 +0000
+++ b/cmenu.ui	2007-01-30 16:05:15 +0000
@@ -5,6 +5,7 @@
         <menuitem name="rename" action="rename" />
         <menuitem name="open" action="open" />
         <separator />
+        <menuitem name="revert" action="revert" />
         <menuitem name="commit" action="commit" />
         <separator />
         <menuitem name="diff" action="diff" />

=== modified file 'olive.glade'
--- a/olive.glade	2006-12-18 10:34:36 +0000
+++ b/olive.glade	2007-01-30 15:15:28 +0000
@@ -281,6 +281,15 @@
 		  </child>
 
 		  <child>
+		    <widget class="GtkMenuItem" id="menuitem_branch_revert">
+		      <property name="visible">True</property>
+		      <property name="label" translatable="yes">_Revert all changes</property>
+		      <property name="use_underline">True</property>
+		      <signal name="activate" handler="on_menuitem_branch_revert_activate" last_modification_time="Tue, 30 Jan 2007 13:20:00 GMT"/>
+		    </widget>
+		  </child>
+		  
+		  <child>
 		    <widget class="GtkMenuItem" id="menuitem_branch_merge">
 		      <property name="visible">True</property>
 		      <property name="label" translatable="yes">_Merge...</property>

=== modified file 'olive/__init__.py'
--- a/olive/__init__.py	2007-01-29 23:53:29 +0000
+++ b/olive/__init__.py	2007-01-30 16:05:15 +0000
@@ -32,10 +32,10 @@
 import gtk.glade
 
 from bzrlib.branch import Branch
-import bzrlib.errors as errors
+import bzrlib.errors as bzrerrors
 from bzrlib.workingtree import WorkingTree
 
-from dialog import error_dialog, info_dialog
+from dialog import error_dialog, info_dialog, warning_dialog
 from errors import show_bzr_error
 from guifiles import GLADEFILENAME
 
@@ -94,6 +94,7 @@
         self.menuitem_branch_checkout = self.toplevel.get_widget('menuitem_branch_checkout')
         self.menuitem_branch_pull = self.toplevel.get_widget('menuitem_branch_pull')
         self.menuitem_branch_push = self.toplevel.get_widget('menuitem_branch_push')
+        self.menuitem_branch_revert = self.toplevel.get_widget('menuitem_branch_revert')
         self.menuitem_branch_merge = self.toplevel.get_widget('menuitem_branch_merge')
         self.menuitem_branch_commit = self.toplevel.get_widget('menuitem_branch_commit')
         self.menuitem_branch_status = self.toplevel.get_widget('menuitem_branch_status')
@@ -131,6 +132,7 @@
                 "on_menuitem_branch_initialize_activate": self.on_menuitem_branch_initialize_activate,
                 "on_menuitem_branch_get_activate": self.on_menuitem_branch_get_activate,
                 "on_menuitem_branch_checkout_activate": self.on_menuitem_branch_checkout_activate,
+                "on_menuitem_branch_revert_activate": self.on_menuitem_branch_revert_activate,
                 "on_menuitem_branch_merge_activate": self.on_menuitem_branch_merge_activate,
                 "on_menuitem_branch_commit_activate": self.on_menuitem_branch_commit_activate,
                 "on_menuitem_branch_push_activate": self.on_menuitem_branch_push_activate,
@@ -198,7 +200,7 @@
         
         try:
             self.wt, self.wtpath = WorkingTree.open_containing(self.path)
-        except (errors.NotBranchError, errors.NoWorkingTree):
+        except (bzrerrors.NotBranchError, bzrerrors.NoWorkingTree):
             self.notbranch = True
         
         self.statusbar.push(self.context_id, path)
@@ -307,6 +309,18 @@
         push = OlivePush(self.wt.branch)
         push.display()
     
+    @show_bzr_error
+    def on_menuitem_branch_revert_activate(self, widget):
+        """ Branch/Revert all changes menu handler. """
+        ret = self.wt.revert([])
+        if ret:
+            warning_dialog(_('Conflicts detected'),
+                           _('Please have a look at the working tree before continuing.'))
+        else:
+            info_dialog(_('Revert successful'),
+                        _('All files reverted to last revision.'))
+        self.refresh_right()
+    
     def on_menuitem_branch_status_activate(self, widget):
         """ Branch/Status... menu handler. """
         from status import OliveStatus
@@ -323,14 +337,14 @@
  
         try:
             existing_bzrdir = bzrdir.BzrDir.open(self.path)
-        except errors.NotBranchError:
+        except bzrerrors.NotBranchError:
             bzrdir.BzrDir.create_branch_convenience(self.path)
         else:
             if existing_bzrdir.has_branch():
                 if existing_bzrdir.has_workingtree():
-                    raise errors.AlreadyBranchError(self.path)
+                    raise bzrerrors.AlreadyBranchError(self.path)
                 else:
-                    raise errors.BranchExistsWithoutWorkingTree(self.path)
+                    raise bzrerrors.BranchExistsWithoutWorkingTree(self.path)
             else:
                 existing_bzrdir.create_branch()
                 existing_bzrdir.create_workingtree()
@@ -464,6 +478,7 @@
             m_add = menu.ui.get_widget('/context_right/add')
             m_remove = menu.ui.get_widget('/context_right/remove')
             m_rename = menu.ui.get_widget('/context_right/rename')
+            m_revert = menu.ui.get_widget('/context_right/revert')
             m_commit = menu.ui.get_widget('/context_right/commit')
             m_diff = menu.ui.get_widget('/context_right/diff')
             # check if we're in a branch
@@ -473,12 +488,14 @@
                 m_add.set_sensitive(True)
                 m_remove.set_sensitive(True)
                 m_rename.set_sensitive(True)
+                m_revert.set_sensitive(True)
                 m_commit.set_sensitive(True)
                 m_diff.set_sensitive(True)
-            except errors.NotBranchError:
+            except bzrerrors.NotBranchError:
                 m_add.set_sensitive(False)
                 m_remove.set_sensitive(False)
                 m_rename.set_sensitive(False)
+                m_revert.set_sensitive(False)
                 m_commit.set_sensitive(False)
                 m_diff.set_sensitive(False)
 
@@ -700,6 +717,7 @@
         self.menuitem_branch_checkout.set_sensitive(self.notbranch)
         self.menuitem_branch_pull.set_sensitive(not self.notbranch)
         self.menuitem_branch_push.set_sensitive(not self.notbranch)
+        self.menuitem_branch_revert.set_sensitive(not self.notbranch)
         self.menuitem_branch_merge.set_sensitive(not self.notbranch)
         self.menuitem_branch_commit.set_sensitive(not self.notbranch)
         self.menuitem_branch_status.set_sensitive(not self.notbranch)
@@ -782,7 +800,7 @@
         notbranch = False
         try:
             tree1 = WorkingTree.open_containing(path)[0]
-        except (errors.NotBranchError, errors.NoWorkingTree):
+        except (bzrerrors.NotBranchError, bzrerrors.NoWorkingTree):
             notbranch = True
         
         if not notbranch:

=== modified file 'olive/commit.py'
--- a/olive/commit.py	2007-01-29 23:53:29 +0000
+++ b/olive/commit.py	2007-01-30 11:33:28 +0000
@@ -25,6 +25,8 @@
 import gobject
 import pango
 
+import os.path
+
 import bzrlib.errors as errors
 from bzrlib import osutils
 
@@ -301,11 +303,23 @@
 
         for path, id, kind in self.delta.added:
             marker = osutils.kind_marker(kind)
-            self._file_store.append([ True, path+marker, _('added'), path ])
+            if self.selected is not None:
+                if path == os.path.join(self.wtpath, self.selected):
+                    self._file_store.append([ True, path+marker, _('added'), path ])
+                else:
+                    self._file_store.append([ False, path+marker, _('added'), path ])
+            else:
+                self._file_store.append([ True, path+marker, _('added'), path ])
 
         for path, id, kind in self.delta.removed:
             marker = osutils.kind_marker(kind)
-            self._file_store.append([ True, path+marker, _('removed'), path ])
+            if self.selected is not None:
+                if path == os.path.join(self.wtpath, self.selected):
+                    self._file_store.append([ True, path+marker, _('removed'), path ])
+                else:
+                    self._file_store.append([ False, path+marker, _('removed'), path ])
+            else:
+                self._file_store.append([ True, path+marker, _('removed'), path ])
 
         for oldpath, newpath, id, kind, text_modified, meta_modified in self.delta.renamed:
             marker = osutils.kind_marker(kind)
@@ -313,15 +327,35 @@
                 changes = _('renamed and modified')
             else:
                 changes = _('renamed')
-            self._file_store.append([ True,
-                                      oldpath+marker + '  =>  ' + newpath+marker,
-                                      changes,
-                                      newpath
-                                    ])
+            if self.selected is not None:
+                if newpath == os.path.join(self.wtpath, self.selected):
+                    self._file_store.append([ True,
+                                              oldpath+marker + '  =>  ' + newpath+marker,
+                                              changes,
+                                              newpath
+                                            ])
+                else:
+                    self._file_store.append([ False,
+                                              oldpath+marker + '  =>  ' + newpath+marker,
+                                              changes,
+                                              newpath
+                                            ])
+            else:
+                self._file_store.append([ True,
+                                          oldpath+marker + '  =>  ' + newpath+marker,
+                                          changes,
+                                          newpath
+                                        ])
 
         for path, id, kind, text_modified, meta_modified in self.delta.modified:
             marker = osutils.kind_marker(kind)
-            self._file_store.append([ True, path+marker, _('modified'), path ])
+            if self.selected is not None:
+                if path == os.path.join(self.wtpath, self.selected):
+                    self._file_store.append([ True, path+marker, _('modified'), path ])
+                else:
+                    self._file_store.append([ False, path+marker, _('modified'), path ])
+            else:
+                self._file_store.append([ True, path+marker, _('modified'), path ])
     
     def _create_pending_merges(self):
         if not self.pending:

=== modified file 'olive/menu.py'
--- a/olive/menu.py	2007-01-29 23:27:09 +0000
+++ b/olive/menu.py	2007-01-30 16:05:15 +0000
@@ -69,6 +69,10 @@
                                        _('Open'), None,
                                        _('Open the selected file'),
                                        self.open_file),
+                                      ('revert', None,
+                                       _('Revert'), None,
+                                       _('Revert the changes'),
+                                       self.revert),
                                       ('commit', None,
                                        _('Commit'), None,
                                        _('Commit the changes'),
@@ -193,6 +197,18 @@
             else:
                 launch(fullpath) 
 
+    def revert(self, action):
+        """ Right context menu -> Revert """
+        wt, path = WorkingTree.open_containing(self.path)
+        ret = wt.revert([os.path.join(path, self.selected)])
+        if ret:
+            warning_dialog(_('Conflicts detected'),
+                           _('Please have a look at the working tree before continuing.'))
+        else:
+            info_dialog(_('Revert successful'),
+                        _('All files reverted to last revision.'))
+        self.app.refresh_right()       
+    
     def commit(self, action):
         """ Right context menu -> Commit """
         from commit import CommitDialog
@@ -202,8 +218,16 @@
             branch = wt.branch
         except NotBranchError, e:
             path = e.path
-        commit = CommitDialog(wt, path, not branch)
-        commit.display()
+        
+        commit = CommitDialog(wt, path, not branch, self.selected)
+        response = commit.run()
+        if response != gtk.RESPONSE_NONE:
+            commit.hide()
+        
+            if response == gtk.RESPONSE_OK:
+                self.app.refresh_right()
+            
+            commit.destroy()
     
     @show_bzr_error
     def diff(self, action):



More information about the Pkg-bazaar-commits mailing list