diff options
author | W. Trevor King <wking@drexel.edu> | 2009-11-20 14:29:01 -0500 |
---|---|---|
committer | W. Trevor King <wking@drexel.edu> | 2009-11-20 14:29:01 -0500 |
commit | b35dfdf10b2f58a0632d0a0542bd8232a39b0391 (patch) | |
tree | 3e331c64841832a0c15683890aee46a58581def4 /libbe/vcs.py | |
parent | 19b3a1d77946b4bbec0788d1ac3270c5cddbd54a (diff) | |
download | bugseverywhere-b35dfdf10b2f58a0632d0a0542bd8232a39b0391.tar.gz |
Adjusted test.py to use an installed vcs by default.
Protects agaist the off chance that the user doesn't have Arch (tla)
installed ;).
Changed Arch.name from "Arch" to "arch" so that each VCSs .name
matches the module name. This allows us to use vcs.VCS_ORDER (a list
of module names) to set up the allowed values of BugDir.vcs_name.
Diffstat (limited to 'libbe/vcs.py')
-rw-r--r-- | libbe/vcs.py | 23 |
1 files changed, 17 insertions, 6 deletions
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. |