Rev 3463: (jam) Change RevisionSpec_revno so that it no longer needs in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Fri May 30 23:13:54 BST 2008


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 3463
revision-id:pqm at pqm.ubuntu.com-20080530221339-0l4zj40k4dknzaqw
parent: pqm at pqm.ubuntu.com-20080530080302-j1jh2bwxmpd0jn2q
parent: john at arbash-meinel.com-20080530214430-nbo0wxzbid6z22ml
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2008-05-30 23:13:39 +0100
message:
  (jam) Change RevisionSpec_revno so that it no longer needs
  	Branch.revision_history()
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/revisionspec.py         revisionspec.py-20050907152633-17567659fd5c0ddb
  bzrlib/tests/test_revisionspec.py testrevisionnamespaces.py-20050711050225-8b4af89e6b1efe84
    ------------------------------------------------------------
    revno: 3460.1.4
    revision-id:john at arbash-meinel.com-20080530214430-nbo0wxzbid6z22ml
    parent: john at arbash-meinel.com-20080530134519-mpgetc0aho9c60z5
    parent: pqm at pqm.ubuntu.com-20080530080302-j1jh2bwxmpd0jn2q
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: revno_no_history
    timestamp: Fri 2008-05-30 16:44:30 -0500
    message:
      merge bzr.dev, resolve NEWS
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/log.py                  log.py-20050505065812-c40ce11702fe5fb1
      bzrlib/uncommit.py             uncommit.py-20050626215513-5ec509fa425b305c
      doc/en/user-guide/branching_a_project.txt branching_a_project.-20071122141511-0knao2lklsdsvb1q-2
    ------------------------------------------------------------
    revno: 3460.1.3
    revision-id:john at arbash-meinel.com-20080530134519-mpgetc0aho9c60z5
    parent: john at arbash-meinel.com-20080530010318-z02yqa2mz048jwb4
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: revno_no_history
    timestamp: Fri 2008-05-30 08:45:19 -0500
    message:
      NEWS
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
    ------------------------------------------------------------
    revno: 3460.1.2
    revision-id:john at arbash-meinel.com-20080530010318-z02yqa2mz048jwb4
    parent: john at arbash-meinel.com-20080530004224-1zq421goscvxm6o1
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: revno_no_history
    timestamp: Thu 2008-05-29 20:03:18 -0500
    message:
      Add a test for wants_revision_history
    modified:
      bzrlib/tests/test_revisionspec.py testrevisionnamespaces.py-20050711050225-8b4af89e6b1efe84
    ------------------------------------------------------------
    revno: 3460.1.1
    revision-id:john at arbash-meinel.com-20080530004224-1zq421goscvxm6o1
    parent: pqm at pqm.ubuntu.com-20080529210000-bycgfufmrqq63tki
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: revno_no_history
    timestamp: Thu 2008-05-29 19:42:24 -0500
    message:
      Change the RevisionSpec_revno so that it doesn't need to grab the revision_history first.
    modified:
      bzrlib/revisionspec.py         revisionspec.py-20050907152633-17567659fd5c0ddb
=== modified file 'NEWS'
--- a/NEWS	2008-05-30 00:35:19 +0000
+++ b/NEWS	2008-05-30 21:44:30 +0000
@@ -39,6 +39,10 @@
       should make something like ``bzr branch -r -100`` in a shared, no-trees
       repository much snappier. (John Arbash Meinel)
 
+    * ``bzr log --short -r X..Y`` no longer needs to access the full revision
+      history. This makes it noticeably faster when logging the last few
+      revisions. (John Arbash Meinel)
+
     * ``bzr ls`` now accepts ``-V`` as an alias for ``--versioned``. 
       (Jerad Cramp, #165086)
 
@@ -153,6 +157,11 @@
       ``bzrlib.revision``  deprecated before bzrlib 1.5 have been removed.
       (Robert Collins)
 
+    * ``RevisionSpec.wants_revision_history`` can be set to False for a given
+      ``RevisionSpec``. This will disable the existing behavior of passing in
+      the full revision history to ``self._match_on``. Useful for specs that
+      don't actually need access to the full history. (John Arbash Meinel)
+
     * The constructors of ``SmartClientMedium`` and its subclasses now require a
       ``base`` parameter.  ``SmartClientMedium`` implementations now also need
       to provide a ``remote_path_from_transport`` method.  (Andrew Bennetts)

=== modified file 'bzrlib/revisionspec.py'
--- a/bzrlib/revisionspec.py	2008-05-08 04:33:38 +0000
+++ b/bzrlib/revisionspec.py	2008-05-30 00:42:24 +0000
@@ -135,6 +135,7 @@
     """
 
     prefix = None
+    wants_revision_history = True
 
     def __new__(cls, spec, _internal=False):
         if _internal:
@@ -215,7 +216,10 @@
 
     def in_history(self, branch):
         if branch:
-            revs = branch.revision_history()
+            if self.wants_revision_history:
+                revs = branch.revision_history()
+            else:
+                revs = None
         else:
             # this should never trigger.
             # TODO: make it a deprecated code path. RBC 20060928
@@ -292,6 +296,7 @@
                                    your history is very long.
     """
     prefix = 'revno:'
+    wants_revision_history = False
 
     def _match_on(self, branch, revs):
         """Lookup a revision by revision number"""

=== modified file 'bzrlib/tests/test_revisionspec.py'
--- a/bzrlib/tests/test_revisionspec.py	2008-03-29 21:16:20 +0000
+++ b/bzrlib/tests/test_revisionspec.py	2008-05-30 01:03:18 +0000
@@ -90,6 +90,35 @@
                          spec.as_revision_id(self.tree.branch))
 
 
+class RevisionSpecMatchOnTrap(RevisionSpec):
+
+    def _match_on(self, branch, revs):
+        self.last_call = (branch, revs)
+        return super(RevisionSpecMatchOnTrap, self)._match_on(branch, revs)
+
+
+class TestRevisionSpecBase(TestRevisionSpec):
+
+    def test_wants_revision_history(self):
+        # If wants_revision_history = True, then _match_on should get the
+        # branch revision history
+        spec = RevisionSpecMatchOnTrap('foo', _internal=True)
+        spec.in_history(self.tree.branch)
+
+        self.assertEqual((self.tree.branch, ['r1' ,'r2']),
+                         spec.last_call)
+
+    def test_wants_no_revision_history(self):
+        # If wants_revision_history = False, then _match_on should get None for
+        # the branch revision history
+        spec = RevisionSpecMatchOnTrap('foo', _internal=True)
+        spec.wants_revision_history = False
+        spec.in_history(self.tree.branch)
+
+        self.assertEqual((self.tree.branch, None), spec.last_call)
+
+
+
 class TestOddRevisionSpec(TestRevisionSpec):
     """Test things that aren't normally thought of as revision specs"""
 




More information about the bazaar-commits mailing list