Mercurial > public > mercurial-scm > hg-stable
diff mercurial/subrepo.py @ 20108:af12f58e2aa0
merge with stable
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Mon, 25 Nov 2013 16:15:44 -0600 |
parents | f962870712da 224e96078708 |
children | 4c96c50ef937 |
line wrap: on
line diff
--- a/mercurial/subrepo.py Mon Nov 18 09:09:05 2013 -0800 +++ b/mercurial/subrepo.py Mon Nov 25 16:15:44 2013 -0600 @@ -313,6 +313,18 @@ if abort: raise util.Abort(_("default path for subrepository not found")) +def _sanitize(ui, path): + def v(arg, dirname, names): + if os.path.basename(dirname).lower() != '.hg': + return + for f in names: + if f.lower() == 'hgrc': + ui.warn( + _("warning: removing potentially hostile .hg/hgrc in '%s'" + % path)) + os.unlink(os.path.join(dirname, f)) + os.walk(path, v, None) + def itersubrepos(ctx1, ctx2): """find subrepos in ctx1 or ctx2""" # Create a (subpath, ctx) mapping where we prefer subpaths from @@ -989,6 +1001,7 @@ # update to a directory which has since been deleted and recreated. args.append('%s@%s' % (state[0], state[1])) status, err = self._svncommand(args, failok=True) + _sanitize(self._ui, self._path) if not re.search('Checked out revision [0-9]+.', status): if ('is already a working copy for a different URL' in err and (self._wcchanged()[:2] == (False, False))): @@ -1249,6 +1262,7 @@ self._gitcommand(['reset', 'HEAD']) cmd.append('-f') self._gitcommand(cmd + args) + _sanitize(self._ui, self._path) def rawcheckout(): # no branch to checkout, check it out with no branch @@ -1332,6 +1346,7 @@ self.get(state) # fast forward merge elif base != self._state[1]: self._gitcommand(['merge', '--no-commit', revision]) + _sanitize(self._ui, self._path) if self.dirty(): if self._gitstate() != revision: