Previously, meld blindly assumed that the proper version control software
was always installed.  This causes issues when the proper version control
software isn't installed.  For example, if 'bzr' is not installed,
running "meld ./" in a bzr repository would result in an error such as:

...
  File "/home/ptyser/meld_git/meld/meld/vc/_vc.py", line 194, in popen
    return subprocess.Popen(cmd, cwd=cwd, stdout=subprocess.PIPE).stdout
  File "/usr/lib/python2.5/subprocess.py", line 594, in __init__
    errread, errwrite)
  File "/usr/lib/python2.5/subprocess.py", line 1147, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

This patch forces meld to check if the proper version control software is
installed before running any version control commands.

Signed-off-by: Peter Tyser <[email protected]>
---
 meld/vcview.py |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/meld/vcview.py b/meld/vcview.py
index 9f93a91..559e250 100644
--- a/meld/vcview.py
+++ b/meld/vcview.py
@@ -203,10 +203,11 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
         # VC ComboBox
         self.combobox_vcs = gtk.ComboBox()
         self.combobox_vcs.lock = True
-        self.combobox_vcs.set_model(gtk.ListStore(str, object))
+        self.combobox_vcs.set_model(gtk.ListStore(str, object, bool))
         cell = gtk.CellRendererText()
         self.combobox_vcs.pack_start(cell, False)
         self.combobox_vcs.add_attribute(cell, 'text', 0)
+        self.combobox_vcs.add_attribute(cell, 'sensitive', 2)
         self.combobox_vcs.lock = False
         self.hbox2.pack_end(self.combobox_vcs, expand=False)
         self.combobox_vcs.show()
@@ -235,7 +236,14 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
             if (self.vc is not None and
                 self.vc.__class__ == avc.__class__):
                 default_active = idx
-            self.combobox_vcs.get_model().append([avc.NAME, avc])
+
+            # See if the necessary version control command exists.  If not,
+            # make the version control choice non-selectable.
+            if vc._vc.call(["which", avc.CMD]):
+                self.combobox_vcs.get_model().append( \
+                    [avc.NAME + " (" + avc.CMD + " Not Installed)", avc, 
False])
+            else:
+                self.combobox_vcs.get_model().append([avc.NAME, avc, True])
         if gtk.pygtk_version >= (2, 12, 0):
             self.combobox_vcs.set_tooltip_text(tooltip_texts[len(vcs) == 1])
         self.combobox_vcs.set_sensitive(len(vcs) > 1)
-- 
1.7.1.13.gcfb88

_______________________________________________
meld-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/meld-list

Reply via email to