[PATCH] schemes: url parts are counted from 1

Alexander Solovyov piranha at piranha.org.ua
Mon Dec 14 13:27:23 CST 2009


# HG changeset patch
# User Alexander Solovyov <piranha at piranha.org.ua>
# Date 1260818494 -7200
# Node ID 4fda90980dbfabd4d98878e4cf566ad0a4d99542
# Parent  fd6729805f44c0686abf0a4d59449284b2ff7dd6
schemes: url parts are counted from 1

diff --git a/hgext/schemes.py b/hgext/schemes.py
--- a/hgext/schemes.py
+++ b/hgext/schemes.py
@@ -64,7 +64,7 @@ class ShortRepository(object):
             parts = parts[:-1]
         else:
             tail = ''
-        context = dict((str(i), v) for i, v in enumerate(parts))
+        context = dict((str(i+1), v) for i, v in enumerate(parts))
         url = ''.join(self.templater.process(self.url, context)) + tail
         return hg._lookup(url).instance(ui, url, create)
 
diff --git a/tests/test-schemes b/tests/test-schemes
--- a/tests/test-schemes
+++ b/tests/test-schemes
@@ -6,6 +6,7 @@ schemes=
 
 [schemes]
 l = http://localhost:$HGPORT/
+parts = http://{1}:$HGPORT/
 EOF
 
 hg init test
@@ -18,5 +19,8 @@ cat hg.pid >> $DAEMON_PIDS
 
 hg incoming l://
 
+echo % check that {1} syntax works
+hg incoming parts://localhost
+
 echo % errors
 cat errors.log
diff --git a/tests/test-schemes.out b/tests/test-schemes.out
--- a/tests/test-schemes.out
+++ b/tests/test-schemes.out
@@ -2,4 +2,8 @@ adding a
 comparing with l://
 searching for changes
 no changes found
+% check that {1} syntax works
+comparing with parts://localhost
+searching for changes
+no changes found
 % errors


More information about the Mercurial-devel mailing list