Rev 2807: Setting and deleting tags should also update the master branch, if any. in http://sourcefrog.net/bzr/tags

Martin Pool mbp at sourcefrog.net
Tue Sep 11 03:09:17 BST 2007


At http://sourcefrog.net/bzr/tags

------------------------------------------------------------
revno: 2807
revision-id: mbp at sourcefrog.net-20070911020916-t0i1xe6jrpmjl4vf
parent: mbp at sourcefrog.net-20070910095133-yvlr99xkorynbdue
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: tags
timestamp: Tue 2007-09-11 12:09:16 +1000
message:
  Setting and deleting tags should also update the master branch, if any.
modified:
  bzrlib/tag.py                  tag.py-20070212110532-91cw79inah2cfozx-1
  bzrlib/tests/test_tag.py       test_tag.py-20070212110532-91cw79inah2cfozx-2
=== modified file 'bzrlib/tag.py'
--- a/bzrlib/tag.py	2007-04-19 19:28:39 +0000
+++ b/bzrlib/tag.py	2007-09-11 02:09:16 +0000
@@ -82,6 +82,9 @@
         # all done with a write lock held, so this looks atomic
         self.branch.lock_write()
         try:
+            master = self.branch.get_master_branch()
+            if master is not None:
+                master.tags.set_tag(tag_name, tag_target)
             td = self.get_tag_dict()
             td[tag_name] = tag_target
             self._set_tag_dict(td)
@@ -134,6 +137,12 @@
                 del d[tag_name]
             except KeyError:
                 raise errors.NoSuchTag(tag_name)
+            master = self.branch.get_master_branch()
+            if master is not None:
+                try:
+                    master.tags.delete_tag(tag_name)
+                except errors.NoSuchTag:
+                    pass
             self._set_tag_dict(d)
         finally:
             self.branch.unlock()
@@ -152,7 +161,7 @@
 
     def _serialize_tag_dict(self, tag_dict):
         td = dict((k.encode('utf-8'), v)
-                for k,v in tag_dict.items())
+                  for k,v in tag_dict.items())
         return bencode.bencode(td)
 
     def _deserialize_tag_dict(self, tag_content):

=== modified file 'bzrlib/tests/test_tag.py'
--- a/bzrlib/tests/test_tag.py	2007-09-10 09:51:33 +0000
+++ b/bzrlib/tests/test_tag.py	2007-09-11 02:09:16 +0000
@@ -83,13 +83,18 @@
 
 class TestTagsInCheckouts(TestCaseWithTransport):
 
-    def make_branch_supporting_tags(self, relpath):
-        return self.make_branch(relpath)
-
     def test_tag_in_checkout(self):
         # checkouts are directly connected to the tags of their master branch:
         # adding a tag in the checkout pushes it to the master
-        raise KnownFailure("not tested yet")
+        master = self.make_branch('master')
+        child = self.make_branch('child')
+        child.bind(master)
+        child.tags.set_tag('foo', 'rev-1')
+        self.assertEquals('rev-1', master.tags.lookup_tag('foo'))
+        # deleting a tag updates the master too
+        child.tags.delete_tag('foo')
+        self.assertRaises(errors.NoSuchTag,
+            master.tags.lookup_tag, 'foo')
 
     def test_update_updates_tags(self):
         raise KnownFailure(




More information about the bazaar-commits mailing list