[meld] Clean up the null VC module
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] Clean up the null VC module
- Date: Mon, 3 Jun 2013 20:02:52 +0000 (UTC)
commit 0c0c68ddee3febc28d7829dea2210b9231b28bfc
Author: Kai Willadsen <kai willadsen gmail com>
Date: Sun May 26 08:34:26 2013 +1000
Clean up the null VC module
meld/vc/_null.py | 62 +++++++++++++++++++++++++----------------------------
meld/vcview.py | 9 +++++--
2 files changed, 35 insertions(+), 36 deletions(-)
---
diff --git a/meld/vc/_null.py b/meld/vc/_null.py
index 8ef801d..0f7fab5 100644
--- a/meld/vc/_null.py
+++ b/meld/vc/_null.py
@@ -1,40 +1,36 @@
-### Copyright (C) 2002-2005 Stephen Kennedy <stevek gnome org>
-
-### Redistribution and use in source and binary forms, with or without
-### modification, are permitted provided that the following conditions
-### are met:
-###
-### 1. Redistributions of source code must retain the above copyright
-### notice, this list of conditions and the following disclaimer.
-### 2. Redistributions in binary form must reproduce the above copyright
-### notice, this list of conditions and the following disclaimer in the
-### documentation and/or other materials provided with the distribution.
-
-### THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-### IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-### OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-### IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-### INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-### NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-### DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-### THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-### (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-### THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-from gettext import gettext as _
-
-from . import _vc
+# Copyright (C) 2002-2005 Stephen Kennedy <stevek gnome org>
+
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+from meld.vc import _vc
class Vc(_vc.Vc):
- CMD = "true"
- NAME = _("None")
- # Accept any directory
+ CMD = None
+ NAME = ""
VC_DIR = "."
def lookup_files(self, dirs, files, directory=None):
- "files is array of (name, path). assume all files in same dir"
- d = [_vc.Dir(x[1], x[0], _vc.STATE_NONE) for x in dirs]
- f = [_vc.File(x[1], x[0], _vc.STATE_NONE) for x in files]
- return d, f
+ dirs = [_vc.Dir(d[1], d[0], _vc.STATE_NONE) for d in dirs]
+ files = [_vc.File(f[1], f[0], _vc.STATE_NONE) for f in files]
+ return dirs, files
diff --git a/meld/vcview.py b/meld/vcview.py
index 36f104b..91441a1 100644
--- a/meld/vcview.py
+++ b/meld/vcview.py
@@ -408,6 +408,8 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
err_str = ""
def vc_installed(cmd):
+ if not cmd:
+ return True
try:
return not vc._vc.call(["which", cmd])
except OSError:
@@ -432,14 +434,15 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
self.combobox_vcs.get_model().append(
[_("%s (%s)") % (avc.NAME, err_str), avc, False])
else:
- self.combobox_vcs.get_model().append([avc.NAME, avc, True])
+ name = avc.NAME or _("None")
+ self.combobox_vcs.get_model().append([name, avc, True])
if not valid_vcs:
# If we didn't get any valid vcs then fallback to null
null_vcs = _null.Vc(vcs[0].location)
vcs.append(null_vcs)
self.combobox_vcs.get_model().insert(
- 0, [null_vcs.NAME, null_vcs, True])
+ 0, [_("None"), null_vcs, True])
default_active = 0
if default_active == -1:
@@ -449,7 +452,7 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
default_active = 0
# If we only have the null VC, give a better error message.
- if (len(vcs) == 1 and vcs[0].CMD == "true") or (len(valid_vcs) == 0):
+ if (len(vcs) == 1 and not vcs[0].CMD) or (len(valid_vcs) == 0):
tooltip = _("No valid version control system found in this folder")
elif len(vcs) == 1:
tooltip = _("Only one version control system found in this folder")
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]