def _time_read_write(self): branch, relpath = Branch.open_containing("a") revision_history = branch.revision_history() bundle_text = StringIO() write_bundle(branch.repository, revision_history[-1], NULL_REVISION, bundle_text) bundle_text.seek(0) target_tree = self.make_branch_and_tree('b') bundle = self.time(read_bundle, bundle_text) self.time(install_bundle, target_tree.branch.repository, bundle)
def do(self, path, revision_id): # open transport relative to our base t = self.transport_from_client_path(path) control, extra_path = bzrdir.BzrDir.open_containing_from_transport(t) repo = control.open_repository() tmpf = tempfile.TemporaryFile() base_revision = revision.NULL_REVISION write_bundle(repo, revision_id, base_revision, tmpf) tmpf.seek(0) return SuccessfulSmartServerResponse((), tmpf.read())
def test_apply_bundle_known_kernel_like_tree(self): """Create a bundle for a kernel sized tree with no ignored, unknowns, or added and one commit. """ tree = self.make_kernel_like_committed_tree('tree') f = open('bundle', 'wb') try: write_bundle(tree.branch.repository, tree.last_revision(), NULL_REVISION, f) finally: f.close() tree2 = self.make_branch_and_tree('branch_a') os.chdir('branch_a') self.time(self.run_bzr, ['merge', '../bundle'])
def create_bundle_file(test_case): test_case.build_tree(['tree/', 'tree/a', 'tree/subdir/']) format = bzrlib.bzrdir.BzrDirFormat.get_default_format() bzrdir = format.initialize('tree') repo = bzrdir.create_repository() branch = repo.bzrdir.create_branch() wt = branch.bzrdir.create_workingtree() wt.add(['a', 'subdir/']) wt.commit('new project', rev_id='commit-1') out = cStringIO.StringIO() rev_ids = write_bundle(wt.branch.repository, wt.get_parent_ids()[0], 'null:', out) out.seek(0) return out, wt
def _generate_bundle(repository, revision_id, ancestor_id): s = StringIO() bundle_serializer.write_bundle(repository, revision_id, ancestor_id, s, '0.9') return s.getvalue()