aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/storage/vcs/base.py
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2009-12-13 07:53:17 -0500
committerW. Trevor King <wking@drexel.edu>2009-12-13 07:53:17 -0500
commit9147ab9e77cd5730c1b2d5a76c92f87564f4af8e (patch)
tree8187adcf5f85efa7b0019540d857cf9e840b0bd6 /libbe/storage/vcs/base.py
parentca52b5cca130fb3bd810276d9de1f198df3cf5b7 (diff)
downloadbugseverywhere-9147ab9e77cd5730c1b2d5a76c92f87564f4af8e.tar.gz
Use detect rather than catching errors in _vcs_root().
Diffstat (limited to 'libbe/storage/vcs/base.py')
-rw-r--r--libbe/storage/vcs/base.py60
1 files changed, 10 insertions, 50 deletions
diff --git a/libbe/storage/vcs/base.py b/libbe/storage/vcs/base.py
index 5308813..7d17b56 100644
--- a/libbe/storage/vcs/base.py
+++ b/libbe/storage/vcs/base.py
@@ -447,6 +447,7 @@ os.listdir(self.get_path("bugs")):
self.versioned = False
self.verbose_invoke = False
self._cached_path_id = CachedPathID()
+ self._rooted = False
def _vcs_version(self):
"""
@@ -597,15 +598,16 @@ os.listdir(self.get_path("bugs")):
Set the root directory to the path's VCS root. This is the
default working directory for future invocations.
"""
- root = self._vcs_root(self.repo)
- if root == None:
+ if self._detect(self.repo) == False:
raise VCSUnableToRoot(self)
+ root = self._vcs_root(self.repo)
self.repo = os.path.abspath(root)
if os.path.isdir(self.repo) == False:
self.repo = os.path.dirname(self.repo)
self.be_dir = os.path.join(
self.repo, self._cached_path_id._spacer_dirs[0])
self._cached_path_id.root(self.repo)
+ self._rooted == True
def _init(self):
"""
@@ -625,7 +627,8 @@ os.listdir(self.get_path("bugs")):
shutil.rmtree(self.be_dir)
def _connect(self):
- self.root()
+ if self._rooted == False:
+ self.root()
self._cached_path_id.connect()
self.check_disk_version()
@@ -796,45 +799,6 @@ os.listdir(self.get_path("bugs")):
"""
return search_parent_directories(path, filename)
- def _use_vcs(self, path, allow_no_vcs):
- """
- Try and decide if _vcs_add/update/mkdir/etc calls will
- succeed. Returns True is we think the vcs_call would
- succeeed, and False otherwise.
- """
- use_vcs = True
- exception = None
- if self.repo != None:
- if self.path_in_root(path) == False:
- use_vcs = False
- exception = InvalidPath(path, self.repo)
- else:
- use_vcs = False
- exception = VCSNotRooted(self)
- if use_vcs == False and allow_no_vcs==False:
- raise exception
- return use_vcs
-
- def path_in_root(self, path, root=None):
- """
- Return the relative path to path from root.
- >>> vcs = new()
- >>> vcs.path_in_root("/a.b/c/.be", "/a.b/c")
- True
- >>> vcs.path_in_root("/a.b/.be", "/a.b/c")
- False
- """
- if root == None:
- if self.repo == None:
- raise VCSNotRooted(self)
- root = self.repo
- path = os.path.abspath(path)
- absRoot = os.path.abspath(root)
- absRootSlashedDir = os.path.join(absRoot,"")
- if not path.startswith(absRootSlashedDir):
- return False
- return True
-
def _u_rel_path(self, path, root=None):
"""
Return the relative path to path from root.
@@ -887,24 +851,20 @@ os.listdir(self.get_path("bugs")):
#if version != upgrade.BUGDIR_DISK_VERSION:
# upgrade.upgrade(self.repo, version)
- def disk_version(self, path=None, use_none_vcs=False,
- for_duplicate_bugdir=False):
+ def disk_version(self, path=None):
"""
Requires disk access.
"""
if path == None:
- path = self.get_path("version")
- allow_no_vcs = not VCS.path_in_root(path)
- if allow_no_vcs == True:
- assert for_duplicate_bugdir == True
- return self.get(path, allow_no_vcs=allow_no_vcs).rstrip("\n")
+ path = self.get_path('version')
+ return self.get(path).rstrip('\n')
def set_disk_version(self):
"""
Requires disk access.
"""
if self.sync_with_disk == False:
- raise DiskAccessRequired("set version")
+ raise DiskAccessRequired('set version')
self.vcs.mkdir(self.get_path())
#self.vcs.set_file_contents(self.get_path("version"),
# upgrade.BUGDIR_DISK_VERSION+"\n")