Rev 439: Add separate tests for push-as-merged. in file:///home/jelmer/bzr-svn/customrevids/

Jelmer Vernooij jelmer at samba.org
Fri May 18 12:06:07 BST 2007


At file:///home/jelmer/bzr-svn/customrevids/

------------------------------------------------------------
revno: 439
revision-id: jelmer at samba.org-20070518110606-ghip0jetjq210xdg
parent: jelmer at samba.org-20070518020115-f6opp2673mhvc9sg
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: customrevids
timestamp: Fri 2007-05-18 12:06:06 +0100
message:
  Add separate tests for push-as-merged.
modified:
  checkout.py                    workingtree.py-20060306120941-b083cb0fdd4a69de
  commit.py                      commit.py-20060607190346-qvq128wgfubhhgm2-1
  tests/test_push.py             test_push.py-20070201165715-g2ievcdfqi33wqsy-1
=== modified file 'checkout.py'
--- a/checkout.py	2007-05-18 01:46:26 +0000
+++ b/checkout.py	2007-05-18 11:06:06 +0000
@@ -427,7 +427,7 @@
 
         self.client_ctx.log_msg_baton2 = log_message_func
         if rev_id is not None:
-            extra = rev_id + "\n"
+            extra = "%s\n" % rev_id
         else:
             extra = ""
         wc = self._get_wc(write_lock=True)

=== modified file 'commit.py'
--- a/commit.py	2007-05-18 01:46:26 +0000
+++ b/commit.py	2007-05-18 11:06:06 +0000
@@ -18,13 +18,14 @@
 import svn.delta
 from svn.core import Pool, SubversionException
 
+from bzrlib.branch import Branch
 from bzrlib.errors import InvalidRevisionId, DivergedBranches
 from bzrlib.inventory import Inventory
 import bzrlib.osutils as osutils
 from bzrlib.repository import RootCommitBuilder
 from bzrlib.trace import mutter
 
-from repository import (SvnRepository, SVN_PROP_BZR_MERGE, SVN_PROP_BZR_FILEIDS,
+from repository import (SVN_PROP_BZR_MERGE, SVN_PROP_BZR_FILEIDS,
                         SVN_PROP_SVK_MERGE, SVN_PROP_BZR_REVPROP_PREFIX, 
                         SVN_PROP_BZR_REVISION_ID, revision_id_to_svk_feature)
 from revids import escape_svn_path
@@ -47,7 +48,6 @@
         """
         super(SvnCommitBuilder, self).__init__(repository, parents, 
             config, None, None, None, revprops, None)
-        assert isinstance(repository, SvnRepository)
         self.branch = branch
         self.pool = Pool()
 
@@ -85,10 +85,9 @@
 
         if revision_id is not None:
             extra = "%s\n" % revision_id
-            if self._svnprops.has_key(SVN_PROP_BZR_REVISION_ID):
-                self._svnprops[SVN_PROP_BZR_REVISION_ID] += extra
-            else:
-                self._svnprops[SVN_PROP_BZR_REVISION_ID] = extra
+            if not self._svnprops.has_key(SVN_PROP_BZR_REVISION_ID):
+                self._svnprops[SVN_PROP_BZR_REVISION_ID] = ""
+            self._svnprops[SVN_PROP_BZR_REVISION_ID] += extra
 
         # At least one of the parents has to be the last revision on the 
         # mainline in # Subversion.
@@ -302,7 +301,6 @@
             self.revnum = revision
             self.date = date
             self.author = author
-            mutter('committed %r, author: %r, date: %r' % (revision, author, date))
         
         mutter('obtaining commit editor')
         self.revnum = None
@@ -338,8 +336,8 @@
         self.branch.revision_history()
         self.branch._revision_history.append(revid)
 
-        mutter('commit finished. author: %r, date: %r' % 
-               (self.author, self.date))
+        mutter('commit %d finished. author: %r, date: %r' % 
+               (self.revnum, self.author, self.date))
 
         # Make sure the logwalker doesn't try to use ra 
         # during checkouts...
@@ -400,6 +398,7 @@
     :param revision_id: Revision id of the revision to push
     :return: The revision id of the created revision
     """
+    assert isinstance(source, Branch)
     rev = source.repository.get_revision(revision_id)
     inv = source.repository.get_inventory(revision_id)
 

=== modified file 'tests/test_push.py'
--- a/tests/test_push.py	2007-05-18 01:25:26 +0000
+++ b/tests/test_push.py	2007-05-18 11:06:06 +0000
@@ -24,7 +24,9 @@
 import format
 import checkout
 import svn.core
+from commit import push_as_merged
 from repository import MAPPING_VERSION, SVN_PROP_BZR_REVISION_ID
+from revids import generate_svn_revision_id
 from tests import TestCaseWithSubversionRepository
 
 class TestPush(TestCaseWithSubversionRepository):
@@ -148,10 +150,40 @@
         wt.add('file')
         wt.commit(message="Commit from Bzr", rev_id="some-rid")
 
+        self.svndir.open_branch().pull(self.bzrdir.open_branch())
+
         self.client_update("sc")
         self.assertEqual("some-rid\n", 
                 self.client_get_prop("sc", SVN_PROP_BZR_REVISION_ID))
 
+    def test_multiple_merged(self):
+        self.build_tree({'dc/file': 'data'})
+        wt = self.bzrdir.open_workingtree()
+        wt.add('file')
+        wt.commit(message="Commit from Bzr")
+
+        self.build_tree({'dc/file': 'data2', 'dc/adir': None})
+        wt.add('adir')
+        wt.commit(message="Another commit from Bzr")
+
+        push_as_merged(self.svndir.open_branch(),
+                       self.bzrdir.open_branch(),
+                       self.bzrdir.open_branch().last_revision())
+                       
+        repos = self.svndir.find_repository()
+
+        self.assertEqual(
+           generate_svn_revision_id(self.svndir.find_repository().uuid, 2, ""), 
+                        self.svndir.open_branch().last_revision())
+
+        inv = repos.get_inventory(repos.generate_revision_id(2, ""))
+        self.assertTrue(inv.has_filename('file'))
+        self.assertTrue(inv.has_filename('adir'))
+
+        self.assertEqual([repos.generate_revision_id(1, ""), 
+            self.bzrdir.open_branch().last_revision()],
+                repos.revision_parents(repos.generate_revision_id(2, "")))
+
     def test_multiple(self):
         self.build_tree({'dc/file': 'data'})
         wt = self.bzrdir.open_workingtree()




More information about the bazaar-commits mailing list