changeset 15149:eaec9cf91aea

subrepo: refactor state function
author Martin Geisler <mg@aragost.com>
date Thu, 22 Sep 2011 14:39:49 +0200
parents 510184e5a09e
children 91dc8878f888
files mercurial/subrepo.py
diffstat 1 files changed, 11 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/subrepo.py	Tue Sep 20 15:02:00 2011 -0500
+++ b/mercurial/subrepo.py	Thu Sep 22 14:39:49 2011 +0200
@@ -50,15 +50,7 @@
             if err.errno != errno.ENOENT:
                 raise
 
-    state = {}
-    for path, src in p[''].items():
-        kind = 'hg'
-        if src.startswith('['):
-            if ']' not in src:
-                raise util.Abort(_('missing ] in subrepo source'))
-            kind, src = src.split(']', 1)
-            kind = kind[1:]
-
+    def remap(src):
         for pattern, repl in p.items('subpaths'):
             # Turn r'C:\foo\bar' into r'C:\\foo\\bar' since re.sub
             # does a string decode.
@@ -72,7 +64,17 @@
             except re.error, e:
                 raise util.Abort(_("bad subrepository pattern in %s: %s")
                                  % (p.source('subpaths', pattern), e))
+        return src
 
+    state = {}
+    for path, src in p[''].items():
+        kind = 'hg'
+        if src.startswith('['):
+            if ']' not in src:
+                raise util.Abort(_('missing ] in subrepo source'))
+            kind, src = src.split(']', 1)
+            kind = kind[1:]
+        src = remap(src)
         state[path] = (src.strip(), rev.get(path, ''), kind)
 
     return state