Rev 792: Give proper error when revspec is used against non-svn branch. in file:///data/jelmer/bzr-svn/0.4/

Jelmer Vernooij jelmer at samba.org
Thu Nov 15 21:57:34 GMT 2007


At file:///data/jelmer/bzr-svn/0.4/

------------------------------------------------------------
revno: 792
revision-id:jelmer at samba.org-20071115215733-wirqr6dc6ooufd2p
parent: jelmer at samba.org-20071113232215-fjvnf2ul71iqjb1a
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4
timestamp: Thu 2007-11-15 22:57:33 +0100
message:
  Give proper error when revspec is used against non-svn branch.
modified:
  README                         README-20051120210643-bd274a2fef9aed6a
  revspec.py                     revspec.py-20071106211507-q4fz2en91yrmjjl8-1
  tests/test_revspec.py          test_revspec.py-20071111183646-0wohlrzaevdsr9ia-1
=== modified file 'README'
--- a/README	2007-11-11 19:16:06 +0000
+++ b/README	2007-11-15 21:57:33 +0000
@@ -132,8 +132,7 @@
   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
 

=== modified file 'revspec.py'
--- a/revspec.py	2007-11-11 19:15:40 +0000
+++ b/revspec.py	2007-11-15 21:57:33 +0000
@@ -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:

=== modified file 'tests/test_revspec.py'
--- a/tests/test_revspec.py	2007-11-11 19:15:40 +0000
+++ b/tests/test_revspec.py	2007-11-15 21:57:33 +0000
@@ -18,7 +18,8 @@
 """
 
 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 @@
         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)




More information about the bazaar-commits mailing list