diff options
author | Aaron Bentley <aaron.bentley@utoronto.ca> | 2005-12-22 02:59:52 -0500 |
---|---|---|
committer | Aaron Bentley <aaron.bentley@utoronto.ca> | 2005-12-22 02:59:52 -0500 |
commit | e2965575907ff05a7249a3a213e0dce8a8217ef9 (patch) | |
tree | 64acf8b2bbc4a16daefb6ed2a98a897d503080b8 /libbe/bugdir.py | |
parent | 2a0112fb5e5a3cb553a3ff0c7347247b2221b03f (diff) | |
download | bugseverywhere-e2965575907ff05a7249a3a213e0dce8a8217ef9.tar.gz |
Various Windows-related bugfixes
Diffstat (limited to 'libbe/bugdir.py')
-rw-r--r-- | libbe/bugdir.py | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/libbe/bugdir.py b/libbe/bugdir.py index 0af4706..9fee680 100644 --- a/libbe/bugdir.py +++ b/libbe/bugdir.py @@ -29,22 +29,32 @@ class NoBugDir(Exception): msg = "The directory \"%s\" has no bug directory." % path Exception.__init__(self, msg) self.path = path - + + +def iter_parent_dirs(cur_dir): + cur_dir = os.path.realpath(cur_dir) + old_dir = None + while True: + yield cur_dir + old_dir = cur_dir + cur_dir = os.path.normpath(os.path.join(cur_dir, '..')) + if old_dir == cur_dir: + break; + def tree_root(dir, old_version=False): - rootdir = os.path.realpath(dir) - while (True): - versionfile=os.path.join(rootdir, ".be/version") + for rootdir in iter_parent_dirs(dir): + versionfile=os.path.join(rootdir, ".be", "version") if os.path.exists(versionfile): if not old_version: test_version(versionfile) - break; - elif rootdir == "/": - raise NoBugDir(dir) + return BugDir(os.path.join(rootdir, ".be")) elif not os.path.exists(rootdir): raise NoRootEntry(rootdir) - rootdir=os.path.dirname(rootdir) - return BugDir(os.path.join(rootdir, ".be")) + old_rootdir = rootdir + rootdir=os.path.join('..', rootdir) + + raise NoBugDir(dir) class BadTreeVersion(Exception): def __init__(self, version): |