Rev 2814: (mbp) fix bugs in tags with checkouts in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Tue Sep 11 06:56:25 BST 2007


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

------------------------------------------------------------
revno: 2814
revision-id: pqm at pqm.ubuntu.com-20070911055622-a3060rj7l0iy38l2
parent: pqm at pqm.ubuntu.com-20070911025457-xd28g5hqu9jco1sm
parent: mbp at sourcefrog.net-20070911031705-ho2pp6ulm4zln3du
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2007-09-11 06:56:22 +0100
message:
  (mbp) fix bugs in tags with checkouts
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/tag.py                  tag.py-20070212110532-91cw79inah2cfozx-1
  bzrlib/tests/test_tag.py       test_tag.py-20070212110532-91cw79inah2cfozx-2
    ------------------------------------------------------------
    revno: 2805.5.5
    merged: mbp at sourcefrog.net-20070911031705-ho2pp6ulm4zln3du
    parent: mbp at sourcefrog.net-20070911030714-nzoumditu81hhwtw
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: tags
    timestamp: Tue 2007-09-11 13:17:05 +1000
    message:
      Add another test that tags work ok in checkouts
    ------------------------------------------------------------
    revno: 2805.5.4
    merged: mbp at sourcefrog.net-20070911030714-nzoumditu81hhwtw
    parent: mbp at sourcefrog.net-20070911030330-8000a0t8feq8g130
    parent: pqm at pqm.ubuntu.com-20070911025457-xd28g5hqu9jco1sm
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: tags
    timestamp: Tue 2007-09-11 13:07:14 +1000
    message:
      merge trunk
    ------------------------------------------------------------
    revno: 2805.5.3
    merged: mbp at sourcefrog.net-20070911030330-8000a0t8feq8g130
    parent: mbp at sourcefrog.net-20070911020916-t0i1xe6jrpmjl4vf
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: tags
    timestamp: Tue 2007-09-11 13:03:30 +1000
    message:
      In checkouts, tags are copied into the master branch when created, changed or deleted, and are copied into the checkout when it is updated.  (Martin Pool, #93856, #93860)
    ------------------------------------------------------------
    revno: 2805.5.2
    merged: 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.
    ------------------------------------------------------------
    revno: 2805.5.1
    merged: mbp at sourcefrog.net-20070910095133-yvlr99xkorynbdue
    parent: pqm at pqm.ubuntu.com-20070907145828-hjh5941jv7y8d9z8
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: tags
    timestamp: Mon 2007-09-10 19:51:33 +1000
    message:
      Start adding tests for bug 93860
=== modified file 'NEWS'
--- a/NEWS	2007-09-11 02:54:57 +0000
+++ b/NEWS	2007-09-11 03:07:14 +0000
@@ -12,6 +12,7 @@
    * The default branch and repository format has changed to 
      ``dirstate-tags``, so tag commands are active by default.
      This format is compatible with Bazaar 0.15 and later.
+     This incidentally fixes bug #126141.
      (Martin Pool)
 
    * ``--quiet`` or ``-q`` is no longer a global option. If present, it
@@ -133,6 +134,10 @@
    * Overwrite conflicting tags by ``push`` and ``pull`` if the
      ``--overwrite`` option is specified.  (Lukáš Lalinský, #93947)
 
+    * In checkouts, tags are copied into the master branch when created,
+      changed or deleted, and are copied into the checkout when it is 
+      updated.  (Martin Pool, #93856, #93860)
+
   IMPROVEMENTS:
 
    * Add the option "--show-diff" to the commit command in order to display

=== modified file 'bzrlib/tag.py'
--- a/bzrlib/tag.py	2007-09-11 00:15:56 +0000
+++ b/bzrlib/tag.py	2007-09-11 03:07:14 +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-07 11:37:13 +0000
+++ b/bzrlib/tests/test_tag.py	2007-09-11 03:17:05 +0000
@@ -26,6 +26,7 @@
     _merge_tags_if_possible,
     )
 from bzrlib.tests import (
+    KnownFailure,
     TestCase,
     TestCaseWithTransport,
     )
@@ -98,3 +99,55 @@
         conflicts = a.tags.merge_to(b.tags, overwrite=True)
         self.assertEqual(conflicts, [])
         self.assertEqual('z', b.tags.lookup_tag('tag-2'))
+
+
+class TestTagsInCheckouts(TestCaseWithTransport):
+
+    def test_update_tag_into_checkout(self):
+        # checkouts are directly connected to the tags of their master branch:
+        # adding a tag in the checkout pushes it to the master
+        # https://bugs.launchpad.net/bzr/+bug/93860
+        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_tag_copied_by_initial_checkout(self):
+        # https://bugs.launchpad.net/bzr/+bug/93860
+        master = self.make_branch('master')
+        master.tags.set_tag('foo', 'rev-1')
+        co_tree = master.create_checkout('checkout')
+        self.assertEquals('rev-1',
+            co_tree.branch.tags.lookup_tag('foo'))
+
+    def test_update_updates_tags(self):
+        # https://bugs.launchpad.net/bzr/+bug/93856
+        master = self.make_branch('master')
+        master.tags.set_tag('foo', 'rev-1')
+        child = self.make_branch('child')
+        child.bind(master)
+        child.update()
+        # after an update, the child has all the master's tags
+        self.assertEquals('rev-1', child.tags.lookup_tag('foo'))
+        # add another tag and update again
+        master.tags.set_tag('tag2', 'target2')
+        child.update()
+        self.assertEquals('target2', child.tags.lookup_tag('tag2'))
+
+    def test_tag_deletion_from_master_to_bound(self):
+        master = self.make_branch('master')
+        master.tags.set_tag('foo', 'rev-1')
+        child = self.make_branch('child')
+        child.bind(master)
+        child.update()
+        # and deletion of tags should also propagate
+        master.tags.delete_tag('foo')
+        raise KnownFailure("tag deletion does not propagate: "
+            "https://bugs.launchpad.net/bzr/+bug/138802")
+        self.assertRaises(errors.NoSuchTag,
+            child.tags.lookup_tag, 'foo')




More information about the bazaar-commits mailing list