changeset 30780:73ac9c2778be draft

subrepo: check that subrepo paths are valid (issue4363) This checks that proposed subrepo paths are valid using pathutil.pathauditor. This check is already done when creating a subrepo object in the subrepo.subrepo function, but I think this is too late and doesn't catch the case where a modified .hgsub has had new paths added but hasn't been committed yet. Moving this check earlier and catching the exception to provide a better error message both seem like improvements.
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Tue, 09 Sep 2014 12:20:41 -0400
parents 1d375f272c3d
children
files mercurial/subrepo.py
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -144,6 +144,12 @@
         if os.path.isfile(path):
             raise util.Abort(_('subrepository path is an existing file: %s')
                              % path)
+        try:
+            pathutil.pathauditor(ctx._repo.root)(path)
+        except util.Abort, e:
+            raise util.Abort(_('bad subrepository path; %s') % e.message,
+                             hint=e.hint)
+
         kind = 'hg'
         if src.startswith('['):
             if ']' not in src:
@@ -355,7 +361,6 @@
     from . import hg as h
     hg = h
 
-    pathutil.pathauditor(ctx.repo().root)(path)
     state = ctx.substate[path]
     if state[2] not in types:
         raise error.Abort(_('unknown subrepo type %s') % state[2])