comparison 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
comparison
equal deleted inserted replaced
20102:04eaa8eec6a0 20108:af12f58e2aa0
311 # chop off the .hg component to get the default path form 311 # chop off the .hg component to get the default path form
312 return os.path.dirname(repo.sharedpath) 312 return os.path.dirname(repo.sharedpath)
313 if abort: 313 if abort:
314 raise util.Abort(_("default path for subrepository not found")) 314 raise util.Abort(_("default path for subrepository not found"))
315 315
316 def _sanitize(ui, path):
317 def v(arg, dirname, names):
318 if os.path.basename(dirname).lower() != '.hg':
319 return
320 for f in names:
321 if f.lower() == 'hgrc':
322 ui.warn(
323 _("warning: removing potentially hostile .hg/hgrc in '%s'"
324 % path))
325 os.unlink(os.path.join(dirname, f))
326 os.walk(path, v, None)
327
316 def itersubrepos(ctx1, ctx2): 328 def itersubrepos(ctx1, ctx2):
317 """find subrepos in ctx1 or ctx2""" 329 """find subrepos in ctx1 or ctx2"""
318 # Create a (subpath, ctx) mapping where we prefer subpaths from 330 # Create a (subpath, ctx) mapping where we prefer subpaths from
319 # ctx1. The subpaths from ctx2 are important when the .hgsub file 331 # ctx1. The subpaths from ctx2 are important when the .hgsub file
320 # has been modified (in ctx2) but not yet committed (in ctx1). 332 # has been modified (in ctx2) but not yet committed (in ctx1).
987 args.append('--force') 999 args.append('--force')
988 # The revision must be specified at the end of the URL to properly 1000 # The revision must be specified at the end of the URL to properly
989 # update to a directory which has since been deleted and recreated. 1001 # update to a directory which has since been deleted and recreated.
990 args.append('%s@%s' % (state[0], state[1])) 1002 args.append('%s@%s' % (state[0], state[1]))
991 status, err = self._svncommand(args, failok=True) 1003 status, err = self._svncommand(args, failok=True)
1004 _sanitize(self._ui, self._path)
992 if not re.search('Checked out revision [0-9]+.', status): 1005 if not re.search('Checked out revision [0-9]+.', status):
993 if ('is already a working copy for a different URL' in err 1006 if ('is already a working copy for a different URL' in err
994 and (self._wcchanged()[:2] == (False, False))): 1007 and (self._wcchanged()[:2] == (False, False))):
995 # obstructed but clean working copy, so just blow it away. 1008 # obstructed but clean working copy, so just blow it away.
996 self.remove() 1009 self.remove()
1247 # the -f option will otherwise throw away files added for 1260 # the -f option will otherwise throw away files added for
1248 # commit, not just unmark them. 1261 # commit, not just unmark them.
1249 self._gitcommand(['reset', 'HEAD']) 1262 self._gitcommand(['reset', 'HEAD'])
1250 cmd.append('-f') 1263 cmd.append('-f')
1251 self._gitcommand(cmd + args) 1264 self._gitcommand(cmd + args)
1265 _sanitize(self._ui, self._path)
1252 1266
1253 def rawcheckout(): 1267 def rawcheckout():
1254 # no branch to checkout, check it out with no branch 1268 # no branch to checkout, check it out with no branch
1255 self._ui.warn(_('checking out detached HEAD in subrepo %s\n') % 1269 self._ui.warn(_('checking out detached HEAD in subrepo %s\n') %
1256 self._relpath) 1270 self._relpath)
1330 def mergefunc(): 1344 def mergefunc():
1331 if base == revision: 1345 if base == revision:
1332 self.get(state) # fast forward merge 1346 self.get(state) # fast forward merge
1333 elif base != self._state[1]: 1347 elif base != self._state[1]:
1334 self._gitcommand(['merge', '--no-commit', revision]) 1348 self._gitcommand(['merge', '--no-commit', revision])
1349 _sanitize(self._ui, self._path)
1335 1350
1336 if self.dirty(): 1351 if self.dirty():
1337 if self._gitstate() != revision: 1352 if self._gitstate() != revision:
1338 dirty = self._gitstate() == self._state[1] or code != 0 1353 dirty = self._gitstate() == self._state[1] or code != 0
1339 if _updateprompt(self._ui, self, dirty, 1354 if _updateprompt(self._ui, self, dirty,