Rev 2722: (mbp) Set default forrmat to dirstate-tags in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Fri Aug 17 11:41:34 BST 2007
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 2722
revision-id: pqm at pqm.ubuntu.com-20070817104128-30oe09d0jeoii7fx
parent: pqm at pqm.ubuntu.com-20070817081001-f4cslu4g95a2e88n
parent: mbp at sourcefrog.net-20070817063508-x2pkbttab8exp56e
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2007-08-17 11:41:28 +0100
message:
(mbp) Set default forrmat to dirstate-tags
added:
bzrlib/tests/repository_implementations/test_fetch.py test_fetch.py-20070814052151-5cxha9slx4c93uog-1
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/branch.py branch.py-20050309040759-e4baf4e0d046576e
bzrlib/bzrdir.py bzrdir.py-20060131065624-156dfea39c4387cb
bzrlib/errors.py errors.py-20050309040759-20512168c4e14fbd
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
bzrlib/store/revision/knit.py knit.py-20060303020652-de5fa299e941a3c7
bzrlib/tests/__init__.py selftest.py-20050531073622-8d0e3c8845c97a64
bzrlib/tests/blackbox/test_info.py test_info.py-20060215045507-bbdd2d34efab9e0a
bzrlib/tests/branch_implementations/test_branch.py testbranch.py-20050711070244-121d632bc37d7253
bzrlib/tests/branch_implementations/test_hooks.py test_hooks.py-20070129154855-blhpwxmvjs07waei-1
bzrlib/tests/branch_implementations/test_revision_history.py test_revision_histor-20070326062311-v7co92liyuchb80w-1
bzrlib/tests/repository_implementations/__init__.py __init__.py-20060131092037-9564957a7d4a841b
bzrlib/tests/repository_implementations/test_repository.py test_repository.py-20060131092128-ad07f494f5c9d26c
bzrlib/tests/test_branch.py test_branch.py-20060116013032-97819aa07b8ab3b5
bzrlib/tests/test_fetch.py testfetch.py-20050825090644-f73e07e7dfb1765a
bzrlib/tests/test_revision.py testrevision.py-20050804210559-46f5e1eb67b01289
------------------------------------------------------------
revno: 2696.3.10
merged: mbp at sourcefrog.net-20070817063508-x2pkbttab8exp56e
parent: mbp at sourcefrog.net-20070817051614-0jczd1jlk8dfvutq
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: default-format
timestamp: Fri 2007-08-17 16:35:08 +1000
message:
Add missing import
------------------------------------------------------------
revno: 2696.3.9
merged: mbp at sourcefrog.net-20070817051614-0jczd1jlk8dfvutq
parent: mbp at sourcefrog.net-20070814115300-ck5miivuv97mj8gp
parent: mbp at sourcefrog.net-20070817050852-pn8w2eij7gcbmbge
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: default-format
timestamp: Fri 2007-08-17 15:16:14 +1000
message:
merge trunk
------------------------------------------------------------
revno: 2697.2.6
merged: mbp at sourcefrog.net-20070817050852-pn8w2eij7gcbmbge
parent: mbp at sourcefrog.net-20070817050128-phk7x1enjqhio5mu
parent: pqm at pqm.ubuntu.com-20070816195834-vvgmajr1s1uk4m9w
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: deprecate-append-revision
timestamp: Fri 2007-08-17 15:08:52 +1000
message:
Merge trunk
------------------------------------------------------------
revno: 2697.2.5
merged: mbp at sourcefrog.net-20070817050128-phk7x1enjqhio5mu
parent: mbp at sourcefrog.net-20070817041727-jsk9mo4vkkt80ttv
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: deprecate-append-revision
timestamp: Fri 2007-08-17 15:01:28 +1000
message:
Kill off append_revision
------------------------------------------------------------
revno: 2697.2.4
merged: mbp at sourcefrog.net-20070817041727-jsk9mo4vkkt80ttv
parent: mbp at sourcefrog.net-20070814092821-1e5d80iyur5fjrrs
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: deprecate-append-revision
timestamp: Fri 2007-08-17 14:17:27 +1000
message:
Remove assertions about revno consistency from BzrBranch.set_last_revision_info
------------------------------------------------------------
revno: 2696.3.8
merged: mbp at sourcefrog.net-20070814115300-ck5miivuv97mj8gp
parent: mbp at sourcefrog.net-20070814114258-ol1kn5rp4ji338yz
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: default-format
timestamp: Tue 2007-08-14 21:53:00 +1000
message:
doc
------------------------------------------------------------
revno: 2696.3.7
merged: mbp at sourcefrog.net-20070814114258-ol1kn5rp4ji338yz
parent: mbp at sourcefrog.net-20070814114234-an7afox3agf2u0sn
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: default-format
timestamp: Tue 2007-08-14 21:42:58 +1000
message:
Update hook test to cope with branches that can't set their last revision to one that's not present
------------------------------------------------------------
revno: 2696.3.6
merged: mbp at sourcefrog.net-20070814114234-an7afox3agf2u0sn
parent: mbp at sourcefrog.net-20070814111754-bcic7hx0iyqkgi2i
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: default-format
timestamp: Tue 2007-08-14 21:42:34 +1000
message:
Mark RemoteBranch as (possibly) supporting tags
------------------------------------------------------------
revno: 2696.3.5
merged: mbp at sourcefrog.net-20070814111754-bcic7hx0iyqkgi2i
parent: mbp at sourcefrog.net-20070814094530-ayg5xgnca168zt8c
parent: mbp at sourcefrog.net-20070814092821-1e5d80iyur5fjrrs
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: default-format
timestamp: Tue 2007-08-14 21:17:54 +1000
message:
merge append-revision fix
------------------------------------------------------------
revno: 2697.2.3
merged: mbp at sourcefrog.net-20070814092821-1e5d80iyur5fjrrs
parent: mbp at sourcefrog.net-20070814083806-zvnep336z68iqo1c
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: deprecate-append-revision
timestamp: Tue 2007-08-14 19:28:21 +1000
message:
More append_revision cleanup; _synchronize_history optimization
------------------------------------------------------------
revno: 2697.2.2
merged: mbp at sourcefrog.net-20070814083806-zvnep336z68iqo1c
parent: mbp at sourcefrog.net-20070814074725-z4vvr86cc20hf335
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: deprecate-append-revision
timestamp: Tue 2007-08-14 18:38:06 +1000
message:
deprecate Branch.append_revision
------------------------------------------------------------
revno: 2696.3.4
merged: mbp at sourcefrog.net-20070814094530-ayg5xgnca168zt8c
parent: mbp at sourcefrog.net-20070814094420-ct7ogmwjoz528i1k
parent: mbp at sourcefrog.net-20070814074725-z4vvr86cc20hf335
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: default-format
timestamp: Tue 2007-08-14 19:45:30 +1000
message:
merge trunk and 0.91 symbol deprecation
------------------------------------------------------------
revno: 2697.2.1
merged: mbp at sourcefrog.net-20070814074725-z4vvr86cc20hf335
parent: pqm at pqm.ubuntu.com-20070813221757-bianevqddds8ift5
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: prepare-0.91
timestamp: Tue 2007-08-14 17:47:25 +1000
message:
Switch to 0.91 release
------------------------------------------------------------
revno: 2696.3.3
merged: mbp at sourcefrog.net-20070814094420-ct7ogmwjoz528i1k
parent: mbp at sourcefrog.net-20070814052233-pse6ril0c2hmjm8f
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: default-format
timestamp: Tue 2007-08-14 19:44:20 +1000
message:
Start setting the default format to dirstate-tags
------------------------------------------------------------
revno: 2696.3.2
merged: mbp at sourcefrog.net-20070814052233-pse6ril0c2hmjm8f
parent: mbp at sourcefrog.net-20070814050549-fgxov55ryq2terjt
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: default-format
timestamp: Tue 2007-08-14 15:22:33 +1000
message:
Move some per-repository tests from big test_repository to test_fetch
------------------------------------------------------------
revno: 2696.3.1
merged: mbp at sourcefrog.net-20070814050549-fgxov55ryq2terjt
parent: pqm at pqm.ubuntu.com-20070813122444-5pi8f4fwxqpgxs1x
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: default-format
timestamp: Tue 2007-08-14 15:05:49 +1000
message:
(broken) start switching format to dirstate-tags
=== added file 'bzrlib/tests/repository_implementations/test_fetch.py'
--- a/bzrlib/tests/repository_implementations/test_fetch.py 1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/repository_implementations/test_fetch.py 2007-08-17 06:35:08 +0000
@@ -0,0 +1,94 @@
+# Copyright (C) 2007 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+"""Tests for fetch between repositories of the same type."""
+
+from bzrlib import (
+ bzrdir,
+ errors,
+ gpg,
+ )
+from bzrlib.tests import TestSkipped
+from bzrlib.tests.repository_implementations import TestCaseWithRepository
+from bzrlib.transport import get_transport
+
+
+class TestFetchSameRepository(TestCaseWithRepository):
+
+ def test_fetch(self):
+ # smoke test fetch to ensure that the convenience function works.
+ # it is defined as a convenience function with the underlying
+ # functionality provided by an InterRepository
+ tree_a = self.make_branch_and_tree('a')
+ self.build_tree(['a/foo'])
+ tree_a.add('foo', 'file1')
+ tree_a.commit('rev1', rev_id='rev1')
+ # fetch with a default limit (grab everything)
+ repo = bzrdir.BzrDir.create_repository(self.get_url('b'))
+ if (tree_a.branch.repository.supports_rich_root() and not
+ repo.supports_rich_root()):
+ raise TestSkipped('Cannot fetch from model2 to model1')
+ repo.fetch(tree_a.branch.repository,
+ revision_id=None)
+ ## pb=bzrlib.progress.DummyProgress())
+
+ def test_fetch_knit3(self):
+ # create a repository of the sort we are testing.
+ tree_a = self.make_branch_and_tree('a', '')
+ self.build_tree(['a/foo'])
+ tree_a.add('foo', 'file1')
+ tree_a.commit('rev1', rev_id='rev1')
+ # create a knit-3 based format to fetch into
+ f = bzrdir.format_registry.make_bzrdir('dirstate-with-subtree')
+ try:
+ format = tree_a.branch.repository._format
+ format.check_conversion_target(f.repository_format)
+ # if we cannot convert data to knit3, skip the test.
+ except errors.BadConversionTarget, e:
+ raise TestSkipped(str(e))
+ self.get_transport().mkdir('b')
+ b_bzrdir = f.initialize(self.get_url('b'))
+ knit3_repo = b_bzrdir.create_repository()
+ # fetch with a default limit (grab everything)
+ knit3_repo.fetch(tree_a.branch.repository, revision_id=None)
+ rev1_tree = knit3_repo.revision_tree('rev1')
+ lines = rev1_tree.get_file_lines(rev1_tree.inventory.root.file_id)
+ self.assertEqual([], lines)
+ b_branch = b_bzrdir.create_branch()
+ b_branch.pull(tree_a.branch)
+ try:
+ tree_b = b_bzrdir.create_workingtree()
+ except errors.NotLocalUrl:
+ raise TestSkipped("cannot make working tree with transport %r"
+ % b_bzrdir.transport)
+ tree_b.commit('no change', rev_id='rev2')
+ rev2_tree = knit3_repo.revision_tree('rev2')
+ self.assertEqual('rev1', rev2_tree.inventory.root.revision)
+
+ def makeARepoWithSignatures(self):
+ wt = self.make_branch_and_tree('a-repo-with-sigs')
+ wt.commit('rev1', allow_pointless=True, rev_id='rev1')
+ repo = wt.branch.repository
+ repo.sign_revision('rev1', gpg.LoopbackGPGStrategy(None))
+ return repo
+
+ def test_fetch_copies_signatures(self):
+ source_repo = self.makeARepoWithSignatures()
+ target_repo = self.make_repository('target')
+ target_repo.fetch(source_repo, revision_id=None)
+ self.assertEqual(
+ source_repo.get_signature_text('rev1'),
+ target_repo.get_signature_text('rev1'))
=== modified file 'NEWS'
--- a/NEWS 2007-08-16 06:43:12 +0000
+++ b/NEWS 2007-08-17 05:16:14 +0000
@@ -1,5 +1,12 @@
IN DEVELOPMENT
+ CHANGES:
+
+ * 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.
+ (Martin Pool)
+
FEATURES:
* New option ``--author`` in ``bzr commit`` to specify the author of the
@@ -18,7 +25,12 @@
* ``pull -v`` no longer includes deltas, making it much faster.
(Aaron Bentley)
- API CHANGES:
+ API BREAKS:
+
+ * ``Branch.append_revision`` is removed altogether; please use
+ ``Branch.set_last_revision_info`` instead. (Martin Pool)
+
+ aPI CHANGES:
* ``Transport.should_cache`` has been removed. It was not called in the
previous release. (Martin Pool)
=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py 2007-08-15 04:33:34 +0000
+++ b/bzrlib/branch.py 2007-08-17 05:16:14 +0000
@@ -59,6 +59,7 @@
DEPRECATED_PARAMETER,
deprecated_passed,
zero_eight, zero_nine, zero_sixteen,
+ zero_ninetyone,
)
from bzrlib.trace import mutter, note
@@ -351,9 +352,6 @@
"""Print `file` to stdout."""
raise NotImplementedError(self.print_file)
- def append_revision(self, *revision_ids):
- raise NotImplementedError(self.append_revision)
-
def set_revision_history(self, rev_history):
raise NotImplementedError(self.set_revision_history)
@@ -1114,13 +1112,14 @@
class BzrBranchFormat6(BzrBranchFormat5):
- """Branch format with last-revision
+ """Branch format with last-revision and tags.
Unlike previous formats, this has no explicit revision history. Instead,
this just stores the last-revision, and the left-hand history leading
up to there is the history.
This format was introduced in bzr 0.15
+ and became the default in 0.91.
"""
def get_format_string(self):
@@ -1239,11 +1238,12 @@
# formats which have no format string are not discoverable
# and not independently creatable, so are not registered.
-__default_format = BzrBranchFormat5()
-BranchFormat.register_format(__default_format)
+__format5 = BzrBranchFormat5()
+__format6 = BzrBranchFormat6()
+BranchFormat.register_format(__format5)
BranchFormat.register_format(BranchReferenceFormat())
-BranchFormat.register_format(BzrBranchFormat6())
-BranchFormat.set_default_format(__default_format)
+BranchFormat.register_format(__format6)
+BranchFormat.set_default_format(__format6)
_legacy_formats = [BzrBranchFormat4(),
]
@@ -1341,17 +1341,6 @@
"""See Branch.print_file."""
return self.repository.print_file(file, revision_id)
- @needs_write_lock
- def append_revision(self, *revision_ids):
- """See Branch.append_revision."""
- revision_ids = [osutils.safe_revision_id(r) for r in revision_ids]
- for revision_id in revision_ids:
- _mod_revision.check_not_reserved_id(revision_id)
- mutter("add {%s} to revision-history" % revision_id)
- rev_history = self.revision_history()
- rev_history.extend(revision_ids)
- self.set_revision_history(rev_history)
-
def _write_revision_history(self, history):
"""Factored out of set_revision_history.
@@ -1372,6 +1361,16 @@
@needs_write_lock
def set_last_revision_info(self, revno, revision_id):
+ """Set the last revision of this branch.
+
+ The caller is responsible for checking that the revno is correct
+ for this revision id.
+
+ It may be possible to set the branch last revision to an id not
+ present in the repository. However, branches can also be
+ configured to check constraints on history, in which case this may not
+ be permitted.
+ """
revision_id = osutils.safe_revision_id(revision_id)
history = self._lefthand_history(revision_id)
assert len(history) == revno, '%d != %d' % (len(history), revno)
@@ -1959,25 +1958,6 @@
self._write_last_revision_info(len(history), last_revision)
@needs_write_lock
- def append_revision(self, *revision_ids):
- revision_ids = [osutils.safe_revision_id(r) for r in revision_ids]
- if len(revision_ids) == 0:
- return
- prev_revno, prev_revision = self.last_revision_info()
- for revision in self.repository.get_revisions(revision_ids):
- if prev_revision == _mod_revision.NULL_REVISION:
- if revision.parent_ids != []:
- raise errors.NotLeftParentDescendant(self, prev_revision,
- revision.revision_id)
- else:
- if revision.parent_ids[0] != prev_revision:
- raise errors.NotLeftParentDescendant(self, prev_revision,
- revision.revision_id)
- prev_revision = revision.revision_id
- self.set_last_revision_info(prev_revno + len(revision_ids),
- revision_ids[-1])
-
- @needs_write_lock
def _set_parent_location(self, url):
"""Set the parent branch"""
self._set_config_location('parent_location', url, make_relative=True)
@@ -2049,8 +2029,12 @@
:param revision_id: The revision-id to truncate history at. May
be None to copy complete history.
"""
+ source_revno, source_revision_id = self.last_revision_info()
if revision_id is None:
- revno, revision_id = self.last_revision_info()
+ revno, revision_id = source_revno, source_revision_id
+ elif source_revision_id == revision_id:
+ # we know the revno without needing to walk all of history
+ revno = source_revno
else:
# To figure out the revno for a random revision, we need to build
# the revision history, and count its length.
=== modified file 'bzrlib/bzrdir.py'
--- a/bzrlib/bzrdir.py 2007-08-07 01:58:45 +0000
+++ b/bzrlib/bzrdir.py 2007-08-14 05:05:49 +0000
@@ -2432,4 +2432,4 @@
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
hidden=True,
)
-format_registry.set_default('dirstate')
+format_registry.set_default('dirstate-tags')
=== modified file 'bzrlib/errors.py'
--- a/bzrlib/errors.py 2007-08-10 16:17:30 +0000
+++ b/bzrlib/errors.py 2007-08-14 11:17:54 +0000
@@ -962,14 +962,16 @@
class NoSuchRevision(BzrError):
- _fmt = "Branch %(branch)s has no revision %(revision)s"
+ _fmt = "%(branch)s has no revision %(revision)s"
internal_error = True
def __init__(self, branch, revision):
+ # 'branch' may sometimes be an internal object like a KnitRevisionStore
BzrError.__init__(self, branch=branch, revision=revision)
+# zero_ninetyone: this exception is no longer raised and should be removed
class NotLeftParentDescendant(BzrError):
_fmt = ("Revision %(old_revision)s is not the left parent of"
=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py 2007-08-15 11:24:06 +0000
+++ b/bzrlib/remote.py 2007-08-17 05:16:14 +0000
@@ -33,6 +33,10 @@
from bzrlib.lockable_files import LockableFiles
from bzrlib.revision import NULL_REVISION
from bzrlib.smart import client, vfs
+from bzrlib.symbol_versioning import (
+ deprecated_method,
+ zero_ninetyone,
+ )
from bzrlib.trace import note
# Note: RemoteBzrDirFormat is in bzrdir.py
@@ -797,6 +801,11 @@
assert isinstance(a_bzrdir, RemoteBzrDir)
return a_bzrdir.create_branch()
+ def supports_tags(self):
+ # Remote branches might support tags, but we won't know until we
+ # access the real remote branch.
+ return True
+
class RemoteBranch(branch.Branch):
"""Branch stored on a server accessed by HPSS RPC.
@@ -1070,11 +1079,6 @@
return result
@needs_write_lock
- def append_revision(self, *revision_ids):
- self._ensure_real()
- return self._real_branch.append_revision(*revision_ids)
-
- @needs_write_lock
def pull(self, source, overwrite=False, stop_revision=None,
**kwargs):
# FIXME: This asks the real branch to run the hooks, which means
=== modified file 'bzrlib/store/revision/knit.py'
--- a/bzrlib/store/revision/knit.py 2007-07-10 21:18:54 +0000
+++ b/bzrlib/store/revision/knit.py 2007-08-14 09:44:20 +0000
@@ -62,6 +62,10 @@
super(KnitRevisionStore, self).__init__()
self.versioned_file_store = versioned_file_store
+ def __repr__(self):
+ return "%s(%s)" % (self.__class__.__name__,
+ self.versioned_file_store)
+
def _add_revision(self, revision, revision_as_file, transaction):
"""Template method helper to store revision in this store."""
# FIXME: make this ghost aware at the knit level
=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py 2007-08-16 07:33:57 +0000
+++ b/bzrlib/tests/__init__.py 2007-08-17 05:08:52 +0000
@@ -1004,6 +1004,13 @@
Note that this only captures warnings raised by symbol_versioning.warn,
not other callers that go direct to the warning module.
+ To test that a deprecated method raises an error, do something like
+ this::
+
+ self.assertRaises(errors.ReservedId,
+ self.applyDeprecated, zero_ninetyone,
+ br.append_revision, 'current:')
+
:param deprecation_format: The deprecation format that the callable
should have been deprecated with. This is the same type as the
parameter to deprecated_method/deprecated_function. If the
=== modified file 'bzrlib/tests/blackbox/test_info.py'
--- a/bzrlib/tests/blackbox/test_info.py 2007-07-06 18:30:50 +0000
+++ b/bzrlib/tests/blackbox/test_info.py 2007-08-14 11:17:54 +0000
@@ -483,7 +483,7 @@
repo = branch.repository
out, err = self.run_bzr('info branch -v')
self.assertEqualDiff(
-"""Standalone branch (format: dirstate or knit)
+"""Standalone branch (format: dirstate-tags)
Location:
branch root: branch
=== modified file 'bzrlib/tests/branch_implementations/test_branch.py'
--- a/bzrlib/tests/branch_implementations/test_branch.py 2007-08-07 22:59:45 +0000
+++ b/bzrlib/tests/branch_implementations/test_branch.py 2007-08-17 05:01:28 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2005, 2006 Canonical Ltd
+# Copyright (C) 2005, 2006, 2007 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
@@ -47,25 +47,13 @@
from bzrlib.transport.memory import MemoryServer
from bzrlib.upgrade import upgrade
from bzrlib.workingtree import WorkingTree
+from bzrlib.symbol_versioning import (
+ zero_ninetyone,
+ )
class TestBranch(TestCaseWithBranch):
- def test_append_revisions(self):
- """Test appending more than one revision"""
- wt = self.make_branch_and_tree('tree')
- wt.commit('f', rev_id='rev1')
- wt.commit('f', rev_id='rev2')
- wt.commit('f', rev_id='rev3')
-
- br = self.get_branch()
- br.fetch(wt.branch)
- br.append_revision("rev1")
- self.assertEquals(br.revision_history(), ["rev1",])
- br.append_revision("rev2", "rev3")
- self.assertEquals(br.revision_history(), ["rev1", "rev2", "rev3"])
- self.assertRaises(errors.ReservedId, br.append_revision, 'current:')
-
def test_create_tree_with_merge(self):
tree = self.create_tree_with_merge()
ancestry_graph = tree.branch.repository.get_revision_graph('rev-3')
=== modified file 'bzrlib/tests/branch_implementations/test_hooks.py'
--- a/bzrlib/tests/branch_implementations/test_hooks.py 2007-03-02 18:59:00 +0000
+++ b/bzrlib/tests/branch_implementations/test_hooks.py 2007-08-14 11:42:58 +0000
@@ -45,10 +45,13 @@
tree = self.make_branch_and_memory_tree('source')
tree.lock_write()
tree.add('')
+ tree.commit('another commit', rev_id='f\xc2\xb5')
tree.commit('empty commit', rev_id='foo')
tree.unlock()
branch = tree.branch
Branch.hooks.install_hook('set_rh', self.capture_set_rh_hook)
+ # some branches require that their history be set to a revision in the
+ # repository
branch.set_revision_history(['f\xc2\xb5'])
self.assertEqual(self.hook_calls,
[('set_rh', branch, ['f\xc2\xb5'], True)])
=== modified file 'bzrlib/tests/branch_implementations/test_revision_history.py'
--- a/bzrlib/tests/branch_implementations/test_revision_history.py 2007-03-26 06:24:01 +0000
+++ b/bzrlib/tests/branch_implementations/test_revision_history.py 2007-08-14 08:38:06 +0000
@@ -14,12 +14,38 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-"""Tests for Branch.revision_history."""
+"""Tests for Branch.revision_history and last_revision."""
-from bzrlib import branch
+from bzrlib import (
+ branch,
+ errors,
+ )
from bzrlib.tests.branch_implementations.test_branch import TestCaseWithBranch
+class TestLastRevision(TestCaseWithBranch):
+ """Tests for the last_revision property of the branch.
+ """
+
+ def test_set_last_revision_info(self):
+ # based on TestBranch.test_append_revisions, which uses the old
+ # append_revision api
+ wt = self.make_branch_and_tree('tree')
+ wt.commit('f', rev_id='rev1')
+ wt.commit('f', rev_id='rev2')
+ wt.commit('f', rev_id='rev3')
+ br = self.get_branch()
+ br.fetch(wt.branch)
+ br.set_last_revision_info(1, 'rev1')
+ self.assertEquals(br.revision_history(), ["rev1",])
+ br.set_last_revision_info(3, 'rev3')
+ self.assertEquals(br.revision_history(), ["rev1", "rev2", "rev3"])
+ # append_revision specifically prohibits some ids;
+ # set_last_revision_info currently does not
+ ## self.assertRaises(errors.ReservedId,
+ ## br.set_last_revision_info, 4, 'current:')
+
+
class TestRevisionHistoryCaching(TestCaseWithBranch):
"""Tests for the caching of branches' revision_history.
=== modified file 'bzrlib/tests/repository_implementations/__init__.py'
--- a/bzrlib/tests/repository_implementations/__init__.py 2007-08-15 11:24:06 +0000
+++ b/bzrlib/tests/repository_implementations/__init__.py 2007-08-17 05:16:14 +0000
@@ -100,6 +100,7 @@
test_repository_implementations = [
'bzrlib.tests.repository_implementations.test_break_lock',
'bzrlib.tests.repository_implementations.test_commit_builder',
+ 'bzrlib.tests.repository_implementations.test_fetch',
'bzrlib.tests.repository_implementations.test_fileid_involved',
'bzrlib.tests.repository_implementations.test_has_same_location',
'bzrlib.tests.repository_implementations.test_iter_reverse_revision_history',
=== modified file 'bzrlib/tests/repository_implementations/test_repository.py'
--- a/bzrlib/tests/repository_implementations/test_repository.py 2007-08-14 03:40:57 +0000
+++ b/bzrlib/tests/repository_implementations/test_repository.py 2007-08-17 05:16:14 +0000
@@ -160,71 +160,6 @@
tree = wt.branch.repository.revision_tree(NULL_REVISION)
self.assertEqual([], list(tree.list_files(include_root=True)))
- def test_fetch(self):
- # smoke test fetch to ensure that the convenience function works.
- # it is defined as a convenience function with the underlying
- # functionality provided by an InterRepository
- tree_a = self.make_branch_and_tree('a')
- self.build_tree(['a/foo'])
- tree_a.add('foo', 'file1')
- tree_a.commit('rev1', rev_id='rev1')
- # fetch with a default limit (grab everything)
- repo = bzrdir.BzrDir.create_repository(self.get_url('b'))
- if (tree_a.branch.repository.supports_rich_root() and not
- repo.supports_rich_root()):
- raise TestSkipped('Cannot fetch from model2 to model1')
- repo.fetch(tree_a.branch.repository,
- revision_id=None,
- pb=bzrlib.progress.DummyProgress())
-
- def test_fetch_knit3(self):
- # create a repository of the sort we are testing.
- tree_a = self.make_branch_and_tree('a', '')
- self.build_tree(['a/foo'])
- tree_a.add('foo', 'file1')
- tree_a.commit('rev1', rev_id='rev1')
- # create a knit-3 based format to fetch into
- f = bzrdir.format_registry.make_bzrdir('dirstate-with-subtree')
- try:
- format = tree_a.branch.repository._format
- format.check_conversion_target(f.repository_format)
- # if we cannot convert data to knit3, skip the test.
- except errors.BadConversionTarget, e:
- raise TestSkipped(str(e))
- self.get_transport().mkdir('b')
- b_bzrdir = f.initialize(self.get_url('b'))
- knit3_repo = b_bzrdir.create_repository()
- # fetch with a default limit (grab everything)
- knit3_repo.fetch(tree_a.branch.repository, revision_id=None)
- rev1_tree = knit3_repo.revision_tree('rev1')
- lines = rev1_tree.get_file_lines(rev1_tree.inventory.root.file_id)
- self.assertEqual([], lines)
- b_branch = b_bzrdir.create_branch()
- b_branch.pull(tree_a.branch)
- try:
- tree_b = b_bzrdir.create_workingtree()
- except errors.NotLocalUrl:
- raise TestSkipped("cannot make working tree with transport %r"
- % b_bzrdir.transport)
- tree_b.commit('no change', rev_id='rev2')
- rev2_tree = knit3_repo.revision_tree('rev2')
- self.assertEqual('rev1', rev2_tree.inventory.root.revision)
-
- def makeARepoWithSignatures(self):
- wt = self.make_branch_and_tree('a-repo-with-sigs')
- wt.commit('rev1', allow_pointless=True, rev_id='rev1')
- repo = wt.branch.repository
- repo.sign_revision('rev1', bzrlib.gpg.LoopbackGPGStrategy(None))
- return repo
-
- def test_fetch_copies_signatures(self):
- source_repo = self.makeARepoWithSignatures()
- target_repo = self.make_repository('target')
- target_repo.fetch(source_repo, revision_id=None)
- self.assertEqual(
- source_repo.get_signature_text('rev1'),
- target_repo.get_signature_text('rev1'))
-
def test_get_revision_delta(self):
tree_a = self.make_branch_and_tree('a')
self.build_tree(['a/foo'])
=== modified file 'bzrlib/tests/test_branch.py'
--- a/bzrlib/tests/test_branch.py 2007-07-04 14:53:53 +0000
+++ b/bzrlib/tests/test_branch.py 2007-08-14 11:53:00 +0000
@@ -39,6 +39,7 @@
BranchReferenceFormat,
BzrBranch5,
BzrBranchFormat5,
+ BzrBranchFormat6,
PullResult,
)
from bzrlib.bzrdir import (BzrDirMetaFormat1, BzrDirMeta1,
@@ -54,10 +55,21 @@
class TestDefaultFormat(TestCase):
+ def test_default_format(self):
+ # update this if you change the default branch format
+ self.assertIsInstance(BranchFormat.get_default_format(),
+ BzrBranchFormat6)
+
+ def test_default_format_is_same_as_bzrdir_default(self):
+ # XXX: it might be nice if there was only one place the default was
+ # set, but at the moment that's not true -- mbp 20070814 --
+ # https://bugs.launchpad.net/bzr/+bug/132376
+ self.assertEqual(BranchFormat.get_default_format(),
+ BzrDirFormat.get_default_format().get_branch_format())
+
def test_get_set_default_format(self):
+ # set the format and then set it back again
old_format = BranchFormat.get_default_format()
- # default is 5
- self.assertTrue(isinstance(old_format, BzrBranchFormat5))
BranchFormat.set_default_format(SampleBranchFormat())
try:
# the default branch format is used by the meta dir format
@@ -224,32 +236,6 @@
finally:
tree.unlock()
- def test_append_revision(self):
- tree = self.make_branch_and_tree('branch1',
- format='dirstate-tags')
- tree.lock_write()
- try:
- tree.commit('foo', rev_id='foo')
- tree.commit('bar', rev_id='bar')
- tree.commit('baz', rev_id='baz')
- tree.set_last_revision('bar')
- tree.branch.set_last_revision_info(2, 'bar')
- tree.commit('qux', rev_id='qux')
- tree.add_parent_tree_id('baz')
- tree.commit('qux', rev_id='quxx')
- tree.branch.set_last_revision_info(0, 'null:')
- self.assertRaises(errors.NotLeftParentDescendant,
- tree.branch.append_revision, 'bar')
- tree.branch.append_revision('foo')
- self.assertRaises(errors.NotLeftParentDescendant,
- tree.branch.append_revision, 'baz')
- tree.branch.append_revision('bar')
- tree.branch.append_revision('baz')
- self.assertRaises(errors.NotLeftParentDescendant,
- tree.branch.append_revision, 'quxx')
- finally:
- tree.unlock()
-
def do_checkout_test(self, lightweight=False):
tree = self.make_branch_and_tree('source', format='dirstate-with-subtree')
subtree = self.make_branch_and_tree('source/subtree',
@@ -276,7 +262,6 @@
else:
self.assertEndsWith(subbranch.base, 'target/subtree/subsubtree/')
-
def test_checkout_with_references(self):
self.do_checkout_test()
=== modified file 'bzrlib/tests/test_fetch.py'
--- a/bzrlib/tests/test_fetch.py 2007-07-25 22:03:13 +0000
+++ b/bzrlib/tests/test_fetch.py 2007-08-17 05:16:14 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2005 Canonical Ltd
+# Copyright (C) 2005, 2007 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
@@ -18,6 +18,7 @@
import re
import sys
+import bzrlib
from bzrlib import (
bzrdir,
errors,
@@ -26,8 +27,10 @@
)
from bzrlib.branch import Branch
from bzrlib.bzrdir import BzrDir
-import bzrlib.errors
from bzrlib.repofmt import knitrepo
+from bzrlib.symbol_versioning import (
+ zero_ninetyone,
+ )
from bzrlib.tests import TestCaseWithTransport
from bzrlib.tests.HTTPTestUtil import TestCaseWithWebserver
from bzrlib.tests.test_revision import make_branches
@@ -35,6 +38,10 @@
from bzrlib.upgrade import Convert
from bzrlib.workingtree import WorkingTree
+# These tests are a bit old; please instead add new tests into
+# interrepository_implementations/ so they'll run on all relevant
+# combinations.
+
def has_revision(branch, revision_id):
return branch.repository.has_revision(revision_id)
@@ -94,18 +101,13 @@
self.assertEquals(fetched, 3, "fetched %d instead of 3" % fetched)
# InstallFailed should be raised if the branch is missing the revision
# that was requested.
- self.assertRaises(bzrlib.errors.InstallFailed, br_a3.fetch, br_a2, 'pizza')
- # InstallFailed should be raised if the branch is missing a revision
- # from its own revision history
- br_a2.append_revision('a-b-c')
- self.assertRaises(bzrlib.errors.InstallFailed, br_a3.fetch, br_a2)
+ self.assertRaises(errors.InstallFailed, br_a3.fetch, br_a2, 'pizza')
- # TODO: ADHB 20070116 Perhaps set_last_revision shouldn't accept
- # revisions which are not present? In that case, this test
- # must be rewritten.
- #
- # RBC 20060403 the way to do this is to uncommit the revision from
- # the repository after the commit
+ # TODO: Test trying to fetch from a branch that points to a revision not
+ # actually present in its repository. Not every branch format allows you
+ # to directly point to such revisions, so it's a bit complicated to
+ # construct. One way would be to uncommit and gc the revision, but not
+ # every branch supports that. -- mbp 20070814
#TODO: test that fetch correctly does reweaving when needed. RBC 20051008
# Note that this means - updating the weave when ghosts are filled in to
@@ -116,7 +118,7 @@
def test_fetch(self):
#highest indices a: 5, b: 7
- br_a, br_b = make_branches(self)
+ br_a, br_b = make_branches(self, format='dirstate-tags')
fetch_steps(self, br_a, br_b, br_a)
def test_fetch_self(self):
=== modified file 'bzrlib/tests/test_revision.py'
--- a/bzrlib/tests/test_revision.py 2007-06-08 21:48:42 +0000
+++ b/bzrlib/tests/test_revision.py 2007-08-14 09:44:20 +0000
@@ -39,7 +39,7 @@
r'bzrlib\.tests\.test_revision')
# XXX: Make this a method of a merge base case
-def make_branches(self):
+def make_branches(self, format=None):
"""Create two branches
branch 1 has 6 commits, branch 2 has 3 commits
@@ -58,7 +58,7 @@
so A is missing b6 at the start
and B is missing a3, a4, a5
"""
- tree1 = self.make_branch_and_tree("branch1")
+ tree1 = self.make_branch_and_tree("branch1", format=format)
br1 = tree1.branch
tree1.commit("Commit one", rev_id="a at u-0-0")
More information about the bazaar-commits
mailing list