Rev 6027: Start working on a config entry for testing whether we should fetch tags or not. in http://bazaar.launchpad.net/~jameinel/bzr/2.4-tag-fetch-flag-771184

John Arbash Meinel john at arbash-meinel.com
Tue Aug 9 13:23:14 UTC 2011


At http://bazaar.launchpad.net/~jameinel/bzr/2.4-tag-fetch-flag-771184

------------------------------------------------------------
revno: 6027
revision-id: john at arbash-meinel.com-20110809132310-5xweu1xf7zmex88w
parent: pqm at pqm.ubuntu.com-20110806012906-nhbhiz93ghzdaew3
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.4-tag-fetch-flag-771184
timestamp: Tue 2011-08-09 15:23:10 +0200
message:
  Start working on a config entry for testing whether we should fetch tags or not.
-------------- next part --------------
=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py	2011-07-18 14:43:35 +0000
+++ b/bzrlib/branch.py	2011-08-09 13:23:10 +0000
@@ -1545,10 +1545,15 @@
         # For bzr native formats must_fetch is just the tip, and if_present_fetch
         # are the tags.
         must_fetch = set([self.last_revision()])
-        try:
-            if_present_fetch = set(self.tags.get_reverse_tag_dict())
-        except errors.TagsNotSupported:
-            if_present_fetch = set()
+        if_present_fetch = set()
+        c = self.get_config()
+        include_tags = c.get_user_option_as_bool('branch.fetch_tags',
+                                                 default=False)
+        if include_tags:
+            try:
+                if_present_fetch = set(self.tags.get_reverse_tag_dict())
+            except errors.TagsNotSupported:
+                pass
         must_fetch.discard(_mod_revision.NULL_REVISION)
         if_present_fetch.discard(_mod_revision.NULL_REVISION)
         return must_fetch, if_present_fetch

=== modified file 'bzrlib/tests/test_remote.py'
--- a/bzrlib/tests/test_remote.py	2011-07-15 08:25:00 +0000
+++ b/bzrlib/tests/test_remote.py	2011-08-09 13:23:10 +0000
@@ -1213,7 +1213,7 @@
         self.assertFinished(client)
         self.assertEqual((set(['tip']), set(['tagged-1', 'tagged-2'])), result)
 
-    def test_backwards_compatible(self):
+    def make_branch_with_tags(self):
         self.setup_smart_server_with_call_log()
         # Make a branch with a single revision.
         builder = self.make_branch_builder('foo')
@@ -1225,6 +1225,12 @@
         # Add two tags to that branch
         branch.tags.set_tag('tag-1', 'rev-1')
         branch.tags.set_tag('tag-2', 'rev-2')
+        return branch
+
+    def test_backwards_compatible(self):
+        branch = self.make_branch_with_tags()
+        c = branch.get_config()
+        c.set_user_option('branch.fetch_tags', 'True')
         self.addCleanup(branch.lock_read().unlock)
         # Disable the heads_to_fetch verb
         verb = 'Branch.heads_to_fetch'
@@ -1233,7 +1239,23 @@
         result = branch.heads_to_fetch()
         self.assertEqual((set(['tip']), set(['rev-1', 'rev-2'])), result)
         self.assertEqual(
-            ['Branch.last_revision_info', 'Branch.get_tags_bytes'],
+            ['Branch.last_revision_info', 'Branch.get_config_file',
+             'Branch.get_tags_bytes'],
+            [call.call.method for call in self.hpss_calls])
+
+    def test_backwards_compatible_no_tags(self):
+        branch = self.make_branch_with_tags()
+        c = branch.get_config()
+        c.set_user_option('branch.fetch_tags', 'False')
+        self.addCleanup(branch.lock_read().unlock)
+        # Disable the heads_to_fetch verb
+        verb = 'Branch.heads_to_fetch'
+        self.disable_verb(verb)
+        self.reset_smart_call_log()
+        result = branch.heads_to_fetch()
+        self.assertEqual((set(['tip']), set()), result)
+        self.assertEqual(
+            ['Branch.last_revision_info', 'Branch.get_config_file'],
             [call.call.method for call in self.hpss_calls])
 
 



More information about the bazaar-commits mailing list