Re: [PATCH 2/3] vc: Check for installed version control tools before use
- From: Kai <kai willadsen gmail com>
- To: Peter Tyser <ptyser gmail com>
- Cc: meld-list gnome org
- Subject: Re: [PATCH 2/3] vc: Check for installed version control tools before use
- Date: Sun, 25 Jul 2010 09:42:51 +1000
On 23 July 2010 15:58, Peter Tyser <ptyser gmail com> wrote:
> 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 <ptyser gmail com>
> ---
> 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]):
I'm no Windows developer, but I'm guessing a call to 'which' isn't
portable. I'm not sure if there's a better option, but can we just try
to popen/call the command in question and catch OSError or something?
> + self.combobox_vcs.get_model().append( \
> + [avc.NAME + " (" + avc.CMD + " Not Installed)", avc, False])
This needs to be translated, and just concatenating isn't i18n
friendly anyway. Off the top of my head, how about something like:
[avc.NAME + _("(%s not found)") % avc, avc, False])
...which would also warrant a translator comment.
cheers,
Kai
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]