diff cmdutil.py @ 257:ffccf0080e54

Move wrappers for hg commands to their own module.
author Augie Fackler <durin42@gmail.com>
date Fri, 10 Apr 2009 22:38:29 -0500
parents 7932d098cb5f
children f8f9a2993705
line wrap: on
line diff
--- a/cmdutil.py
+++ b/cmdutil.py
@@ -1,6 +1,7 @@
 #!/usr/bin/python
 import re
 import os
+import urllib
 
 from mercurial import util as hgutil
 
@@ -278,16 +279,19 @@ def commit_from_rev(ui, repo, rev_ctx, h
         else:
             raise
 
-def filecheck(path):
-    for x in ('locks', 'hooks', 'format', 'db', ):
-        if not os.path.exists(os.path.join(path, x)):
-            return False
     return True
 
+def islocalrepo(url):
+    if not url.startswith('file:///'):
+        return False
+    path = urllib.unquote(url[len('file://'):])
+    while '/' in path:
+        if reduce(lambda x,y: x and y,
+                  map(lambda p: os.path.exists(os.path.join(path, p)),
+                      ('hooks', 'format', 'db', ))):
+            return True
+        path = path.rsplit('/', 1)[0]
+    return False
 
 def issvnurl(url):
-    return url.startswith('svn+') or (
-        url.startswith('file://') and
-        reduce(lambda x,y: x and y,
-               map(lambda p: os.path.exists(os.path.join(url[7:], p)),
-                   ('locks', 'hooks', 'format', 'db', ))))
+    return url.startswith('svn') or islocalrepo(url)