Mercurial > hg > mercurial-source
comparison mercurial/subrepo.py @ 21567:5900bc09e684 stable
subrepo: avoid sanitizing ".hg/hgrc" in meta data area for non-hg subrepos
Before this patch, sanitizing ".hg/hgrc" scans directories and files
also in meta data area for non-hg subrepos: under ".svn" for
Subversion subrepo, for example.
This may cause not only performance impact (especially in large scale
subrepos) but also unexpected removing meta data files.
This patch avoids sanitizing ".hg/hgrc" in meta data area for non-hg
subrepos.
This patch stops checking "ignore" target at the first
(case-insensitive) appearance of it, because continuation of scanning
is meaningless in almost all cases.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Thu, 08 May 2014 19:03:00 +0900 |
parents | a01988cd9b61 |
children | 8dd17b19e722 |
comparison
equal
deleted
inserted
replaced
21566:a01988cd9b61 | 21567:5900bc09e684 |
---|---|
312 # chop off the .hg component to get the default path form | 312 # chop off the .hg component to get the default path form |
313 return os.path.dirname(repo.sharedpath) | 313 return os.path.dirname(repo.sharedpath) |
314 if abort: | 314 if abort: |
315 raise util.Abort(_("default path for subrepository not found")) | 315 raise util.Abort(_("default path for subrepository not found")) |
316 | 316 |
317 def _sanitize(ui, path): | 317 def _sanitize(ui, path, ignore): |
318 for dirname, dirs, names in os.walk(path): | 318 for dirname, dirs, names in os.walk(path): |
319 for i, d in enumerate(dirs): | |
320 if d.lower() == ignore: | |
321 del dirs[i] | |
322 break | |
319 if os.path.basename(dirname).lower() != '.hg': | 323 if os.path.basename(dirname).lower() != '.hg': |
320 continue | 324 continue |
321 for f in names: | 325 for f in names: |
322 if f.lower() == 'hgrc': | 326 if f.lower() == 'hgrc': |
323 ui.warn(_("warning: removing potentially hostile 'hgrc' " | 327 ui.warn(_("warning: removing potentially hostile 'hgrc' " |
1048 args.append('--force') | 1052 args.append('--force') |
1049 # The revision must be specified at the end of the URL to properly | 1053 # The revision must be specified at the end of the URL to properly |
1050 # update to a directory which has since been deleted and recreated. | 1054 # update to a directory which has since been deleted and recreated. |
1051 args.append('%s@%s' % (state[0], state[1])) | 1055 args.append('%s@%s' % (state[0], state[1])) |
1052 status, err = self._svncommand(args, failok=True) | 1056 status, err = self._svncommand(args, failok=True) |
1053 _sanitize(self._ui, self._ctx._repo.wjoin(self._path)) | 1057 _sanitize(self._ui, self._ctx._repo.wjoin(self._path), '.svn') |
1054 if not re.search('Checked out revision [0-9]+.', status): | 1058 if not re.search('Checked out revision [0-9]+.', status): |
1055 if ('is already a working copy for a different URL' in err | 1059 if ('is already a working copy for a different URL' in err |
1056 and (self._wcchanged()[:2] == (False, False))): | 1060 and (self._wcchanged()[:2] == (False, False))): |
1057 # obstructed but clean working copy, so just blow it away. | 1061 # obstructed but clean working copy, so just blow it away. |
1058 self.remove() | 1062 self.remove() |
1341 # the -f option will otherwise throw away files added for | 1345 # the -f option will otherwise throw away files added for |
1342 # commit, not just unmark them. | 1346 # commit, not just unmark them. |
1343 self._gitcommand(['reset', 'HEAD']) | 1347 self._gitcommand(['reset', 'HEAD']) |
1344 cmd.append('-f') | 1348 cmd.append('-f') |
1345 self._gitcommand(cmd + args) | 1349 self._gitcommand(cmd + args) |
1346 _sanitize(self._ui, self._abspath) | 1350 _sanitize(self._ui, self._abspath, '.git') |
1347 | 1351 |
1348 def rawcheckout(): | 1352 def rawcheckout(): |
1349 # no branch to checkout, check it out with no branch | 1353 # no branch to checkout, check it out with no branch |
1350 self._ui.warn(_('checking out detached HEAD in subrepo %s\n') % | 1354 self._ui.warn(_('checking out detached HEAD in subrepo %s\n') % |
1351 self._relpath) | 1355 self._relpath) |
1390 # Since we are only looking at branching at update, we need to | 1394 # Since we are only looking at branching at update, we need to |
1391 # detect this situation and perform this action lazily. | 1395 # detect this situation and perform this action lazily. |
1392 if tracking[remote] != self._gitcurrentbranch(): | 1396 if tracking[remote] != self._gitcurrentbranch(): |
1393 checkout([tracking[remote]]) | 1397 checkout([tracking[remote]]) |
1394 self._gitcommand(['merge', '--ff', remote]) | 1398 self._gitcommand(['merge', '--ff', remote]) |
1395 _sanitize(self._ui, self._abspath) | 1399 _sanitize(self._ui, self._abspath, '.git') |
1396 else: | 1400 else: |
1397 # a real merge would be required, just checkout the revision | 1401 # a real merge would be required, just checkout the revision |
1398 rawcheckout() | 1402 rawcheckout() |
1399 | 1403 |
1400 @annotatesubrepoerror | 1404 @annotatesubrepoerror |
1426 def mergefunc(): | 1430 def mergefunc(): |
1427 if base == revision: | 1431 if base == revision: |
1428 self.get(state) # fast forward merge | 1432 self.get(state) # fast forward merge |
1429 elif base != self._state[1]: | 1433 elif base != self._state[1]: |
1430 self._gitcommand(['merge', '--no-commit', revision]) | 1434 self._gitcommand(['merge', '--no-commit', revision]) |
1431 _sanitize(self._ui, self._abspath) | 1435 _sanitize(self._ui, self._abspath, '.git') |
1432 | 1436 |
1433 if self.dirty(): | 1437 if self.dirty(): |
1434 if self._gitstate() != revision: | 1438 if self._gitstate() != revision: |
1435 dirty = self._gitstate() == self._state[1] or code != 0 | 1439 dirty = self._gitstate() == self._state[1] or code != 0 |
1436 if _updateprompt(self._ui, self, dirty, | 1440 if _updateprompt(self._ui, self, dirty, |