Rev 3496: Fix bug #239933, use the right exception for -c0 in http://bzr.arbash-meinel.com/branches/bzr/jam-integration

John Arbash Meinel john at arbash-meinel.com
Mon Jun 16 00:09:00 BST 2008


At http://bzr.arbash-meinel.com/branches/bzr/jam-integration

------------------------------------------------------------
revno: 3496
revision-id: john at arbash-meinel.com-20080615230814-euzbbh2528vzi2d8
parent: pqm at pqm.ubuntu.com-20080612170229-8h3mrl35jgqhs0gt
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: jam-integration
timestamp: Sun 2008-06-15 18:08:14 -0500
message:
  Fix bug #239933, use the right exception for -c0
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS	2008-06-11 12:03:48 +0000
+++ b/NEWS	2008-06-15 23:08:14 +0000
@@ -8,8 +8,6 @@
 IN DEVELOPMENT
 --------------
 
-  BUG FIXES:
-
   IMPROVEMENTS:
 
     * ``bzr export --format=tgz --root=NAME -`` to export a gzipped tarball 
@@ -18,6 +16,9 @@
 
   BUGFIXES:
 
+    * Raise the correct exception when doing ``-rbefore:0`` or ``-c0``.
+      (John Arbash Meinel, #239933)
+
     * You can now compare file revisions in Windows diff programs from 
       Cygwin Bazaar.
       (Matt McClure, #209281)

=== modified file 'bzrlib/revisionspec.py'
--- a/bzrlib/revisionspec.py	2008-05-30 00:42:24 +0000
+++ b/bzrlib/revisionspec.py	2008-06-15 23:08:14 +0000
@@ -522,7 +522,7 @@
         base_revspec = RevisionSpec.from_string(self.spec)
         base_revision_id = base_revspec.as_revision_id(context_branch)
         if base_revision_id == revision.NULL_REVISION:
-            raise errors.InvalidRevisionSpec(self.user_spec, branch,
+            raise errors.InvalidRevisionSpec(self.user_spec, context_branch,
                                          'cannot go before the null: revision')
         context_repo = context_branch.repository
         context_repo.lock_read()

=== modified file 'bzrlib/tests/test_revisionspec.py'
--- a/bzrlib/tests/test_revisionspec.py	2008-05-30 01:03:18 +0000
+++ b/bzrlib/tests/test_revisionspec.py	2008-06-15 23:08:14 +0000
@@ -73,15 +73,27 @@
                          ' %r != %r'
                          % (revision_spec, exp_revision_id, rev_info.rev_id))
 
-    def assertInvalid(self, revision_spec, extra=''):
+    def assertInvalid(self, revision_spec, extra='',
+                      invalid_as_revision_id=True):
         try:
             self.get_in_history(revision_spec)
         except errors.InvalidRevisionSpec, e:
             self.assertEqual(revision_spec, e.spec)
             self.assertEqual(extra, e.extra)
         else:
-            self.fail('Expected InvalidRevisionSpec to be raised for %s'
-                      % (revision_spec,))
+            self.fail('Expected InvalidRevisionSpec to be raised for'
+                      ' %r.in_history' % (revision_spec,))
+        if invalid_as_revision_id:
+            try:
+                spec = RevisionSpec.from_string(revision_spec)
+                spec.as_revision_id(self.tree.branch)
+            except errors.InvalidRevisionSpec, e:
+                self.assertEqual(revision_spec, e.spec)
+                self.assertEqual(extra, e.extra)
+            else:
+                self.fail('Expected InvalidRevisionSpec to be raised for'
+                          ' %r.as_revision_id'
+                          % (revision_spec,))
 
     def assertAsRevisionId(self, revision_id, revision_spec):
         """Calling as_revision_id() should return the specified id."""
@@ -299,7 +311,7 @@
         self.assertInHistoryIs(2, 'r2', 'revid:r2')
         
     def test_missing(self):
-        self.assertInvalid('revid:r3')
+        self.assertInvalid('revid:r3', invalid_as_revision_id=False)
 
     def test_merged(self):
         """We can reach revisions in the ancestry"""
@@ -308,7 +320,7 @@
     def test_not_here(self):
         self.tree2.commit('alt third', rev_id='alt_r3')
         # It exists in tree2, but not in tree
-        self.assertInvalid('revid:alt_r3')
+        self.assertInvalid('revid:alt_r3', invalid_as_revision_id=False)
 
     def test_in_repository(self):
         """We can get any revision id in the repository"""



More information about the bazaar-commits mailing list