15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
from bzrlib import bzrdir, repository
22
20
from bzrlib.branch import Branch
23
21
from bzrlib.bzrdir import BzrDir
24
22
from bzrlib.builtins import merge
27
25
from bzrlib.tests.HTTPTestUtil import TestCaseWithWebserver
28
26
from bzrlib.tests.test_revision import make_branches
29
27
from bzrlib.trace import mutter
30
from bzrlib.upgrade import Convert
31
28
from bzrlib.workingtree import WorkingTree
116
113
wt = self.make_branch_and_tree('br')
117
114
self.assertEqual(wt.branch.fetch(wt.branch), (0, []))
119
def test_fetch_root_knit(self):
120
"""Ensure that knit2.fetch() updates the root knit
122
This tests the case where the root has a new revision, but there are no
123
corresponding filename, parent, contents or other changes.
125
knit1_format = bzrdir.BzrDirMetaFormat1()
126
knit1_format.repository_format = repository.RepositoryFormatKnit1()
127
knit2_format = bzrdir.BzrDirMetaFormat1()
128
knit2_format.repository_format = repository.RepositoryFormatKnit2()
129
# we start with a knit1 repository because that causes the
130
# root revision to change for each commit, even though the content,
131
# parent, name, and other attributes are unchanged.
132
tree = self.make_branch_and_tree('tree', knit1_format)
133
tree.set_root_id('tree-root')
134
tree.commit('rev1', rev_id='rev1')
135
tree.commit('rev2', rev_id='rev2')
137
# Now we convert it to a knit2 repository so that it has a root knit
138
Convert(tree.basedir, knit2_format)
139
tree = WorkingTree.open(tree.basedir)
140
branch = self.make_branch('branch', format=knit2_format)
141
branch.pull(tree.branch, stop_revision='rev1')
142
repo = branch.repository
143
root_knit = repo.weave_store.get_weave('tree-root',
144
repo.get_transaction())
145
# Make sure fetch retrieved only what we requested
146
self.assertTrue('rev1' in root_knit)
147
self.assertTrue('rev2' not in root_knit)
148
branch.pull(tree.branch)
149
root_knit = repo.weave_store.get_weave('tree-root',
150
repo.get_transaction())
151
# Make sure that the next revision in the root knit was retrieved,
152
# even though the text, name, parent_id, etc., were unchanged.
153
self.assertTrue('rev2' in root_knit)
156
117
class TestMergeFetch(TestCaseWithTransport):
238
199
def _count_log_matches(self, target, logs):
239
200
"""Count the number of times the target file pattern was fetched in an http log"""
240
get_succeeds_re = re.compile(
241
'.*"GET .*%s HTTP/1.1" 20[06] - "-" "bzr/%s' %
242
( target, bzrlib.__version__))
201
log_pattern = '%s HTTP/1.1" 200 - "-" "bzr/%s' % \
202
(target, bzrlib.__version__)
244
204
for line in logs:
245
if get_succeeds_re.match(line):
205
# TODO: perhaps use a regexp instead so we can match more
207
if line.find(log_pattern) > -1:
257
219
target = BzrDir.create_branch_and_repo("target/")
258
220
source = Branch.open(self.get_readonly_url("source/"))
259
221
self.assertEqual(target.fetch(source), (2, []))
222
log_pattern = '%%s HTTP/1.1" 200 - "-" "bzr/%s' % bzrlib.__version__
260
223
# this is the path to the literal file. As format changes
261
224
# occur it needs to be updated. FIXME: ask the store for the