[meld] Rename is_repo_root to check_repo_root, and use in find_repo_root



commit a6c983b10dd5381f36a157fcb1254b618733a252
Author: Geoffrey Irving <irving naml us>
Date:   Fri Jul 24 14:49:45 2009 -0400

    Rename is_repo_root to check_repo_root, and use in find_repo_root
    
    1.  The name "is_repo_root" is misleading since the function throws an
        exception on failure, so call it "check_repo_root" instead.
    
    2.  Make find_repo_root call check_repo_root to avoid duplicating logic.

 meld/vc/_vc.py |   10 ++++++----
 meld/vc/svk.py |    2 +-
 2 files changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/meld/vc/_vc.py b/meld/vc/_vc.py
index 68e5160..0331a6d 100644
--- a/meld/vc/_vc.py
+++ b/meld/vc/_vc.py
@@ -79,7 +79,7 @@ class Vc(object):
         if self.VC_ROOT_WALK:
             self.root = self.find_repo_root(location)
         else:
-            self.root = self.is_repo_root(location)
+            self.root = self.check_repo_root(location)
 
     def commit_command(self, message):
         raise NotImplementedError()
@@ -98,15 +98,17 @@ class Vc(object):
     def patch_command(self, workdir):
         return ["patch","--strip=%i"%self.PATCH_STRIP_NUM,"--reverse","--directory=%s" % workdir]
 
-    def is_repo_root(self, location):
+    def check_repo_root(self, location):
         if not os.path.isdir(os.path.join(location, self.VC_DIR)):
             raise ValueError
         return location
 
     def find_repo_root(self, location):
         while True:
-            if os.path.isdir(os.path.join(location, self.VC_DIR)):
-                return location
+            try:
+                return self.check_repo_root(location)
+            except ValueError:
+                pass
             tmp = os.path.dirname(location)
             if tmp == location:
                 break
diff --git a/meld/vc/svk.py b/meld/vc/svk.py
index 435cc88..8112b6b 100644
--- a/meld/vc/svk.py
+++ b/meld/vc/svk.py
@@ -30,7 +30,7 @@ class Vc(svn.Vc):
     NAME = "SVK"
     PATCH_INDEX_RE = "^=== (.*)$"
 
-    def is_repo_root(self, location):
+    def check_repo_root(self, location):
         try:
             # `svk info` may be interactive. It can ask to create its repository, we
             # don't want that to happen, so provide the right answer with `text="n"`



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]