Rev 2207: Merge from bzr.dev in sftp://bazaar.launchpad.net/%7Ebzr/bzr/hpss/

Andrew Bennetts andrew.bennetts at canonical.com
Wed Apr 11 05:28:27 BST 2007


At sftp://bazaar.launchpad.net/%7Ebzr/bzr/hpss/

------------------------------------------------------------
revno: 2207
revision-id: andrew.bennetts at canonical.com-20070411042623-4qav34z64fftnbyx
parent: andrew.bennetts at canonical.com-20070410155415-hyzlzwevu3ud0dny
parent: pqm at pqm.ubuntu.com-20070411022359-403a2155afb207cf
committer: Andrew Bennetts <andrew.bennetts at canonical.com>
branch nick: hpss
timestamp: Wed 2007-04-11 14:26:23 +1000
message:
  Merge from bzr.dev
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/revision.py             revision.py-20050309040759-e77802c08f3999d5
  bzrlib/smart/request.py        request.py-20061108095550-gunadhxmzkdjfeek-1
  bzrlib/smart/vfs.py            vfs.py-20061108095550-gunadhxmzkdjfeek-2
  bzrlib/tests/test_read_bundle.py test_read_bundle.py-20060615211421-ud8cwr1ulgd914zf-1
  bzrlib/tests/test_smart_transport.py test_ssh_transport.py-20060608202016-c25gvf1ob7ypbus6-2
  bzrlib/tests/test_transport_implementations.py test_transport_implementations.py-20051227111451-f97c5c7d5c49fce7
    ------------------------------------------------------------
    revno: 2018.1.2.1.50.2.80.1.99.1.9.1.21.1.26.2.74.2.2.2.23
    merged: pqm at pqm.ubuntu.com-20070411022359-403a2155afb207cf
    parent: pqm at pqm.ubuntu.com-20070411015343-51539420298ee77c
    parent: andrew.bennetts at canonical.com-20070411020118-yie55yxj8v9ke3b8
    committer: Canonical.com Patch Queue Manager<pqm at pqm.ubuntu.com>
    branch nick: +trunk
    timestamp: Wed 2007-04-11 03:23:59 +0100
    message:
      Use the Command pattern for smart server request handling
        ------------------------------------------------------------
        revno: 2018.1.2.1.50.2.80.1.99.1.9.1.21.1.26.2.74.2.2.2.21.1.2
        merged: andrew.bennetts at canonical.com-20070411020118-yie55yxj8v9ke3b8
        parent: andrew.bennetts at canonical.com-20070410141235-wtmjydzktegq64cz
        committer: Andrew Bennetts <andrew.bennetts at canonical.com>
        branch nick: hpss-part-two-server-commands
        timestamp: Wed 2007-04-11 12:01:18 +1000
        message:
          Deal with review comments.
        ------------------------------------------------------------
        revno: 2018.1.2.1.50.2.80.1.99.1.9.1.21.1.26.2.74.2.2.2.21.1.1
        merged: andrew.bennetts at canonical.com-20070410141235-wtmjydzktegq64cz
        parent: pqm at pqm.ubuntu.com-20070410074302-cf6b95587a1058cd
        committer: Andrew Bennetts <andrew.bennetts at canonical.com>
        branch nick: hpss-part-two-server-commands
        timestamp: Wed 2007-04-11 00:12:35 +1000
        message:
          Use the Command pattern for handling smart server commands.
          
          This improves readability and testability.
          
          This change has been extracted from the hpss branch.
    ------------------------------------------------------------
    revno: 2018.1.2.1.50.2.80.1.99.1.9.1.21.1.26.2.74.2.2.2.22
    merged: pqm at pqm.ubuntu.com-20070411015343-51539420298ee77c
    parent: pqm at pqm.ubuntu.com-20070410074302-cf6b95587a1058cd
    parent: john at arbash-meinel.com-20070411012920-wnp7rnqdwe13xmhx
    committer: Canonical.com Patch Queue Manager<pqm at pqm.ubuntu.com>
    branch nick: +trunk
    timestamp: Wed 2007-04-11 02:53:43 +0100
    message:
      (John Arbash Meinel) Fix bug #103757 by teaching common_ancestor to shortcut when a tip is in the other ancestry.
    ------------------------------------------------------------
    revno: 2018.1.2.1.50.2.80.1.99.1.9.1.21.1.26.2.74.2.2.2.20.1.5
    merged: john at arbash-meinel.com-20070411012920-wnp7rnqdwe13xmhx
    parent: john at arbash-meinel.com-20070410191541-rj635kcwkp305bo7
    parent: pqm at pqm.ubuntu.com-20070410074302-cf6b95587a1058cd
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: shortcut-common-ancestor
    timestamp: Tue 2007-04-10 20:29:20 -0500
    message:
      [merge] bzr.dev 2402
    ------------------------------------------------------------
    revno: 2018.1.2.1.50.2.80.1.99.1.9.1.21.1.26.2.74.2.2.2.20.1.4
    merged: john at arbash-meinel.com-20070410191541-rj635kcwkp305bo7
    parent: john at arbash-meinel.com-20070410183032-rw4d3kpb8f9cesfw
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: shortcut-common-ancestor
    timestamp: Tue 2007-04-10 14:15:41 -0500
    message:
      NEWS about fixing bug #103757
    ------------------------------------------------------------
    revno: 2018.1.2.1.50.2.80.1.99.1.9.1.21.1.26.2.74.2.2.2.20.1.3
    merged: john at arbash-meinel.com-20070410183032-rw4d3kpb8f9cesfw
    parent: john at arbash-meinel.com-20070410181305-9y6qbm51we9k37kz
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: shortcut-common-ancestor
    timestamp: Tue 2007-04-10 13:30:32 -0500
    message:
      We don't need to extract ancestry_b until we after we've checked for existence.
      It seems to make sense to check 'b in ancestry_a' first, though we might consider checking
      a in ancestry_b first.
      b in a is merging something which has already been merged.
      a in b is merging something which has merged you.
      And 'a in b' may actually be more common.
      The timing difference is fairly small, though.
    ------------------------------------------------------------
    revno: 2018.1.2.1.50.2.80.1.99.1.9.1.21.1.26.2.74.2.2.2.20.1.2
    merged: john at arbash-meinel.com-20070410181305-9y6qbm51we9k37kz
    parent: john at arbash-meinel.com-20070410175723-9a3rljph39ot4e35
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: shortcut-common-ancestor
    timestamp: Tue 2007-04-10 13:13:05 -0500
    message:
      Ancestry checks can be done using the dictionaries
      And we don't need to create 2 sets, one will do just fine.
    ------------------------------------------------------------
    revno: 2018.1.2.1.50.2.80.1.99.1.9.1.21.1.26.2.74.2.2.2.20.1.1
    merged: john at arbash-meinel.com-20070410175723-9a3rljph39ot4e35
    parent: pqm at pqm.ubuntu.com-20070405073143-8fa894c829ab5e50
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: shortcut-common-ancestor
    timestamp: Tue 2007-04-10 12:57:23 -0500
    message:
      Shortcut the common_ancestor code when one tip is in the ancestry of the other.
