mercurial/subrepo.py
changeset 14052 ecaa78594983
parent 14049 92db9667d15a
parent 14050 9e8a9d45945c
child 14076 924c82157d46
--- a/mercurial/subrepo.py	Sat Apr 30 03:00:38 2011 -0500
+++ b/mercurial/subrepo.py	Sat Apr 30 03:44:31 2011 -0500
@@ -10,6 +10,7 @@
 from i18n import _
 import config, scmutil, util, node, error, cmdutil, url, bookmarks
 hg = None
+propertycache = util.propertycache
 
 nullstate = ('', '', 'empty')
 
@@ -511,7 +512,6 @@
         self._ui = ctx._repo.ui
 
     def _svncommand(self, commands, filename=''):
-        path = os.path.join(self._ctx._repo.origroot, self._path, filename)
         cmd = ['svn']
         # Starting in svn 1.5 --non-interactive is a global flag
         # instead of being per-command, but we need to support 1.4 so
@@ -521,7 +521,9 @@
             commands[0] in ('update', 'checkout', 'commit')):
             cmd.append('--non-interactive')
         cmd.extend(commands)
-        cmd.append(path)
+        if filename is not None:
+            path = os.path.join(self._ctx._repo.origroot, self._path, filename)
+            cmd.append(path)
         env = dict(os.environ)
         # Avoid localized output, preserve current locale for everything else.
         env['LC_MESSAGES'] = 'C'
@@ -534,6 +536,14 @@
             raise util.Abort(stderr)
         return stdout
 
+    @propertycache
+    def _svnversion(self):
+        output = self._svncommand(['--version'], filename=None)
+        m = re.search(r'^svn,\s+version\s+(\d+)\.(\d+)', output)
+        if not m:
+            raise util.Abort(_('cannot retrieve svn tool version'))
+        return (int(m.group(1)), int(m.group(2)))
+
     def _wcrevs(self):
         # Get the working directory revision as well as the last
         # commit revision so we can compare the subrepo state with
@@ -628,7 +638,11 @@
     def get(self, state, overwrite=False):
         if overwrite:
             self._svncommand(['revert', '--recursive'])
-        status = self._svncommand(['checkout', state[0], '--revision', state[1]])
+        args = ['checkout']
+        if self._svnversion >= (1, 5):
+            args.append('--force')
+        args.extend([state[0], '--revision', state[1]])
+        status = self._svncommand(args)
         if not re.search('Checked out revision [0-9]+.', status):
             raise util.Abort(status.splitlines()[-1])
         self._ui.status(status)