~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/branch_implementations/test_stacking.py

  • Committer: Andrew Bennetts
  • Date: 2008-08-07 00:25:38 UTC
  • mfrom: (3612 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3613.
  • Revision ID: andrew.bennetts@canonical.com-20080807002538-mtl1fcgy2fdabha4
Merge from bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
258
258
        unstacked.fetch(stacked.branch.repository, 'rev2')
259
259
        unstacked.get_revision('rev1')
260
260
        unstacked.get_revision('rev2')
 
261
 
 
262
    def test_autopack_when_stacked(self):
 
263
        # in bzr.dev as of 20080730, autopack was reported to fail in stacked
 
264
        # repositories because of problems with text deltas spanning physical
 
265
        # repository boundaries.  however, i didn't actually get this test to
 
266
        # fail on that code. -- mbp
 
267
        # see https://bugs.launchpad.net/bzr/+bug/252821
 
268
        if not self.branch_format.supports_stacking():
 
269
            raise TestNotApplicable("%r does not support stacking"
 
270
                % self.branch_format)
 
271
        stack_on = self.make_branch_and_tree('stack-on')
 
272
        text_lines = ['line %d blah blah blah\n' % i for i in range(20)]
 
273
        self.build_tree_contents([('stack-on/a', ''.join(text_lines))])
 
274
        stack_on.add('a')
 
275
        stack_on.commit('base commit')
 
276
        stacked_dir = stack_on.bzrdir.sprout('stacked', stacked=True)
 
277
        stacked_tree = stacked_dir.open_workingtree()
 
278
        for i in range(20):
 
279
            text_lines[0] = 'changed in %d\n' % i
 
280
            self.build_tree_contents([('stacked/a', ''.join(text_lines))])
 
281
            stacked_tree.commit('commit %d' % i)
 
282
        stacked_tree.branch.repository.pack()
 
283
        stacked_tree.branch.check()
 
284
 
 
285
    def test_pull_delta_when_stacked(self):
 
286
        if not self.branch_format.supports_stacking():
 
287
            raise TestNotApplicable("%r does not support stacking"
 
288
                % self.branch_format)
 
289
        stack_on = self.make_branch_and_tree('stack-on')
 
290
        text_lines = ['line %d blah blah blah\n' % i for i in range(20)]
 
291
        self.build_tree_contents([('stack-on/a', ''.join(text_lines))])
 
292
        stack_on.add('a')
 
293
        stack_on.commit('base commit')
 
294
        # make a stacked branch from the mainline
 
295
        stacked_dir = stack_on.bzrdir.sprout('stacked', stacked=True)
 
296
        stacked_tree = stacked_dir.open_workingtree()
 
297
        # make a second non-stacked branch from the mainline
 
298
        other_dir = stack_on.bzrdir.sprout('other')
 
299
        other_tree = other_dir.open_workingtree()
 
300
        text_lines[9] = 'changed in other\n'
 
301
        self.build_tree_contents([('other/a', ''.join(text_lines))])
 
302
        other_tree.commit('commit in other')
 
303
        # this should have generated a delta; try to pull that across
 
304
        # bug 252821 caused a RevisionNotPresent here...
 
305
        stacked_tree.pull(other_tree.branch)
 
306
        stacked_tree.branch.repository.pack()
 
307
        stacked_tree.branch.check()
 
308
 
 
309
    def test_fetch_revisions_with_file_changes(self):
 
310
        # Fetching revisions including file changes into a stacked branch
 
311
        # works without error.
 
312
        # Make the source tree.
 
313
        src_tree = self.make_branch_and_tree('src')
 
314
        self.build_tree_contents([('src/a', 'content')])
 
315
        src_tree.add('a')
 
316
        src_tree.commit('first commit')
 
317
 
 
318
        # Make the stacked-on branch.
 
319
        src_tree.bzrdir.sprout('stacked-on')
 
320
 
 
321
        # Make a branch stacked on it.
 
322
        target = self.make_branch('target')
 
323
        try:
 
324
            target.set_stacked_on_url('../stacked-on')
 
325
        except (errors.UnstackableRepositoryFormat,
 
326
                errors.UnstackableBranchFormat):
 
327
            raise TestNotApplicable('Format does not support stacking.')
 
328
 
 
329
        # Change the source branch.
 
330
        self.build_tree_contents([('src/a', 'new content')])
 
331
        src_tree.commit('second commit', rev_id='rev2')
 
332
 
 
333
        # Fetch changes to the target.
 
334
        target.fetch(src_tree.branch)
 
335
        rtree = target.repository.revision_tree('rev2')
 
336
        rtree.lock_read()
 
337
        self.addCleanup(rtree.unlock)
 
338
        self.assertEqual('new content', rtree.get_file_by_path('a').read())