>>> dir = utility.Dir()
>>> os.chdir(dir.path)
- >>> vcs = vcs.installed_vcs()
- >>> vcs.init('.')
- >>> print vcs.name
- Arch
- >>> execute([], manipulate_encodings=False)
- Using Arch for revision control.
+ >>> _vcs = vcs.installed_vcs()
+ >>> _vcs.init('.')
+ >>> _vcs.name in vcs.VCS_ORDER
+ >>> execute([], manipulate_encodings=False) # doctest: +ELLIPSIS
+ Using ... for revision control.
Directory initialized.
- >>> vcs.cleanup()
+ >>> _vcs.cleanup()
>>> try:
... execute(['--root', '.'], manipulate_encodings=False)
return Arch()
class Arch(vcs.VCS):
- name = "Arch"
+ name = "arch"
client = client
versioned = True
_archive_name = None
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):
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
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.
those modules.
"""
-from libbe import plugin
+from libbe import plugin, vcs
import unittest
import doctest
import sys
for modname,module in plugin.iter_plugins("becommands"):
suite.addTest(doctest.DocTestSuite(module))
-#for s in suite._tests:
-# print s
-#exit(0)
+_vcs = vcs.installed_vcs()
+vcs.set_preferred_vcs(_vcs.name)
+print 'Using %s as the testing VCS' % _vcs.name
+
result = unittest.TextTestRunner(verbosity=2).run(suite)
numErrors = len(result.errors)