Rev 6226: (jelmer) Add parent_ids and allow_leftmost_as_ghost arguments to in file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/

Patch Queue Manager pqm at pqm.ubuntu.com
Wed Oct 19 13:12:23 UTC 2011


At file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 6226 [merge]
revision-id: pqm at pqm.ubuntu.com-20111019131223-otfw8zcljb7ans2o
parent: pqm at pqm.ubuntu.com-20111018145022-q5crzwqjwu6z33ue
parent: jelmer at samba.org-20111019124641-dx64janhmns2xifo
committer: Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2011-10-19 13:12:23 +0000
message:
  (jelmer) Add parent_ids and allow_leftmost_as_ghost arguments to
   BranchBuilder.build_commit. (Jelmer Vernooij)
modified:
  bzrlib/branchbuilder.py        branchbuilder.py-20070427022007-zlxpqz2lannhk6y8-1
  bzrlib/tests/test_branchbuilder.py test_branchbuilder.p-20070427022007-zlxpqz2lannhk6y8-2
  doc/en/release-notes/bzr-2.5.txt bzr2.5.txt-20110708125756-587p0hpw7oke4h05-1
=== modified file 'bzrlib/branchbuilder.py'
--- a/bzrlib/branchbuilder.py	2011-10-11 12:01:51 +0000
+++ b/bzrlib/branchbuilder.py	2011-10-18 15:28:32 +0000
@@ -87,7 +87,8 @@
                 transport.base, format=format, force_new_tree=False)
         self._tree = None
 
-    def build_commit(self, **commit_kwargs):
+    def build_commit(self, parent_ids=None, allow_leftmost_as_ghost=False,
+                     **commit_kwargs):
         """Build a commit on the branch.
 
         This makes a commit with no real file content for when you only want
@@ -96,9 +97,20 @@
         :param commit_kwargs: Arguments to pass through to commit, such as
              timestamp.
         """
+        if parent_ids is not None:
+            if len(parent_ids) == 0:
+                base_id = revision.NULL_REVISION
+            else:
+                base_id = parent_ids[0]
+            if base_id != self._branch.last_revision():
+                self._move_branch_pointer(base_id,
+                    allow_leftmost_as_ghost=allow_leftmost_as_ghost)
         tree = memorytree.MemoryTree.create_on_branch(self._branch)
         tree.lock_write()
         try:
+            if parent_ids is not None:
+                tree.set_parent_ids(parent_ids,
+                    allow_leftmost_as_ghost=allow_leftmost_as_ghost)
             tree.add('')
             return self._do_commit(tree, **commit_kwargs)
         finally:

=== modified file 'bzrlib/tests/test_branchbuilder.py'
--- a/bzrlib/tests/test_branchbuilder.py	2011-07-15 09:22:16 +0000
+++ b/bzrlib/tests/test_branchbuilder.py	2011-10-18 15:28:32 +0000
@@ -86,6 +86,18 @@
             [rev_id1],
             branch.repository.get_revision(branch.last_revision()).parent_ids)
 
+    def test_build_commit_parent_ids(self):
+        """build_commit() takes a parent_ids argument."""
+        builder = BranchBuilder(self.get_transport().clone('foo'))
+        rev_id1 = builder.build_commit(
+            parent_ids=["ghost"], allow_leftmost_as_ghost=True)
+        rev_id2 = builder.build_commit(parent_ids=[])
+        branch = builder.get_branch()
+        self.assertEqual((1, rev_id2), branch.last_revision_info())
+        self.assertEqual(
+            ["ghost"],
+            branch.repository.get_revision(rev_id1).parent_ids)
+
 
 class TestBranchBuilderBuildSnapshot(tests.TestCaseWithMemoryTransport):
 

=== modified file 'doc/en/release-notes/bzr-2.5.txt'
--- a/doc/en/release-notes/bzr-2.5.txt	2011-10-18 14:50:22 +0000
+++ b/doc/en/release-notes/bzr-2.5.txt	2011-10-19 12:46:41 +0000
@@ -92,6 +92,9 @@
   which format implementations can use whether or not they can access
   a control dir over a particular transport. (Jelmer Vernooij)
 
+* ``BranchBuilder.build_commit`` now take ``parent_ids`` and
+  ``allow_leftmost_as_ghost`` arguments.  (Jelmer Vernooij)
+
 Testing
 *******
 




More information about the bazaar-commits mailing list