mercurial/subrepo.py
branchstable
changeset 20104 224e96078708
parent 19811 5e10d41e7b9c
child 20108 af12f58e2aa0
equal deleted inserted replaced
20103:b3483223f734 20104:224e96078708
   310             # chop off the .hg component to get the default path form
   310             # chop off the .hg component to get the default path form
   311             return os.path.dirname(repo.sharedpath)
   311             return os.path.dirname(repo.sharedpath)
   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
   318     # ctx1. The subpaths from ctx2 are important when the .hgsub file
   330     # ctx1. The subpaths from ctx2 are important when the .hgsub file
   319     # has been modified (in ctx2) but not yet committed (in ctx1).
   331     # has been modified (in ctx2) but not yet committed (in ctx1).
   986             args.append('--force')
   998             args.append('--force')
   987         # The revision must be specified at the end of the URL to properly
   999         # The revision must be specified at the end of the URL to properly
   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))):
   994                 # obstructed but clean working copy, so just blow it away.
  1007                 # obstructed but clean working copy, so just blow it away.
   995                 self.remove()
  1008                 self.remove()
  1246                 # the -f option will otherwise throw away files added for
  1259                 # the -f option will otherwise throw away files added for
  1247                 # commit, not just unmark them.
  1260                 # commit, not just unmark them.
  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
  1254             self._ui.warn(_('checking out detached HEAD in subrepo %s\n') %
  1268             self._ui.warn(_('checking out detached HEAD in subrepo %s\n') %
  1255                           self._relpath)
  1269                           self._relpath)
  1329         def mergefunc():
  1343         def mergefunc():
  1330             if base == revision:
  1344             if base == revision:
  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:
  1337                 dirty = self._gitstate() == self._state[1] or code != 0
  1352                 dirty = self._gitstate() == self._state[1] or code != 0
  1338                 if _updateprompt(self._ui, self, dirty,
  1353                 if _updateprompt(self._ui, self, dirty,