Show More
@@ -10,6 +10,7 b' import stat, subprocess, tarfile' | |||
|
10 | 10 | from i18n import _ |
|
11 | 11 | import config, util, node, error, cmdutil |
|
12 | 12 | hg = None |
|
13 | propertycache = util.propertycache | |
|
13 | 14 | |
|
14 | 15 | nullstate = ('', '', 'empty') |
|
15 | 16 | |
@@ -521,7 +522,6 b' class svnsubrepo(abstractsubrepo):' | |||
|
521 | 522 | self._ui = ctx._repo.ui |
|
522 | 523 | |
|
523 | 524 | def _svncommand(self, commands, filename=''): |
|
524 | path = os.path.join(self._ctx._repo.origroot, self._path, filename) | |
|
525 | 525 | cmd = ['svn'] |
|
526 | 526 | # Starting in svn 1.5 --non-interactive is a global flag |
|
527 | 527 | # instead of being per-command, but we need to support 1.4 so |
@@ -531,7 +531,9 b' class svnsubrepo(abstractsubrepo):' | |||
|
531 | 531 | commands[0] in ('update', 'checkout', 'commit')): |
|
532 | 532 | cmd.append('--non-interactive') |
|
533 | 533 | cmd.extend(commands) |
|
534 | cmd.append(path) | |
|
534 | if filename is not None: | |
|
535 | path = os.path.join(self._ctx._repo.origroot, self._path, filename) | |
|
536 | cmd.append(path) | |
|
535 | 537 | env = dict(os.environ) |
|
536 | 538 | # Avoid localized output, preserve current locale for everything else. |
|
537 | 539 | env['LC_MESSAGES'] = 'C' |
@@ -544,6 +546,14 b' class svnsubrepo(abstractsubrepo):' | |||
|
544 | 546 | raise util.Abort(stderr) |
|
545 | 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 | 557 | def _wcrevs(self): |
|
548 | 558 | # Get the working directory revision as well as the last |
|
549 | 559 | # commit revision so we can compare the subrepo state with |
@@ -638,7 +648,11 b' class svnsubrepo(abstractsubrepo):' | |||
|
638 | 648 | def get(self, state, overwrite=False): |
|
639 | 649 | if overwrite: |
|
640 | 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 | 656 | if not re.search('Checked out revision [0-9]+.', status): |
|
643 | 657 | raise util.Abort(status.splitlines()[-1]) |
|
644 | 658 | self._ui.status(status) |
@@ -121,6 +121,15 b' def has_docutils():' | |||
|
121 | 121 | except ImportError: |
|
122 | 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 | 133 | def has_svn(): |
|
125 | 134 | return matchoutput('svn --version 2>&1', r'^svn, version') and \ |
|
126 | 135 | matchoutput('svnadmin --version 2>&1', r'^svnadmin, version') |
@@ -204,6 +213,7 b' checks = {' | |||
|
204 | 213 | "pygments": (has_pygments, "Pygments source highlighting library"), |
|
205 | 214 | "ssl": (has_ssl, "python >= 2.6 ssl module and python OpenSSL"), |
|
206 | 215 | "svn": (has_svn, "subversion client and admin tools"), |
|
216 | "svn15": (has_svn15, "subversion client and admin tools >= 1.5"), | |
|
207 | 217 | "svn-bindings": (has_svn_bindings, "subversion python bindings"), |
|
208 | 218 | "symlink": (has_symlink, "symbolic links"), |
|
209 | 219 | "tla": (has_tla, "GNU Arch tla client"), |
@@ -438,3 +438,54 b' Test subrepo already at intended revisio' | |||
|
438 | 438 | $ svnversion |
|
439 | 439 | 2 |
|
440 | 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