From 3d7d9889f6c2a09fcc94fdb48a38c9612b0b838b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 15 Nov 2007 22:57:33 +0100 Subject: [PATCH] Give proper error when revspec is used against non-svn branch. --- README | 3 +-- revspec.py | 13 ++++++++++++- tests/test_revspec.py | 8 +++++++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/README b/README index e561edf7..3107fed8 100644 --- a/README +++ b/README @@ -132,8 +132,7 @@ Features held back by Subversion: information in Subversion, something which the Subversion folks are working on at the moment (see https://svn.collab.net/repos/svn/branches/merge-tracking). - Might require cherry-picking support in Bazaar (or at least the ability - to know about cherry picks). + Requires tracking cherry-picking support in Bazaar: Spec at https://launchpad.net/products/bzr/+spec/bzr-cpick-data diff --git a/revspec.py b/revspec.py index 43725527..d5447b29 100644 --- a/revspec.py +++ b/revspec.py @@ -15,16 +15,27 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """Custom revision specifier for Subversion.""" -from bzrlib.errors import InvalidRevisionSpec +from bzrlib.errors import BzrError, InvalidRevisionSpec from bzrlib.revisionspec import RevisionSpec, RevisionInfo class RevisionSpec_svn(RevisionSpec): """Selects a revision using a Subversion revision number.""" + + help_txt = """Selects a revision using a Subversion revision number (revno). + + Subversion revision numbers are per-repository whereas Bazaar revision + numbers are per-branch. This revision specifier allows specifying + a Subversion revision number. + + This only works directly against Subversion branches. + """ prefix = 'svn:' def _match_on(self, branch, revs): loc = self.spec.find(':') + if not hasattr(branch.repository, 'uuid'): + raise BzrError("the svn: revisionspec can only be used with Subversion branches") try: return RevisionInfo.from_revision_id(branch, branch.generate_revision_id(int(self.spec[loc+1:])), branch.revision_history()) except ValueError: diff --git a/tests/test_revspec.py b/tests/test_revspec.py index 1bcc17ec..c24f8225 100644 --- a/tests/test_revspec.py +++ b/tests/test_revspec.py @@ -18,7 +18,8 @@ Tests for revision specificiers. """ from bzrlib.branch import Branch -from bzrlib.errors import InvalidRevisionSpec +from bzrlib.bzrdir import BzrDir +from bzrlib.errors import BzrError, InvalidRevisionSpec from bzrlib.revisionspec import RevisionSpec, RevisionInfo from bzrlib.tests import TestCase @@ -63,3 +64,8 @@ class TestRevSpecsBySubversion(TestCaseWithSubversionRepository): branch = Branch.open(repos_url) self.assertRaises(InvalidRevisionSpec, revspec._match_on, branch, None) + + def test_non_svn_branch(self): + revspec = RevisionSpec.from_string("svn:0") + branch = BzrDir.create_standalone_workingtree("a").branch + self.assertRaises(BzrError, revspec._match_on, branch, None) -- 2.34.1