diff options
Diffstat (limited to 'libbe')
-rw-r--r-- | libbe/arch.py | 2 | ||||
-rw-r--r-- | libbe/bugdir.py | 2 | ||||
-rw-r--r-- | libbe/vcs.py | 23 |
3 files changed, 19 insertions, 8 deletions
diff --git a/libbe/arch.py b/libbe/arch.py index 4687555..48129b5 100644 --- a/libbe/arch.py +++ b/libbe/arch.py @@ -45,7 +45,7 @@ def new(): return Arch() class Arch(vcs.VCS): - name = "Arch" + name = "arch" client = client versioned = True _archive_name = None diff --git a/libbe/bugdir.py b/libbe/bugdir.py index 5b942d3..675b744 100644 --- a/libbe/bugdir.py +++ b/libbe/bugdir.py @@ -213,7 +213,7 @@ that the Arch VCS backend *enforces* ids with this format.""", settings easy. Don't set this attribute. Set .vcs instead, and .vcs_name will be automatically adjusted.""", default="None", - allowed=["None", "Arch", "bzr", "darcs", "git", "hg"]) + allowed=["None"]+vcs.VCS_ORDER) def vcs_name(): return {} def _get_vcs(self, vcs_name=None): diff --git a/libbe/vcs.py b/libbe/vcs.py index be28846..b1fd114 100644 --- a/libbe/vcs.py +++ b/libbe/vcs.py @@ -38,16 +38,23 @@ import doctest from utility import Dir, search_parent_directories from subproc import CommandError, invoke +from plugin import get_plugin +# List VCS modules in order of preference. +# Don't list this module, it is implicitly last. +VCS_ORDER = ['arch', 'bzr', 'darcs', 'git', 'hg'] + +def set_preferred_vcs(name): + global VCS_ORDER + assert name in VCS_ORDER, \ + 'unrecognized VCS %s not in\n %s' % (name, VCS_ORDER) + VCS_ORDER.remove(name) + VCS_ORDER.insert(0, name) def _get_matching_vcs(matchfn): """Return the first module for which matchfn(VCS_instance) is true""" - import arch - import bzr - import darcs - import git - import hg - for module in [arch, bzr, darcs, git, hg]: + for submodname in VCS_ORDER: + module = get_plugin('libbe', submodname) vcs = module.new() if matchfn(vcs) == True: return vcs @@ -117,6 +124,10 @@ class VCS(object): self._duplicateDirname = None self.encoding = encoding self.version = self._get_version() + def __str__(self): + return "<%s %s>" % (self.__class__.__name__, id(self)) + def __repr__(self): + return str(self) def _vcs_version(self): """ Return the VCS version string. |