Commit 0c0c68dd authored by Kai Willadsen's avatar Kai Willadsen

Clean up the null VC module

parent 641b2d02
### 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
......@@ -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")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment