Mercurial > hg
comparison mercurial/subrepo.py @ 21566:a01988cd9b61 stable
subrepo: make "_sanitize()" take absolute path to the root of subrepo
Before this patch, "hg update" doesn't sanitize ".hg/hgrc" in non-hg
subrepos correctly, if "hg update" is executed not at the root of the
parent repository.
"_sanitize()" takes relative path to subrepo from the root of the
parent repository, and passes it to "os.walk()". In this case,
"os.walk()" expects CWD to be equal to the root of the parent
repository.
So, "os.walk()" can't find specified path (or may scan unexpected
path), if CWD isn't equal to the root of the parent repository.
Non-hg subrepo under nested hg-subrepos may cause same problem, too:
CWD may be equal to the root of the outer most repository, or so.
This patch makes "_sanitize()" take absolute path to the root of
subrepo to sanitize correctly in such cases.
This patch doesn't normalize the path to hostile files as the one
relative to CWD (or the root of the outer most repository), to fix the
problem in the simple way suitable for "stable".
Normalizing should be done in the future: maybe as a part of the
migration to vfs.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Thu, 08 May 2014 19:03:00 +0900 |
parents | 7f7f634d073d |
children | 5900bc09e684 |
comparison
equal
deleted
inserted
replaced
21565:7f7f634d073d | 21566:a01988cd9b61 |
---|---|
1048 args.append('--force') | 1048 args.append('--force') |
1049 # The revision must be specified at the end of the URL to properly | 1049 # 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. | 1050 # update to a directory which has since been deleted and recreated. |
1051 args.append('%s@%s' % (state[0], state[1])) | 1051 args.append('%s@%s' % (state[0], state[1])) |
1052 status, err = self._svncommand(args, failok=True) | 1052 status, err = self._svncommand(args, failok=True) |
1053 _sanitize(self._ui, self._path) | 1053 _sanitize(self._ui, self._ctx._repo.wjoin(self._path)) |
1054 if not re.search('Checked out revision [0-9]+.', status): | 1054 if not re.search('Checked out revision [0-9]+.', status): |
1055 if ('is already a working copy for a different URL' in err | 1055 if ('is already a working copy for a different URL' in err |
1056 and (self._wcchanged()[:2] == (False, False))): | 1056 and (self._wcchanged()[:2] == (False, False))): |
1057 # obstructed but clean working copy, so just blow it away. | 1057 # obstructed but clean working copy, so just blow it away. |
1058 self.remove() | 1058 self.remove() |
1341 # the -f option will otherwise throw away files added for | 1341 # the -f option will otherwise throw away files added for |
1342 # commit, not just unmark them. | 1342 # commit, not just unmark them. |
1343 self._gitcommand(['reset', 'HEAD']) | 1343 self._gitcommand(['reset', 'HEAD']) |
1344 cmd.append('-f') | 1344 cmd.append('-f') |
1345 self._gitcommand(cmd + args) | 1345 self._gitcommand(cmd + args) |
1346 _sanitize(self._ui, self._path) | 1346 _sanitize(self._ui, self._abspath) |
1347 | 1347 |
1348 def rawcheckout(): | 1348 def rawcheckout(): |
1349 # no branch to checkout, check it out with no branch | 1349 # no branch to checkout, check it out with no branch |
1350 self._ui.warn(_('checking out detached HEAD in subrepo %s\n') % | 1350 self._ui.warn(_('checking out detached HEAD in subrepo %s\n') % |
1351 self._relpath) | 1351 self._relpath) |
1390 # Since we are only looking at branching at update, we need to | 1390 # Since we are only looking at branching at update, we need to |
1391 # detect this situation and perform this action lazily. | 1391 # detect this situation and perform this action lazily. |
1392 if tracking[remote] != self._gitcurrentbranch(): | 1392 if tracking[remote] != self._gitcurrentbranch(): |
1393 checkout([tracking[remote]]) | 1393 checkout([tracking[remote]]) |
1394 self._gitcommand(['merge', '--ff', remote]) | 1394 self._gitcommand(['merge', '--ff', remote]) |
1395 _sanitize(self._ui, self._path) | 1395 _sanitize(self._ui, self._abspath) |
1396 else: | 1396 else: |
1397 # a real merge would be required, just checkout the revision | 1397 # a real merge would be required, just checkout the revision |
1398 rawcheckout() | 1398 rawcheckout() |
1399 | 1399 |
1400 @annotatesubrepoerror | 1400 @annotatesubrepoerror |
1426 def mergefunc(): | 1426 def mergefunc(): |
1427 if base == revision: | 1427 if base == revision: |
1428 self.get(state) # fast forward merge | 1428 self.get(state) # fast forward merge |
1429 elif base != self._state[1]: | 1429 elif base != self._state[1]: |
1430 self._gitcommand(['merge', '--no-commit', revision]) | 1430 self._gitcommand(['merge', '--no-commit', revision]) |
1431 _sanitize(self._ui, self._path) | 1431 _sanitize(self._ui, self._abspath) |
1432 | 1432 |
1433 if self.dirty(): | 1433 if self.dirty(): |
1434 if self._gitstate() != revision: | 1434 if self._gitstate() != revision: |
1435 dirty = self._gitstate() == self._state[1] or code != 0 | 1435 dirty = self._gitstate() == self._state[1] or code != 0 |
1436 if _updateprompt(self._ui, self, dirty, | 1436 if _updateprompt(self._ui, self, dirty, |