Show More
@@ -10,6 +10,7 b' import stat, subprocess, tarfile' | |||||
10 | from i18n import _ |
|
10 | from i18n import _ | |
11 | import config, util, node, error, cmdutil |
|
11 | import config, util, node, error, cmdutil | |
12 | hg = None |
|
12 | hg = None | |
|
13 | propertycache = util.propertycache | |||
13 |
|
14 | |||
14 | nullstate = ('', '', 'empty') |
|
15 | nullstate = ('', '', 'empty') | |
15 |
|
16 | |||
@@ -521,7 +522,6 b' class svnsubrepo(abstractsubrepo):' | |||||
521 | self._ui = ctx._repo.ui |
|
522 | self._ui = ctx._repo.ui | |
522 |
|
523 | |||
523 | def _svncommand(self, commands, filename=''): |
|
524 | def _svncommand(self, commands, filename=''): | |
524 | path = os.path.join(self._ctx._repo.origroot, self._path, filename) |
|
|||
525 | cmd = ['svn'] |
|
525 | cmd = ['svn'] | |
526 | # Starting in svn 1.5 --non-interactive is a global flag |
|
526 | # Starting in svn 1.5 --non-interactive is a global flag | |
527 | # instead of being per-command, but we need to support 1.4 so |
|
527 | # instead of being per-command, but we need to support 1.4 so | |
@@ -531,6 +531,8 b' class svnsubrepo(abstractsubrepo):' | |||||
531 | commands[0] in ('update', 'checkout', 'commit')): |
|
531 | commands[0] in ('update', 'checkout', 'commit')): | |
532 | cmd.append('--non-interactive') |
|
532 | cmd.append('--non-interactive') | |
533 | cmd.extend(commands) |
|
533 | cmd.extend(commands) | |
|
534 | if filename is not None: | |||
|
535 | path = os.path.join(self._ctx._repo.origroot, self._path, filename) | |||
534 | cmd.append(path) |
|
536 | cmd.append(path) | |
535 | env = dict(os.environ) |
|
537 | env = dict(os.environ) | |
536 | # Avoid localized output, preserve current locale for everything else. |
|
538 | # Avoid localized output, preserve current locale for everything else. | |
@@ -544,6 +546,14 b' class svnsubrepo(abstractsubrepo):' | |||||
544 | raise util.Abort(stderr) |
|
546 | raise util.Abort(stderr) | |
545 | return stdout |
|
547 | return stdout | |
546 |
|
548 | |||
|
549 | @propertycache | |||
|
550 | def _svnversion(self): | |||
|
551 | output = self._svncommand(['--version'], filename=None) | |||
|
552 | m = re.search(r'^svn,\s+version\s+(\d+)\.(\d+)', output) | |||
|
553 | if not m: | |||
|
554 | raise util.Abort(_('cannot retrieve svn tool version')) | |||
|
555 | return (int(m.group(1)), int(m.group(2))) | |||
|
556 | ||||
547 | def _wcrevs(self): |
|
557 | def _wcrevs(self): | |
548 | # Get the working directory revision as well as the last |
|
558 | # Get the working directory revision as well as the last | |
549 | # commit revision so we can compare the subrepo state with |
|
559 | # commit revision so we can compare the subrepo state with | |
@@ -638,7 +648,11 b' class svnsubrepo(abstractsubrepo):' | |||||
638 | def get(self, state, overwrite=False): |
|
648 | def get(self, state, overwrite=False): | |
639 | if overwrite: |
|
649 | if overwrite: | |
640 | self._svncommand(['revert', '--recursive']) |
|
650 | self._svncommand(['revert', '--recursive']) | |
641 | status = self._svncommand(['checkout', state[0], '--revision', state[1]]) |
|
651 | args = ['checkout'] | |
|
652 | if self._svnversion >= (1, 5): | |||
|
653 | args.append('--force') | |||
|
654 | args.extend([state[0], '--revision', state[1]]) | |||
|
655 | status = self._svncommand(args) | |||
642 | if not re.search('Checked out revision [0-9]+.', status): |
|
656 | if not re.search('Checked out revision [0-9]+.', status): | |
643 | raise util.Abort(status.splitlines()[-1]) |
|
657 | raise util.Abort(status.splitlines()[-1]) | |
644 | self._ui.status(status) |
|
658 | self._ui.status(status) |
@@ -121,6 +121,15 b' def has_docutils():' | |||||
121 | except ImportError: |
|
121 | except ImportError: | |
122 | return False |
|
122 | return False | |
123 |
|
123 | |||
|
124 | def getsvnversion(): | |||
|
125 | m = matchoutput('svn --version 2>&1', r'^svn,\s+version\s+(\d+)\.(\d+)') | |||
|
126 | if not m: | |||
|
127 | return (0, 0) | |||
|
128 | return (int(m.group(1)), int(m.group(2))) | |||
|
129 | ||||
|
130 | def has_svn15(): | |||
|
131 | return getsvnversion() >= (1, 5) | |||
|
132 | ||||
124 | def has_svn(): |
|
133 | def has_svn(): | |
125 | return matchoutput('svn --version 2>&1', r'^svn, version') and \ |
|
134 | return matchoutput('svn --version 2>&1', r'^svn, version') and \ | |
126 | matchoutput('svnadmin --version 2>&1', r'^svnadmin, version') |
|
135 | matchoutput('svnadmin --version 2>&1', r'^svnadmin, version') | |
@@ -204,6 +213,7 b' checks = {' | |||||
204 | "pygments": (has_pygments, "Pygments source highlighting library"), |
|
213 | "pygments": (has_pygments, "Pygments source highlighting library"), | |
205 | "ssl": (has_ssl, "python >= 2.6 ssl module and python OpenSSL"), |
|
214 | "ssl": (has_ssl, "python >= 2.6 ssl module and python OpenSSL"), | |
206 | "svn": (has_svn, "subversion client and admin tools"), |
|
215 | "svn": (has_svn, "subversion client and admin tools"), | |
|
216 | "svn15": (has_svn15, "subversion client and admin tools >= 1.5"), | |||
207 | "svn-bindings": (has_svn_bindings, "subversion python bindings"), |
|
217 | "svn-bindings": (has_svn_bindings, "subversion python bindings"), | |
208 | "symlink": (has_symlink, "symbolic links"), |
|
218 | "symlink": (has_symlink, "symbolic links"), | |
209 | "tla": (has_tla, "GNU Arch tla client"), |
|
219 | "tla": (has_tla, "GNU Arch tla client"), |
@@ -438,3 +438,54 b' Test subrepo already at intended revisio' | |||||
438 | $ svnversion |
|
438 | $ svnversion | |
439 | 2 |
|
439 | 2 | |
440 | $ cd .. |
|
440 | $ cd .. | |
|
441 | ||||
|
442 | Test case where subversion would fail to update the subrepo because there | |||
|
443 | are unknown directories being replaced by tracked ones (happens with rebase). | |||
|
444 | ||||
|
445 | $ cd $WCROOT/src | |||
|
446 | $ mkdir dir | |||
|
447 | $ echo epsilon.py > dir/epsilon.py | |||
|
448 | $ svn add dir | |||
|
449 | A dir | |||
|
450 | A dir/epsilon.py | |||
|
451 | $ svn ci -m 'Add dir/epsilon.py' | |||
|
452 | Adding src/dir | |||
|
453 | Adding src/dir/epsilon.py | |||
|
454 | Transmitting file data . | |||
|
455 | Committed revision 6. | |||
|
456 | $ cd ../.. | |||
|
457 | $ hg init rebaserepo | |||
|
458 | $ cd rebaserepo | |||
|
459 | $ svn co -r5 --quiet "$SVNREPO"/src s | |||
|
460 | $ echo "s = [svn] $SVNREPO/src" >> .hgsub | |||
|
461 | $ hg add .hgsub | |||
|
462 | $ hg ci -m addsub | |||
|
463 | committing subrepository s | |||
|
464 | $ echo a > a | |||
|
465 | $ hg ci -Am adda | |||
|
466 | adding a | |||
|
467 | $ hg up 0 | |||
|
468 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |||
|
469 | $ svn up -r6 s | |||
|
470 | A s/dir | |||
|
471 | A s/dir/epsilon.py | |||
|
472 | ||||
|
473 | Fetching external item into 's/externals' | |||
|
474 | Updated external to revision 1. | |||
|
475 | ||||
|
476 | Updated to revision 6. | |||
|
477 | $ hg ci -m updatesub | |||
|
478 | committing subrepository s | |||
|
479 | created new head | |||
|
480 | $ echo pyc > s/dir/epsilon.pyc | |||
|
481 | $ hg up 1 | |||
|
482 | D $TESTTMP/rebaserepo/s/dir | |||
|
483 | ||||
|
484 | Fetching external item into '$TESTTMP/rebaserepo/s/externals' | |||
|
485 | Checked out external at revision 1. | |||
|
486 | ||||
|
487 | Checked out revision 5. | |||
|
488 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
489 | $ if "$TESTDIR/hghave" -q svn15; then | |||
|
490 | > hg up 2 >/dev/null 2>&1 || echo update failed | |||
|
491 | > fi |
General Comments 0
You need to be logged in to leave comments.
Login now