aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/storage/vcs/base.py
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2010-01-18 12:25:17 -0500
committerW. Trevor King <wking@drexel.edu>2010-01-18 12:25:17 -0500
commit7ae29f930fe73adada5174a2ce74266411809ac7 (patch)
treeae850b985fab14974d3eca393907cc3a098156fa /libbe/storage/vcs/base.py
parentc7945daa3e1413b7c789df182b39c12dfbe2b4db (diff)
downloadbugseverywhere-7ae29f930fe73adada5174a2ce74266411809ac7.tar.gz
Added VCS._u_find_id_from_manifest for faster id->path calculation
Diffstat (limited to 'libbe/storage/vcs/base.py')
-rw-r--r--libbe/storage/vcs/base.py29
1 files changed, 28 insertions, 1 deletions
diff --git a/libbe/storage/vcs/base.py b/libbe/storage/vcs/base.py
index 716283a..fa64b4e 100644
--- a/libbe/storage/vcs/base.py
+++ b/libbe/storage/vcs/base.py
@@ -756,7 +756,7 @@ os.listdir(self.get_path("bugs")):
path = id_to_path(id)
ancestors = []
while True:
- if path == self.repo:
+ if not path.startswith(self.repo + os.path.sep):
break
path = os.path.dirname(path)
try:
@@ -926,6 +926,33 @@ os.listdir(self.get_path("bugs")):
return None
return ret
+ def _u_find_id_from_manifest(self, id, manifest, revision=None):
+ """
+ Search for the relative path to id using manifest, a list of all files.
+
+ Returns None if the id is not found.
+ """
+ be_dir = self._cached_path_id._spacer_dirs[0]
+ be_dir_sep = self._cached_path_id._spacer_dirs[0] + os.path.sep
+ files = [f for f in manifest if f.startswith(be_dir_sep)]
+ for file in files:
+ if not file.startswith(be_dir+os.path.sep):
+ continue
+ parts = file.split(os.path.sep)
+ dir = parts.pop(0) # don't add the first spacer dir
+ for part in parts[:-1]:
+ dir = os.path.join(dir, part)
+ if not dir in files:
+ files.append(dir)
+ for file in files:
+ try:
+ p_id = self._u_path_to_id(file)
+ if p_id == id:
+ return file
+ except (SpacerCollision, InvalidPath):
+ pass
+ raise InvalidID(id, revision=revision)
+
def _u_find_id(self, id, revision):
"""
Search for the relative path to id as of revision.