From: W. Trevor King Date: Wed, 23 Feb 2011 02:02:11 +0000 (-0500) Subject: Local imports and better missing-client detection in client-based VCS classes. X-Git-Tag: 1.1.0~236 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=893bbc21bdac3a5f25c17e547df8adab00dbd670;p=be.git Local imports and better missing-client detection in client-based VCS classes. --- diff --git a/libbe/storage/vcs/arch.py b/libbe/storage/vcs/arch.py index d12a91a..6c519c4 100644 --- a/libbe/storage/vcs/arch.py +++ b/libbe/storage/vcs/arch.py @@ -33,11 +33,11 @@ import sys import time # work around http://mercurial.selenic.com/bts/issue618 import libbe -import libbe.ui.util.user -import libbe.storage.util.config -from libbe.util.id import uuid_gen -from libbe.util.subproc import CommandError -import base +from ...ui.util import user as _user +from ...util.id import uuid_gen +from ...util.subproc import CommandError +from ..util import config as _config +from . import base if libbe.TESTING == True: import unittest @@ -51,7 +51,7 @@ class CantAddFile(Exception): DEFAULT_CLIENT = 'tla' -client = libbe.storage.util.config.get_val( +client = _config.get_val( 'arch_client', default=DEFAULT_CLIENT) def new(): @@ -77,14 +77,17 @@ class Arch(base.VCS): self.__updated = [] # work around http://mercurial.selenic.com/bts/issue618 def _vcs_version(self): - status,output,error = self._u_invoke_client('--version') + try: + status,output,error = self._u_invoke_client('--version') + except CommandError: # command not found? + return None version = '\n'.join(output.splitlines()[:2]) return version def _vcs_detect(self, path): """Detect whether a directory is revision-controlled using Arch""" if self._u_search_parent_directories(path, '{arch}') != None : - libbe.storage.util.config.set_val('arch_client', client) + _config.set_val('arch_client', client) return True return False @@ -102,7 +105,7 @@ class Arch(base.VCS): # http://regexps.srparish.net/tutorial-tla/new-archive.html#Creating_a_New_Archive assert self._archive_name == None id = self.get_user_id() - name, email = libbe.ui.util.user.parse_user_id(id) + name, email = _user.parse_user_id(id) if email == None: email = '%s@example.com' % name trailer = '%s-%s' % ('bugs-everywhere-auto', uuid_gen()[0:8]) diff --git a/libbe/storage/vcs/darcs.py b/libbe/storage/vcs/darcs.py index 4aa8766..4a19d1d 100644 --- a/libbe/storage/vcs/darcs.py +++ b/libbe/storage/vcs/darcs.py @@ -35,7 +35,8 @@ except ImportError: # look for non-core module from xml.sax.saxutils import unescape import libbe -import base +from ...util.subproc import CommandError +from . import base if libbe.TESTING == True: import doctest @@ -57,7 +58,10 @@ class Darcs(base.VCS): self.__updated = [] # work around http://mercurial.selenic.com/bts/issue618 def _vcs_version(self): - status,output,error = self._u_invoke_client('--version') + try: + status,output,error = self._u_invoke_client('--version') + except CommandError: # command not found? + return None return output.strip() def version_cmp(self, *args): diff --git a/libbe/storage/vcs/git.py b/libbe/storage/vcs/git.py index 7c9199d..5c17303 100644 --- a/libbe/storage/vcs/git.py +++ b/libbe/storage/vcs/git.py @@ -30,8 +30,8 @@ import shutil import unittest import libbe -import libbe.ui.util.user -import base +from ...ui.util import user as _user +from . import base if libbe.TESTING == True: import doctest @@ -52,7 +52,10 @@ class Git(base.VCS): self.versioned = True def _vcs_version(self): - status,output,error = self._u_invoke_client('--version') + try: + status,output,error = self._u_invoke_client('--version') + except CommandError: # command not found? + return None return output.strip() def _vcs_get_user_id(self): @@ -71,10 +74,10 @@ class Git(base.VCS): if name != '' or email != '': # got something! # guess missing info, if necessary if name == '': - name = libbe.ui.util.user.get_fallback_username() + name = _user.get_fallback_username() if email == '': - email = libe.ui.util.user.get_fallback_email() - return libbe.ui.util.user.create_user_id(name, email) + email = _user.get_fallback_email() + return _user.create_user_id(name, email) return None # Git has no infomation def _vcs_detect(self, path): diff --git a/libbe/storage/vcs/monotone.py b/libbe/storage/vcs/monotone.py index 65ecd91..e99a6ec 100644 --- a/libbe/storage/vcs/monotone.py +++ b/libbe/storage/vcs/monotone.py @@ -29,8 +29,8 @@ import unittest import libbe import libbe.ui.util.user -from libbe.util.subproc import CommandError -import base +from ...util.subproc import CommandError +from . import base if libbe.TESTING == True: import doctest @@ -54,7 +54,10 @@ class Monotone (base.VCS): self._key = None def _vcs_version(self): - status,output,error = self._u_invoke_client('automate', 'interface_version') + try: + status,output,error = self._u_invoke_client('automate', 'interface_version') + except CommandError: # command not found? + return None return output.strip() def version_cmp(self, *args):