##// END OF EJS Templates
subrepo: sanitize non-hg subrepos
Matt Mackall -
r20104:224e9607 stable
parent child Browse files
Show More
@@ -312,6 +312,18 def _abssource(repo, push=False, abort=T
312 if abort:
312 if abort:
313 raise util.Abort(_("default path for subrepository not found"))
313 raise util.Abort(_("default path for subrepository not found"))
314
314
315 def _sanitize(ui, path):
316 def v(arg, dirname, names):
317 if os.path.basename(dirname).lower() != '.hg':
318 return
319 for f in names:
320 if f.lower() == 'hgrc':
321 ui.warn(
322 _("warning: removing potentially hostile .hg/hgrc in '%s'"
323 % path))
324 os.unlink(os.path.join(dirname, f))
325 os.walk(path, v, None)
326
315 def itersubrepos(ctx1, ctx2):
327 def itersubrepos(ctx1, ctx2):
316 """find subrepos in ctx1 or ctx2"""
328 """find subrepos in ctx1 or ctx2"""
317 # Create a (subpath, ctx) mapping where we prefer subpaths from
329 # Create a (subpath, ctx) mapping where we prefer subpaths from
@@ -988,6 +1000,7 class svnsubrepo(abstractsubrepo):
988 # update to a directory which has since been deleted and recreated.
1000 # update to a directory which has since been deleted and recreated.
989 args.append('%s@%s' % (state[0], state[1]))
1001 args.append('%s@%s' % (state[0], state[1]))
990 status, err = self._svncommand(args, failok=True)
1002 status, err = self._svncommand(args, failok=True)
1003 _sanitize(self._ui, self._path)
991 if not re.search('Checked out revision [0-9]+.', status):
1004 if not re.search('Checked out revision [0-9]+.', status):
992 if ('is already a working copy for a different URL' in err
1005 if ('is already a working copy for a different URL' in err
993 and (self._wcchanged()[:2] == (False, False))):
1006 and (self._wcchanged()[:2] == (False, False))):
@@ -1248,6 +1261,7 class gitsubrepo(abstractsubrepo):
1248 self._gitcommand(['reset', 'HEAD'])
1261 self._gitcommand(['reset', 'HEAD'])
1249 cmd.append('-f')
1262 cmd.append('-f')
1250 self._gitcommand(cmd + args)
1263 self._gitcommand(cmd + args)
1264 _sanitize(self._ui, self._path)
1251
1265
1252 def rawcheckout():
1266 def rawcheckout():
1253 # no branch to checkout, check it out with no branch
1267 # no branch to checkout, check it out with no branch
@@ -1331,6 +1345,7 class gitsubrepo(abstractsubrepo):
1331 self.get(state) # fast forward merge
1345 self.get(state) # fast forward merge
1332 elif base != self._state[1]:
1346 elif base != self._state[1]:
1333 self._gitcommand(['merge', '--no-commit', revision])
1347 self._gitcommand(['merge', '--no-commit', revision])
1348 _sanitize(self._ui, self._path)
1334
1349
1335 if self.dirty():
1350 if self.dirty():
1336 if self._gitstate() != revision:
1351 if self._gitstate() != revision:
General Comments 0
You need to be logged in to leave comments. Login now