Rev 5558: Move the check for fallback repos cancelling commit to later in the cycle. in http://bazaar.launchpad.net/~jameinel/bzr/2.3-commit-to-stacked
John Arbash Meinel
john at arbash-meinel.com
Thu Dec 2 23:02:27 GMT 2010
At http://bazaar.launchpad.net/~jameinel/bzr/2.3-commit-to-stacked
------------------------------------------------------------
revno: 5558
revision-id: john at arbash-meinel.com-20101202230218-v9pzqgb839ccskr1
parent: pqm at pqm.ubuntu.com-20101202172840-i4wtlbm8vt4wi1j0
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.3-commit-to-stacked
timestamp: Thu 2010-12-02 17:02:18 -0600
message:
Move the check for fallback repos cancelling commit to later in the cycle.
Instead, we are going to be ensuring fallback inventories here.
-------------- next part --------------
=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py 2010-12-02 10:41:05 +0000
+++ b/bzrlib/repository.py 2010-12-02 23:02:18 +0000
@@ -176,11 +176,27 @@
self._validate_unicode_text(value,
'revision property (%s)' % (key,))
+ def _ensure_fallback_inventories(self):
+ """Ensure that appropriate inventories are available.
+
+ This only applies to repositories that are stacked, and is about
+ enusring the stacking invariants. Namely, that for any revision that is
+ present, we either have all of the file content, or we have the parent
+ inventory and the delta file content.
+ """
+ if not self.repository._fallback_repositories:
+ return
+
+ raise errors.BzrError("Cannot commit from a lightweight checkout "
+ "to a stacked branch. See "
+ "https://bugs.launchpad.net/bzr/+bug/375013 for details.")
+
def commit(self, message):
"""Make the actual commit.
:return: The revision id of the recorded revision.
"""
+ self._ensure_fallback_inventories()
self._validate_unicode_text(message, 'commit message')
rev = _mod_revision.Revision(
timestamp=self._timestamp,
@@ -1761,10 +1777,6 @@
:param revprops: Optional dictionary of revision properties.
:param revision_id: Optional revision id.
"""
- if self._fallback_repositories:
- raise errors.BzrError("Cannot commit from a lightweight checkout "
- "to a stacked branch. See "
- "https://bugs.launchpad.net/bzr/+bug/375013 for details.")
result = self._commit_builder_class(self, parents, config,
timestamp, timezone, committer, revprops, revision_id)
self.start_write_group()
=== modified file 'bzrlib/tests/per_repository_reference/__init__.py'
--- a/bzrlib/tests/per_repository_reference/__init__.py 2010-08-25 10:20:41 +0000
+++ b/bzrlib/tests/per_repository_reference/__init__.py 2010-12-02 23:02:18 +0000
@@ -113,6 +113,7 @@
'bzrlib.tests.per_repository_reference.test_all_revision_ids',
'bzrlib.tests.per_repository_reference.test_break_lock',
'bzrlib.tests.per_repository_reference.test_check',
+ 'bzrlib.tests.per_repository_reference.test_commit_with_stacking',
'bzrlib.tests.per_repository_reference.test_default_stacking',
'bzrlib.tests.per_repository_reference.test_fetch',
'bzrlib.tests.per_repository_reference.test_get_record_stream',
=== added file 'bzrlib/tests/per_repository_reference/test_commit_with_stacking.py'
--- a/bzrlib/tests/per_repository_reference/test_commit_with_stacking.py 1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/per_repository_reference/test_commit_with_stacking.py 2010-12-02 23:02:18 +0000
@@ -0,0 +1,34 @@
+# Copyright (C) 2010 Canonical Ltd
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+
+from bzrlib.tests.per_repository import TestCaseWithRepository
+
+
+class TestCommitWithStacking(TestCaseWithRepository):
+
+ def make_stacked_target(self):
+ base = self.make_branch_and_tree('base')
+ self.build_tree(['base/f1.txt'])
+ base.add(['f1.txt'], ['f1.txt-id'])
+ stacked = base.bzrdir.sprout('stacked',
+ stacked=True).open_workingtree()
+ return base, stacked
+
+ def test_simple_commit(self):
+ base, stacked = self.make_stacked_target()
+ self.assertEqual(1,
+ len(stacked.branch.repository._fallback_repositories))
More information about the bazaar-commits
mailing list