=== modified file 'NEWS'
--- a/NEWS	2007-04-10 15:54:15 +0000
+++ b/NEWS	2007-04-11 04:26:23 +0000
@@ -67,6 +67,11 @@
     * Don't produce encoding error when adding duplicate files.
       (Aaron Bentley)
 
+    * Teach ``common_ancestor`` to shortcut when the tip of one branch is
+      inside the ancestry of the other. Saves a lot of graph processing
+      (with an ancestry of 16k revisions, ``bzr merge ../already-merged``
+      changes from 2m10s to 13s).  (John Arbash Meinel, #103757)
+
   TESTING:
 
     * Added ``bzrlib.strace.strace`` which will strace a single callable and

=== modified file 'bzrlib/revision.py'
--- a/bzrlib/revision.py	2007-01-17 15:37:08 +0000
+++ b/bzrlib/revision.py	2007-04-10 18:30:32 +0000
@@ -251,11 +251,19 @@
             pb.update('Picking ancestor', 1, 3)
             graph = revision_source.get_revision_graph_with_ghosts(
                 [revision_a, revision_b])
+            # Shortcut the case where one of the tips is already included in
+            # the other graphs ancestry.
+            ancestry_a = graph.get_ancestry(revision_a)
+            if revision_b in ancestry_a:
+                return revision_b
+            ancestry_b = graph.get_ancestry(revision_b)
+            if revision_a in ancestry_b:
+                return revision_a
             # convert to a NULL_REVISION based graph.
             ancestors = graph.get_ancestors()
             descendants = graph.get_descendants()
-            common = set(graph.get_ancestry(revision_a)).intersection(
-                     set(graph.get_ancestry(revision_b)))
+            common = set(ancestry_a)
+            common.intersection_update(ancestry_b)
             descendants[NULL_REVISION] = {}
             ancestors[NULL_REVISION] = []
             for root in graph.roots:

=== modified file 'bzrlib/smart/request.py'
--- a/bzrlib/smart/request.py	2007-04-10 15:54:15 +0000
+++ b/bzrlib/smart/request.py	2007-04-11 04:26:23 +0000
@@ -19,15 +19,24 @@
 
 import tempfile
 
-from bzrlib import bzrdir, errors, registry, revision
+from bzrlib import (
+    bzrdir,
+    errors,
+    registry,
+    revision,
+    )
 from bzrlib.bundle.serializer import write_bundle
 
 
 class SmartServerRequest(object):
-    """Base class for request handlers.
-    """
+    """Base class for request handlers."""
 
     def __init__(self, backing_transport):
+        """Constructor.
+
+        :param backing_transport: the base transport to be used when performing
+            this request.
+        """
         self._backing_transport = backing_transport
 
     def _check_enabled(self):
@@ -198,6 +207,7 @@
 
 
 class GetBundleRequest(SmartServerRequest):
+    """Get a bundle of from the null revision to the specified revision."""
 
     def do(self, path, revision_id):
         # open transport relative to our base

=== modified file 'bzrlib/smart/vfs.py'
--- a/bzrlib/smart/vfs.py	2006-11-23 06:16:15 +0000
+++ b/bzrlib/smart/vfs.py	2007-04-11 04:26:23 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2006 Canonical Ltd
+# Copyright (C) 2006, 2007 Canonical Ltd
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -42,11 +42,11 @@
 def vfs_enabled():
     """Is the VFS enabled ?
 
-    the VFS is disabled when the NO_SMART_VFS environment variable is set.
+    the VFS is disabled when the BZR_NO_SMART_VFS environment variable is set.
 
     :return: True if it is enabled.
     """
-    return not 'NO_SMART_VFS' in os.environ
+    return not 'BZR_NO_SMART_VFS' in os.environ
 
 
 class VfsRequest(request.SmartServerRequest):

=== modified file 'bzrlib/tests/test_read_bundle.py'
--- a/bzrlib/tests/test_read_bundle.py	2007-03-28 07:48:37 +0000
+++ b/bzrlib/tests/test_read_bundle.py	2007-04-11 04:26:23 +0000
@@ -63,7 +63,7 @@
         return wt
 
     def test_read_bundle_from_url(self):
-        self._captureVar('NO_SMART_VFS', None)
+        self._captureVar('BZR_NO_SMART_VFS', None)
         wt = self.create_test_bundle()
         if wt is None:
             return
@@ -75,7 +75,7 @@
     def test_read_fail(self):
         # Trying to read from a directory, or non-bundle file
         # should fail with NotABundle
-        self._captureVar('NO_SMART_VFS', None)
+        self._captureVar('BZR_NO_SMART_VFS', None)
         wt = self.create_test_bundle()
         if wt is None:
             return

=== modified file 'bzrlib/tests/test_smart_transport.py'
--- a/bzrlib/tests/test_smart_transport.py	2007-04-10 15:54:15 +0000
+++ b/bzrlib/tests/test_smart_transport.py	2007-04-11 04:26:23 +0000
@@ -572,7 +572,7 @@
 
     def setUp(self):
         super(TestSmartServerStreamMedium, self).setUp()
-        self._captureVar('NO_SMART_VFS', None)
+        self._captureVar('BZR_NO_SMART_VFS', None)
 
     def portable_socket_pair(self):
         """Return a pair of TCP sockets connected to each other.
@@ -780,7 +780,7 @@
 
     def test_get_error_unexpected(self):
         """Error reported by server with no specific representation"""
-        self._captureVar('NO_SMART_VFS', None)
+        self._captureVar('BZR_NO_SMART_VFS', None)
         class FlakyTransport(object):
             base = 'a_url'
             def get_bytes(self, path):
@@ -866,14 +866,14 @@
 
     def test_smart_transport_has(self):
         """Checking for file existence over smart."""
-        self._captureVar('NO_SMART_VFS', None)
+        self._captureVar('BZR_NO_SMART_VFS', None)
         self.backing_transport.put_bytes("foo", "contents of foo\n")
         self.assertTrue(self.transport.has("foo"))
         self.assertFalse(self.transport.has("non-foo"))
 
     def test_smart_transport_get(self):
         """Read back a file over smart."""
-        self._captureVar('NO_SMART_VFS', None)
+        self._captureVar('BZR_NO_SMART_VFS', None)
         self.backing_transport.put_bytes("foo", "contents\nof\nfoo\n")
         fp = self.transport.get("foo")
         self.assertEqual('contents\nof\nfoo\n', fp.read())
@@ -883,7 +883,7 @@
         # The path in a raised NoSuchFile exception should be the precise path
         # asked for by the client. This gives meaningful and unsurprising errors
         # for users.
-        self._captureVar('NO_SMART_VFS', None)
+        self._captureVar('BZR_NO_SMART_VFS', None)
         try:
             self.transport.get('not%20a%20file')
         except errors.NoSuchFile, e:
@@ -910,7 +910,7 @@
 
     def test_open_dir(self):
         """Test changing directory"""
-        self._captureVar('NO_SMART_VFS', None)
+        self._captureVar('BZR_NO_SMART_VFS', None)
         transport = self.transport
         self.backing_transport.mkdir('toffee')
         self.backing_transport.mkdir('toffee/apple')
@@ -938,7 +938,7 @@
 
     def test_mkdir_error_readonly(self):
         """TransportNotPossible should be preserved from the backing transport."""
-        self._captureVar('NO_SMART_VFS', None)
+        self._captureVar('BZR_NO_SMART_VFS', None)
         self.setUpServer(readonly=True)
         self.assertRaises(errors.TransportNotPossible, self.transport.mkdir,
             'foo')
@@ -1012,7 +1012,7 @@
 
     def setUp(self):
         super(SmartServerRequestHandlerTests, self).setUp()
-        self._captureVar('NO_SMART_VFS', None)
+        self._captureVar('BZR_NO_SMART_VFS', None)
 
     def build_handler(self, transport):
         """Returns a handler for the commands in protocol version one."""
@@ -1030,15 +1030,15 @@
         self.assertEqual(None, handler.response.body)
         
     def test_disable_vfs_handler_classes_via_environment(self):
-        # VFS handler classes will raise an error from "execute" if NO_SMART_VFS
-        # is set.
+        # VFS handler classes will raise an error from "execute" if
+        # BZR_NO_SMART_VFS is set.
         handler = vfs.HasRequest(None)
         # set environment variable after construction to make sure it's
         # examined.
-        # Note that we can safely clobber NO_SMART_VFS here, because setUp has
-        # called _captureVar, so it will be restored to the right state
+        # Note that we can safely clobber BZR_NO_SMART_VFS here, because setUp
+        # has called _captureVar, so it will be restored to the right state
         # afterwards.
-        os.environ['NO_SMART_VFS'] = ''
+        os.environ['BZR_NO_SMART_VFS'] = ''
         self.assertRaises(errors.DisabledMethod, handler.execute)
 
     def test_readonly_exception_becomes_transport_not_possible(self):
@@ -1176,7 +1176,7 @@
         self.client_protocol = protocol.SmartClientRequestProtocolOne(
             self.client_medium)
         self.smart_server = InstrumentedServerProtocol(self.server_to_client)
-        self.smart_server_request = smart.SmartServerRequestHandler(
+        self.smart_server_request = request.SmartServerRequestHandler(
             None, request.request_handlers)
 
     def assertOffsetSerialisation(self, expected_offsets, expected_serialised,
@@ -1269,7 +1269,7 @@
         self.assertTrue(self.end_received)
 
     def test_accept_request_and_body_all_at_once(self):
-        self._captureVar('NO_SMART_VFS', None)
+        self._captureVar('BZR_NO_SMART_VFS', None)
         mem_transport = memory.MemoryTransport()
         mem_transport.put_bytes('foo', 'abcdefghij')
         out_stream = StringIO()
@@ -1563,7 +1563,7 @@
     def setUp(self):
         super(HTTPTunnellingSmokeTest, self).setUp()
         # We use the VFS layer as part of HTTP tunnelling tests.
-        self._captureVar('NO_SMART_VFS', None)
+        self._captureVar('BZR_NO_SMART_VFS', None)
 
     def _test_bulk_data(self, url_protocol):
         # We should be able to send and receive bulk data in a single message.

=== modified file 'bzrlib/tests/test_transport_implementations.py'
--- a/bzrlib/tests/test_transport_implementations.py	2007-04-10 15:54:15 +0000
+++ b/bzrlib/tests/test_transport_implementations.py	2007-04-11 04:26:23 +0000
@@ -48,7 +48,7 @@
 
     def setUp(self):
         super(TransportTests, self).setUp()
-        self._captureVar('NO_SMART_VFS', None)
+        self._captureVar('BZR_NO_SMART_VFS', None)
 
     def check_transport_contents(self, content, transport, relpath):
         """Check that transport.get(relpath).read() == content."""




More information about the bazaar-commits mailing list