diff -r 32601b0b74c0 -r 652e07debf10 mercurial/subrepo.py --- a/mercurial/subrepo.py Sat Mar 08 19:02:39 2014 +1100 +++ b/mercurial/subrepo.py Tue May 27 17:41:20 2014 -0700 @@ -277,8 +277,7 @@ parent = repo while util.safehasattr(parent, '_subparent'): parent = parent._subparent - p = parent.root.rstrip(os.sep) - return repo.root[len(p) + 1:] + return repo.root[len(pathutil.normasprefix(parent.root)):] def subrelpath(sub): """return path to this subrepo as seen from outermost repo""" @@ -315,17 +314,19 @@ if abort: raise util.Abort(_("default path for subrepository not found")) -def _sanitize(ui, path): - def v(arg, dirname, names): +def _sanitize(ui, path, ignore): + for dirname, dirs, names in os.walk(path): + for i, d in enumerate(dirs): + if d.lower() == ignore: + del dirs[i] + break if os.path.basename(dirname).lower() != '.hg': - return + continue for f in names: if f.lower() == 'hgrc': - ui.warn( - _("warning: removing potentially hostile .hg/hgrc in '%s'") - % path) + ui.warn(_("warning: removing potentially hostile 'hgrc' " + "in '%s'\n") % dirname) os.unlink(os.path.join(dirname, f)) - os.walk(path, v, None) def subrepo(ctx, path): """return instance of the right subrepo class for subrepo in path""" @@ -1059,7 +1060,7 @@ # update to a directory which has since been deleted and recreated. args.append('%s@%s' % (state[0], state[1])) status, err = self._svncommand(args, failok=True) - _sanitize(self._ui, self._path) + _sanitize(self._ui, self._ctx._repo.wjoin(self._path), '.svn') if not re.search('Checked out revision [0-9]+.', status): if ('is already a working copy for a different URL' in err and (self._wcchanged()[:2] == (False, False))): @@ -1352,7 +1353,7 @@ self._gitcommand(['reset', 'HEAD']) cmd.append('-f') self._gitcommand(cmd + args) - _sanitize(self._ui, self._path) + _sanitize(self._ui, self._abspath, '.git') def rawcheckout(): # no branch to checkout, check it out with no branch @@ -1401,6 +1402,7 @@ if tracking[remote] != self._gitcurrentbranch(): checkout([tracking[remote]]) self._gitcommand(['merge', '--ff', remote]) + _sanitize(self._ui, self._abspath, '.git') else: # a real merge would be required, just checkout the revision rawcheckout() @@ -1436,7 +1438,7 @@ self.get(state) # fast forward merge elif base != self._state[1]: self._gitcommand(['merge', '--no-commit', revision]) - _sanitize(self._ui, self._path) + _sanitize(self._ui, self._abspath, '.git') if self.dirty(): if self._gitstate() != revision: