comparison mercurial/subrepo.py @ 24724:95eb067b2b5e

subrepo: pass wvfs to _sanitize instead of absolute path to a subrepository As a preparation for vfs migration of "_sanitize()", this patch passes "wvfs" to "_sanitize()" and use "wvfs.base" instead of absolute path to a subrepository.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Sat, 11 Apr 2015 23:00:04 +0900
parents 419528cb05b6
children 747748766421
comparison
equal deleted inserted replaced
24723:467a33142425 24724:95eb067b2b5e
300 # chop off the .hg component to get the default path form 300 # chop off the .hg component to get the default path form
301 return os.path.dirname(repo.sharedpath) 301 return os.path.dirname(repo.sharedpath)
302 if abort: 302 if abort:
303 raise util.Abort(_("default path for subrepository not found")) 303 raise util.Abort(_("default path for subrepository not found"))
304 304
305 def _sanitize(ui, path, ignore): 305 def _sanitize(ui, vfs, ignore):
306 for dirname, dirs, names in os.walk(path): 306 for dirname, dirs, names in os.walk(vfs.base):
307 for i, d in enumerate(dirs): 307 for i, d in enumerate(dirs):
308 if d.lower() == ignore: 308 if d.lower() == ignore:
309 del dirs[i] 309 del dirs[i]
310 break 310 break
311 if os.path.basename(dirname).lower() != '.hg': 311 if os.path.basename(dirname).lower() != '.hg':
1130 args.append('--force') 1130 args.append('--force')
1131 # The revision must be specified at the end of the URL to properly 1131 # The revision must be specified at the end of the URL to properly
1132 # update to a directory which has since been deleted and recreated. 1132 # update to a directory which has since been deleted and recreated.
1133 args.append('%s@%s' % (state[0], state[1])) 1133 args.append('%s@%s' % (state[0], state[1]))
1134 status, err = self._svncommand(args, failok=True) 1134 status, err = self._svncommand(args, failok=True)
1135 _sanitize(self.ui, self._ctx.repo().wjoin(self._path), '.svn') 1135 _sanitize(self.ui, self.wvfs, '.svn')
1136 if not re.search('Checked out revision [0-9]+.', status): 1136 if not re.search('Checked out revision [0-9]+.', status):
1137 if ('is already a working copy for a different URL' in err 1137 if ('is already a working copy for a different URL' in err
1138 and (self._wcchanged()[:2] == (False, False))): 1138 and (self._wcchanged()[:2] == (False, False))):
1139 # obstructed but clean working copy, so just blow it away. 1139 # obstructed but clean working copy, so just blow it away.
1140 self.remove() 1140 self.remove()
1431 # the -f option will otherwise throw away files added for 1431 # the -f option will otherwise throw away files added for
1432 # commit, not just unmark them. 1432 # commit, not just unmark them.
1433 self._gitcommand(['reset', 'HEAD']) 1433 self._gitcommand(['reset', 'HEAD'])
1434 cmd.append('-f') 1434 cmd.append('-f')
1435 self._gitcommand(cmd + args) 1435 self._gitcommand(cmd + args)
1436 _sanitize(self.ui, self._abspath, '.git') 1436 _sanitize(self.ui, self.wvfs, '.git')
1437 1437
1438 def rawcheckout(): 1438 def rawcheckout():
1439 # no branch to checkout, check it out with no branch 1439 # no branch to checkout, check it out with no branch
1440 self.ui.warn(_('checking out detached HEAD in subrepo %s\n') % 1440 self.ui.warn(_('checking out detached HEAD in subrepo %s\n') %
1441 self._relpath) 1441 self._relpath)
1480 # Since we are only looking at branching at update, we need to 1480 # Since we are only looking at branching at update, we need to
1481 # detect this situation and perform this action lazily. 1481 # detect this situation and perform this action lazily.
1482 if tracking[remote] != self._gitcurrentbranch(): 1482 if tracking[remote] != self._gitcurrentbranch():
1483 checkout([tracking[remote]]) 1483 checkout([tracking[remote]])
1484 self._gitcommand(['merge', '--ff', remote]) 1484 self._gitcommand(['merge', '--ff', remote])
1485 _sanitize(self.ui, self._abspath, '.git') 1485 _sanitize(self.ui, self.wvfs, '.git')
1486 else: 1486 else:
1487 # a real merge would be required, just checkout the revision 1487 # a real merge would be required, just checkout the revision
1488 rawcheckout() 1488 rawcheckout()
1489 1489
1490 @annotatesubrepoerror 1490 @annotatesubrepoerror
1516 def mergefunc(): 1516 def mergefunc():
1517 if base == revision: 1517 if base == revision:
1518 self.get(state) # fast forward merge 1518 self.get(state) # fast forward merge
1519 elif base != self._state[1]: 1519 elif base != self._state[1]:
1520 self._gitcommand(['merge', '--no-commit', revision]) 1520 self._gitcommand(['merge', '--no-commit', revision])
1521 _sanitize(self.ui, self._abspath, '.git') 1521 _sanitize(self.ui, self.wvfs, '.git')
1522 1522
1523 if self.dirty(): 1523 if self.dirty():
1524 if self._gitstate() != revision: 1524 if self._gitstate() != revision:
1525 dirty = self._gitstate() == self._state[1] or code != 0 1525 dirty = self._gitstate() == self._state[1] or code != 0
1526 if _updateprompt(self.ui, self, dirty, 1526 if _updateprompt(self.ui, self, dirty,