[PATCH] Proof of concept: Use paths instead of the suggested Scheme extension

Mads Kiilerich mads at kiilerich.com
Fri Mar 13 09:45:20 CDT 2009


On 03/13/2009 03:36 PM, Hans Meine wrote:
> Interesting. I prefer the URL scheme syntax though.

I agree. That makes both implementation, use and performance better.

/Mads


Proof of concept: Use paths instead of the suggested Scheme extension

Usage example:
hg -v --config paths.selenic=http://www.selenic.com/repo/ clone 
selenic://hello /tmp/hello


diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -360,7 +360,14 @@

      def expandpath(self, loc, default=None):
          """Return repository location relative to cwd or from [paths]"""
-        if "://" in loc or os.path.isdir(os.path.join(loc, '.hg')):
+        if os.path.isdir(os.path.join(loc, '.hg')):
+            return loc
+
+        if "://" in loc:
+            scheme, rest = loc.split('://', 1)
+            schemepath = self.config("paths", scheme)
+            if schemepath:
+                return schemepath + rest
              return loc

          path = self.config("paths", loc)



More information about the Mercurial mailing list