def test_upgrade_v6_to_meta_no_workingtree(self): # Some format6 branches do not have checkout files. Upgrading # such a branch to metadir must not setup a working tree. self.build_tree_contents(_upgrade1_template) upgrade('.', bzrdir.BzrDirFormat6()) transport = get_transport('.') transport.delete_multi(['.bzr/pending-merges', '.bzr/inventory']) self.assertFalse(transport.has('.bzr/stat-cache')) # XXX: upgrade fails if a backup.bzr is already present # -- David Allouche 2006-08-11 transport.delete_tree('backup.bzr') # At this point, we have a format6 branch without checkout files. upgrade('.', bzrdir.BzrDirMetaFormat1()) # The upgrade should not have set up a working tree. control = bzrdir.BzrDir.open('.') self.assertFalse(control.has_workingtree()) # We have covered the scope of this test, we may as well check that # upgrade has not eaten our data, even if it's a bit redundant with # other tests. self.failUnless(isinstance(control._format, bzrdir.BzrDirMetaFormat1)) branch = control.open_branch() self.assertEquals(branch.revision_history(), [ '[email protected]', '[email protected]' ])
def test_stack_upgrade(self): """Correct checks when stacked-on repository is upgraded. We initially stack on a repo with the same rich root support, we then upgrade it and should fail, we then upgrade the overlaid repository. """ base = self.make_branch_and_tree('base', format=self.scenario_old_format) self.build_tree(['base/foo']) base.commit('base commit') # make another one stacked stacked = base.bzrdir.sprout('stacked', stacked=True) # this must really be stacked (or get_stacked_on_url raises an error) self.assertTrue(stacked.open_branch().get_stacked_on_url()) # now we'll upgrade the underlying branch, then upgrade the stacked # branch, and this should still work. new_format = bzrdir.format_registry.make_bzrdir( self.scenario_new_format) upgrade('base', new_format) # in some cases you'll get an error if the underlying model has # changed; if just the data format has changed this should still work if self.scenario_model_change: self.assertRaises(errors.IncompatibleRepositories, stacked.open_branch) else: stacked.open_branch().check() stacked = bzrdir.BzrDir.open('stacked') # but we can upgrade the stacked repository upgrade('stacked', new_format) # and now it's ok stacked = bzrdir.BzrDir.open('stacked') stacked.open_branch().check()
def test_upgrade_preserves_signatures(self): if not self.repository_format.supports_revision_signatures: raise tests.TestNotApplicable( "repository does not support signing revisions") wt = self.make_branch_and_tree('source') wt.commit('A', allow_pointless=True, rev_id='A') repo = wt.branch.repository repo.lock_write() repo.start_write_group() try: repo.sign_revision('A', gpg.LoopbackGPGStrategy(None)) except errors.UnsupportedOperation: self.assertFalse(repo._format.supports_revision_signatures) raise tests.TestNotApplicable( "signatures not supported by repository format") repo.commit_write_group() repo.unlock() old_signature = repo.get_signature_text('A') try: old_format = controldir.ControlDirFormat.get_default_format() # This gives metadir branches something they can convert to. # it would be nice to have a 'latest' vs 'default' concept. format = controldir.format_registry.make_bzrdir( 'development-subtree') upgrade.upgrade(repo.bzrdir.root_transport.base, format=format) except errors.UpToDateFormat: # this is in the most current format already. return except errors.BadConversionTarget, e: raise tests.TestSkipped(str(e))
def test_upgrade_to_meta_sets_workingtree_last_revision(self): self.build_tree_contents(_upgrade_dir_template) upgrade.upgrade('.', bzrdir.BzrDirMetaFormat1()) tree = workingtree.WorkingTree.open('.') self.addCleanup(tree.lock_read().unlock) self.assertEqual([tree.branch._revision_history()[-1]], tree.get_parent_ids())
def test_upgrade_preserves_signatures(self): if not self.repository_format.supports_revision_signatures: raise tests.TestNotApplicable( "repository does not support signing revisions") wt = self.make_branch_and_tree('source') wt.commit('A', allow_pointless=True, rev_id='A') repo = wt.branch.repository repo.lock_write() repo.start_write_group() try: repo.sign_revision('A', gpg.LoopbackGPGStrategy(None)) except errors.UnsupportedOperation: self.assertFalse(repo._format.supports_revision_signatures) raise tests.TestNotApplicable("signatures not supported by repository format") repo.commit_write_group() repo.unlock() old_signature = repo.get_signature_text('A') try: old_format = controldir.ControlDirFormat.get_default_format() # This gives metadir branches something they can convert to. # it would be nice to have a 'latest' vs 'default' concept. format = controldir.format_registry.make_bzrdir( 'development-subtree') upgrade.upgrade(repo.bzrdir.root_transport.base, format=format) except errors.UpToDateFormat: # this is in the most current format already. return except errors.BadConversionTarget, e: raise tests.TestSkipped(str(e))
def update_branches(sourcecode_directory, update_branches, possible_transports=None, tip=False, quiet=False): """Update the existing branches in sourcecode.""" if possible_transports is None: possible_transports = [] # XXX: JonathanLange 2009-11-09: Rather than updating one branch after # another, we could instead try to get them in parallel. for project, (branch_url, revision, optional) in (update_branches.iteritems()): # Update project from branch_url. destination = os.path.join(sourcecode_directory, project) if not quiet: print 'Updating %s to %s' % (project, _format_revision_name(revision, tip)) local_tree = WorkingTree.open(destination) try: remote_branch = Branch.open( branch_url, possible_transports=possible_transports) except BzrError: if optional: report_exception(sys.exc_info(), sys.stderr) continue else: raise possible_transports.append(remote_branch.bzrdir.root_transport) revision_id = get_revision_id(revision, remote_branch, tip) try: result = local_tree.pull(remote_branch, stop_revision=revision_id, overwrite=True, possible_transports=possible_transports) except IncompatibleRepositories: # XXX JRV 20100407: Ideally remote_branch.bzrdir._format # should be passed into upgrade() to ensure the format is the same # locally and remotely. Unfortunately smart server branches # have their _format set to RemoteFormat rather than an actual # format instance. upgrade(destination) # Upgraded, repoen working tree local_tree = WorkingTree.open(destination) result = local_tree.pull(remote_branch, stop_revision=revision_id, overwrite=True, possible_transports=possible_transports) if result.old_revid == result.new_revid: if not quiet: print ' (No change)' else: if result.old_revno < result.new_revno: change = 'Updated' else: change = 'Reverted' if not quiet: print ' (%s from %s to %s)' % (change, result.old_revno, result.new_revno)
def run(self, _check_transaction=False): """See `IBranchUpgradeJob`.""" # Set up the new branch structure with server(get_rw_server(), no_replace=True): upgrade_branch_path = tempfile.mkdtemp() try: upgrade_transport = get_transport(upgrade_branch_path) upgrade_transport.mkdir('.bzr') source_branch_transport = get_transport( self.branch.getInternalBzrUrl()) source_branch_transport.clone('.bzr').copy_tree_to_transport( upgrade_transport.clone('.bzr')) transaction.commit() upgrade_branch = BzrBranch.open_from_transport( upgrade_transport) # No transactions are open so the DB connection won't be # killed. with TransactionFreeOperation(): # Perform the upgrade. upgrade(upgrade_branch.base) # Re-open the branch, since its format has changed. upgrade_branch = BzrBranch.open_from_transport( upgrade_transport) source_branch = BzrBranch.open_from_transport( source_branch_transport) source_branch.lock_write() upgrade_branch.pull(source_branch) upgrade_branch.fetch(source_branch) source_branch.unlock() # Move the branch in the old format to backup.bzr try: source_branch_transport.delete_tree('backup.bzr') except NoSuchFile: pass source_branch_transport.rename('.bzr', 'backup.bzr') source_branch_transport.mkdir('.bzr') upgrade_transport.clone('.bzr').copy_tree_to_transport( source_branch_transport.clone('.bzr')) # Re-open the source branch again. source_branch = BzrBranch.open_from_transport( source_branch_transport) formats = get_branch_formats(source_branch) self.branch.branchChanged( self.branch.stacked_on, self.branch.last_scanned_id, *formats) finally: shutil.rmtree(upgrade_branch_path)
def update_branches(sourcecode_directory, update_branches, possible_transports=None, tip=False, quiet=False): """Update the existing branches in sourcecode.""" if possible_transports is None: possible_transports = [] # XXX: JonathanLange 2009-11-09: Rather than updating one branch after # another, we could instead try to get them in parallel. for project, (branch_url, revision, optional) in ( update_branches.iteritems()): # Update project from branch_url. destination = os.path.join(sourcecode_directory, project) if not quiet: print 'Updating %s to %s' % ( project, _format_revision_name(revision, tip)) local_tree = WorkingTree.open(destination) try: remote_branch = Branch.open( branch_url, possible_transports=possible_transports) except BzrError: if optional: report_exception(sys.exc_info(), sys.stderr) continue else: raise possible_transports.append( remote_branch.bzrdir.root_transport) revision_id = get_revision_id(revision, remote_branch, tip) try: result = local_tree.pull( remote_branch, stop_revision=revision_id, overwrite=True, possible_transports=possible_transports) except IncompatibleRepositories: # XXX JRV 20100407: Ideally remote_branch.bzrdir._format # should be passed into upgrade() to ensure the format is the same # locally and remotely. Unfortunately smart server branches # have their _format set to RemoteFormat rather than an actual # format instance. upgrade(destination) # Upgraded, repoen working tree local_tree = WorkingTree.open(destination) result = local_tree.pull( remote_branch, stop_revision=revision_id, overwrite=True, possible_transports=possible_transports) if result.old_revid == result.new_revid: if not quiet: print ' (No change)' else: if result.old_revno < result.new_revno: change = 'Updated' else: change = 'Reverted' if not quiet: print ' (%s from %s to %s)' % ( change, result.old_revno, result.new_revno)
def test_upgrade_simple(self): """Upgrade simple v0.0.4 format to latest format""" eq = self.assertEquals self.build_tree_contents(_upgrade1_template) upgrade.upgrade(u'.') control = controldir.ControlDir.open('.') b = control.open_branch() # tsk, peeking under the covers. self.assertIsInstance( control._format, bzrdir.BzrDirFormat.get_default_format().__class__) self.addCleanup(b.lock_read().unlock) rh = b._revision_history() eq(rh, ['[email protected]', '[email protected]']) rt = b.repository.revision_tree(rh[0]) foo_id = 'foo-20051004035605-91e788d1875603ae' rt.lock_read() try: eq(rt.get_file_text(foo_id), 'initial contents\n') finally: rt.unlock() rt = b.repository.revision_tree(rh[1]) rt.lock_read() try: eq(rt.get_file_text(foo_id), 'new contents\n') finally: rt.unlock() # check a backup was made: backup_dir = 'backup.bzr.~1~' t = self.get_transport('.') t.stat(backup_dir) t.stat(backup_dir + '/README') t.stat(backup_dir + '/branch-format') t.stat(backup_dir + '/revision-history') t.stat(backup_dir + '/merged-patches') t.stat(backup_dir + '/pending-merged-patches') t.stat(backup_dir + '/pending-merges') t.stat(backup_dir + '/branch-name') t.stat(backup_dir + '/branch-lock') t.stat(backup_dir + '/inventory') t.stat(backup_dir + '/stat-cache') t.stat(backup_dir + '/text-store') t.stat(backup_dir + '/text-store/foo-20051004035611-1591048e9dc7c2d4.gz') t.stat(backup_dir + '/text-store/foo-20051004035756-4081373d897c3453.gz') t.stat(backup_dir + '/inventory-store/') t.stat(backup_dir + '/inventory-store/[email protected]') t.stat(backup_dir + '/inventory-store/[email protected]') t.stat(backup_dir + '/revision-store/') t.stat(backup_dir + '/revision-store/[email protected]') t.stat(backup_dir + '/revision-store/[email protected]')
def test_upgrade_from_format4(self): from bzrlib.tests.test_upgrade import _upgrade_dir_template if self.repository_format.get_format_description() \ == "Repository format 4": raise TestSkipped('Cannot convert format-4 to itself') if isinstance(self.repository_format, remote.RemoteRepositoryFormat): return # local conversion to/from RemoteObjects is irrelevant. self.build_tree_contents(_upgrade_dir_template) old_repodir = bzrlib.bzrdir.BzrDir.open_unsupported('.') old_repo_format = old_repodir.open_repository()._format format = self.repository_format._matchingbzrdir try: format.repository_format = self.repository_format except AttributeError: pass upgrade('.', format)
def test_format_change(self): # When the format of a mirrored branch changes, the puller remirrors # the branch into the new format. db_branch = self.factory.makeAnyBranch(branch_type=BranchType.MIRRORED) tree = self.setUpMirroredBranch(db_branch, format='pack-0.92') transaction.commit() command, retcode, output, error = self.runPuller() self.assertRanSuccessfully(command, retcode, output, error) self.assertMirrored(db_branch, source_branch=tree.branch) transaction.begin() db_branch.requestMirror() upgrade(tree.basedir) tree = WorkingTree.open(tree.basedir) transaction.commit() command, retcode, output, error = self.runPuller() self.assertRanSuccessfully(command, retcode, output, error) self.assertMirrored(db_branch, source_branch=tree.branch)
def test_format_change(self): # When the format of a mirrored branch changes, the puller remirrors # the branch into the new format. db_branch = self.factory.makeAnyBranch( branch_type=BranchType.MIRRORED) tree = self.setUpMirroredBranch(db_branch, format='pack-0.92') transaction.commit() command, retcode, output, error = self.runPuller() self.assertRanSuccessfully(command, retcode, output, error) self.assertMirrored(db_branch, source_branch=tree.branch) transaction.begin() db_branch.requestMirror() upgrade(tree.basedir) tree = WorkingTree.open(tree.basedir) transaction.commit() command, retcode, output, error = self.runPuller() self.assertRanSuccessfully(command, retcode, output, error) self.assertMirrored(db_branch, source_branch=tree.branch)
def test_upgrade_with_ghosts(self): """Upgrade v0.0.4 tree containing ghost references. That is, some of the parents of revisions mentioned in the branch aren't present in the branch's storage. This shouldn't normally happen in branches created entirely in bzr, but can happen in branches imported from baz and arch, or from other systems, where the importer knows about a revision but not its contents.""" eq = self.assertEquals self.build_tree_contents(_ghost_template) upgrade(u'.') b = Branch.open(u'.') revision_id = b.revision_history()[1] rev = b.repository.get_revision(revision_id) eq(len(rev.parent_ids), 2) eq(rev.parent_ids[1], 'wibble@wobble-2')
def test_upgrade_makes_dir_weaves(self): self.build_tree_contents(_upgrade_dir_template) old_repodir = controldir.ControlDir.open_unsupported('.') old_repo_format = old_repodir.open_repository()._format upgrade.upgrade('.') # this is the path to the literal file. As format changes # occur it needs to be updated. FIXME: ask the store for the # path. repo = repository.Repository.open('.') # it should have changed the format self.assertNotEqual(old_repo_format.__class__, repo._format.__class__) # and we should be able to read the names for the file id # 'dir-20051005095101-da1441ea3fa6917a' repo.lock_read() self.addCleanup(repo.unlock) text_keys = repo.texts.keys() dir_keys = [key for key in text_keys if key[0] == 'dir-20051005095101-da1441ea3fa6917a'] self.assertNotEqual([], dir_keys)
def pull(self, db_branch_id, target_path, required_format, needs_tree=False, stacked_on_url=None): """Pull down the Bazaar branch of an import to `target_path`. :return: A Bazaar branch for the code import corresponding to the database branch with id `db_branch_id`. """ remote_url = self._getMirrorURL(db_branch_id) try: remote_bzr_dir = BzrDir.open(remote_url) except NotBranchError: local_branch = BzrDir.create_branch_and_repo( target_path, format=required_format) if needs_tree: local_branch.bzrdir.create_workingtree() if stacked_on_url: local_branch.set_stacked_on_url(stacked_on_url) return local_branch # The proper thing to do here would be to call # "remote_bzr_dir.sprout()". But 2a fetch slowly checks which # revisions are in the ancestry of the tip of the remote branch, which # we strictly don't care about, so we just copy the whole thing down # at the vfs level. control_dir = remote_bzr_dir.root_transport.relpath( remote_bzr_dir.transport.abspath('.')) target = get_transport_from_path(target_path) target_control = target.clone(control_dir) target_control.create_prefix() remote_bzr_dir.transport.copy_tree_to_transport(target_control) local_bzr_dir = BzrDir.open_from_transport(target) if local_bzr_dir.needs_format_conversion(format=required_format): try: local_bzr_dir.root_transport.delete_tree('backup.bzr') except NoSuchFile: pass upgrade(target_path, required_format, clean_up=True) if needs_tree: local_bzr_dir.create_workingtree() return local_bzr_dir.open_branch()
def test_upgrade_preserves_signatures(self): wt = self.make_branch_and_tree('source') wt.commit('A', allow_pointless=True, rev_id='A') repo = wt.branch.repository repo.lock_write() repo.start_write_group() repo.sign_revision('A', bzrlib.gpg.LoopbackGPGStrategy(None)) repo.commit_write_group() repo.unlock() old_signature = repo.get_signature_text('A') try: old_format = bzrdir.BzrDirFormat.get_default_format() # This gives metadir branches something they can convert to. # it would be nice to have a 'latest' vs 'default' concept. format = bzrdir.format_registry.make_bzrdir('dirstate-with-subtree') upgrade(repo.bzrdir.root_transport.base, format=format) except errors.UpToDateFormat: # this is in the most current format already. return except errors.BadConversionTarget, e: raise TestSkipped(str(e))
def test_upgrade_preserves_signatures(self): wt = self.make_branch_and_tree('source') wt.commit('A', allow_pointless=True, rev_id='A') repo = wt.branch.repository repo.lock_write() repo.start_write_group() repo.sign_revision('A', bzrlib.gpg.LoopbackGPGStrategy(None)) repo.commit_write_group() repo.unlock() old_signature = repo.get_signature_text('A') try: old_format = bzrdir.BzrDirFormat.get_default_format() # This gives metadir branches something they can convert to. # it would be nice to have a 'latest' vs 'default' concept. format = bzrdir.format_registry.make_bzrdir( 'dirstate-with-subtree') upgrade(repo.bzrdir.root_transport.base, format=format) except errors.UpToDateFormat: # this is in the most current format already. return except errors.BadConversionTarget, e: raise TestSkipped(str(e))
def test_upgrade_v6_to_meta_no_workingtree(self): # Some format6 branches do not have checkout files. Upgrading # such a branch to metadir must not setup a working tree. self.build_tree_contents(_upgrade1_template) upgrade.upgrade('.', BzrDirFormat6()) t = self.get_transport('.') t.delete_multi(['.bzr/pending-merges', '.bzr/inventory']) self.assertFalse(t.has('.bzr/stat-cache')) t.delete_tree('backup.bzr.~1~') # At this point, we have a format6 branch without checkout files. upgrade.upgrade('.', bzrdir.BzrDirMetaFormat1()) # The upgrade should not have set up a working tree. control = controldir.ControlDir.open('.') self.assertFalse(control.has_workingtree()) # We have covered the scope of this test, we may as well check that # upgrade has not eaten our data, even if it's a bit redundant with # other tests. self.assertIsInstance(control._format, bzrdir.BzrDirMetaFormat1) b = control.open_branch() self.addCleanup(b.lock_read().unlock) self.assertEquals(b._revision_history(), ['[email protected]', '[email protected]'])
def test_upgrade_v6_to_meta_no_workingtree(self): # Some format6 branches do not have checkout files. Upgrading # such a branch to metadir must not setup a working tree. self.build_tree_contents(_upgrade1_template) upgrade('.', bzrdir.BzrDirFormat6()) transport = get_transport('.') transport.delete_multi(['.bzr/pending-merges', '.bzr/inventory']) self.assertFalse(transport.has('.bzr/stat-cache')) # XXX: upgrade fails if a backup.bzr is already present # -- David Allouche 2006-08-11 transport.delete_tree('backup.bzr') # At this point, we have a format6 branch without checkout files. upgrade('.', bzrdir.BzrDirMetaFormat1()) # The upgrade should not have set up a working tree. control = bzrdir.BzrDir.open('.') self.assertFalse(control.has_workingtree()) # We have covered the scope of this test, we may as well check that # upgrade has not eaten our data, even if it's a bit redundant with # other tests. self.failUnless(isinstance(control._format, bzrdir.BzrDirMetaFormat1)) branch = control.open_branch() self.assertEquals(branch.revision_history(), ['[email protected]', '[email protected]'])
def add_upgraded_branch(self): """Add an upgraded branch to the target_subdir. self.branch's branch (but not repository) is mirrored to the BzrDir and then the bzrdir is upgraded in the normal way. """ bd = self.get_bzrdir() self.mirror_branch(self.bzr_branch, bd) try: exceptions = upgrade( bd.root_transport.base, self.get_target_format()) if exceptions: if len(exceptions) == 1: # Compatibility with historical behavior raise exceptions[0] else: return 3 except UpToDateFormat: pass return bd
def add_upgraded_branch(self): """Add an upgraded branch to the target_subdir. self.branch's branch (but not repository) is mirrored to the BzrDir and then the bzrdir is upgraded in the normal way. """ bd = self.get_bzrdir() self.mirror_branch(self.bzr_branch, bd) try: exceptions = upgrade( bd.root_transport.base, self.get_target_format()) if exceptions: if len(exceptions) == 1: # Compatibility with historical behaviour raise exceptions[0] else: return 3 except UpToDateFormat: pass return bd
def test_upgrade_rich_root(self): tree = self.make_branch_and_tree('tree', format='rich-root') rev_id = tree.commit('first post') upgrade.upgrade('tree')
def test_info_standalone(self): transport = self.get_transport() # Create initial standalone branch tree1 = self.make_branch_and_tree('standalone', 'weave') self.build_tree(['standalone/a']) tree1.add('a') branch1 = tree1.branch out, err = self.run_bzr('info standalone') self.assertEqualDiff( """Standalone tree (format: weave) Location: branch root: standalone """, out) self.assertEqual('', err) out, err = self.run_bzr('info standalone -v') self.assertEqualDiff( """Standalone tree (format: weave) Location: branch root: standalone Format: control: All-in-one format 6 working tree: Working tree format 2 branch: Branch format 4 repository: Weave repository format 6 In the working tree: 0 unchanged 0 modified 1 added 0 removed 0 renamed 0 unknown 0 ignored 0 versioned subdirectories Branch history: 0 revisions 0 committers Repository: 0 revisions """, out) self.assertEqual('', err) tree1.commit('commit one') rev = branch1.repository.get_revision(branch1.revision_history()[0]) datestring_first = format_date(rev.timestamp, rev.timezone) # Branch standalone with push location branch2 = branch1.bzrdir.sprout('branch').open_branch() branch2.set_push_location(branch1.bzrdir.root_transport.base) out, err = self.run_bzr('info branch') self.assertEqualDiff( """Standalone tree (format: weave) Location: branch root: branch Related branches: push branch: standalone parent branch: standalone """, out) self.assertEqual('', err) out, err = self.run_bzr('info branch --verbose') self.assertEqualDiff( """Standalone tree (format: weave) Location: branch root: branch Related branches: push branch: standalone parent branch: standalone Format: control: All-in-one format 6 working tree: Working tree format 2 branch: Branch format 4 repository: Weave repository format 6 In the working tree: 1 unchanged 0 modified 0 added 0 removed 0 renamed 0 unknown 0 ignored 0 versioned subdirectories Branch history: 1 revision 1 committer 0 days old first revision: %s latest revision: %s Repository: 1 revision """ % (datestring_first, datestring_first, ), out) self.assertEqual('', err) # Branch and bind to standalone, needs upgrade to metadir # (creates backup as unknown) branch1.bzrdir.sprout('bound') knit1_format = bzrdir.format_registry.make_bzrdir('knit') upgrade.upgrade('bound', knit1_format) branch3 = bzrdir.BzrDir.open('bound').open_branch() branch3.bind(branch1) bound_tree = branch3.bzrdir.open_workingtree() out, err = self.run_bzr('info -v bound') self.assertEqualDiff( """Checkout (format: knit) Location: checkout root: bound checkout of branch: standalone Related branches: parent branch: standalone Format: control: Meta directory format 1 working tree: %s branch: %s repository: %s In the working tree: 1 unchanged 0 modified 0 added 0 removed 0 renamed 1 unknown 0 ignored 0 versioned subdirectories Branch history: 1 revision 1 committer 0 days old first revision: %s latest revision: %s Repository: 1 revision """ % (bound_tree._format.get_format_description(), branch3._format.get_format_description(), branch3.repository._format.get_format_description(), datestring_first, datestring_first, ), out) self.assertEqual('', err) # Checkout standalone (same as above, but does not have parent set) branch4 = bzrdir.BzrDir.create_branch_convenience('checkout', format=knit1_format) branch4.bind(branch1) branch4.bzrdir.open_workingtree().update() out, err = self.run_bzr('info checkout --verbose') self.assertEqualDiff( """Checkout (format: knit) Location: checkout root: checkout checkout of branch: standalone Format: control: Meta directory format 1 working tree: Working tree format 3 branch: Branch format 5 repository: %s In the working tree: 1 unchanged 0 modified 0 added 0 removed 0 renamed 0 unknown 0 ignored 0 versioned subdirectories Branch history: 1 revision 1 committer 0 days old first revision: %s latest revision: %s Repository: 1 revision """ % (branch4.repository._format.get_format_description(), datestring_first, datestring_first, ), out) self.assertEqual('', err) # Lightweight checkout (same as above, different branch and repository) tree5 = branch1.create_checkout('lightcheckout', lightweight=True) branch5 = tree5.branch out, err = self.run_bzr('info -v lightcheckout') self.assertEqualDiff( """Lightweight checkout (format: 1.6 or 1.6.1-rich-root \ or dirstate or dirstate-tags or \ pack-0.92 or rich-root or rich-root-pack) Location: light checkout root: lightcheckout checkout of branch: standalone Format: control: Meta directory format 1 working tree: Working tree format 4 branch: Branch format 4 repository: Weave repository format 6 In the working tree: 1 unchanged 0 modified 0 added 0 removed 0 renamed 0 unknown 0 ignored 0 versioned subdirectories Branch history: 1 revision 1 committer 0 days old first revision: %s latest revision: %s Repository: 1 revision """ % (datestring_first, datestring_first,), out) self.assertEqual('', err) # Update initial standalone branch self.build_tree(['standalone/b']) tree1.add('b') tree1.commit('commit two') rev = branch1.repository.get_revision(branch1.revision_history()[-1]) datestring_last = format_date(rev.timestamp, rev.timezone) # Out of date branched standalone branch will not be detected out, err = self.run_bzr('info -v branch') self.assertEqualDiff( """Standalone tree (format: weave) Location: branch root: branch Related branches: push branch: standalone parent branch: standalone Format: control: All-in-one format 6 working tree: Working tree format 2 branch: Branch format 4 repository: Weave repository format 6 In the working tree: 1 unchanged 0 modified 0 added 0 removed 0 renamed 0 unknown 0 ignored 0 versioned subdirectories Branch history: 1 revision 1 committer 0 days old first revision: %s latest revision: %s Repository: 1 revision """ % (datestring_first, datestring_first, ), out) self.assertEqual('', err) # Out of date bound branch out, err = self.run_bzr('info -v bound') self.assertEqualDiff( """Checkout (format: knit) Location: checkout root: bound checkout of branch: standalone Related branches: parent branch: standalone Format: control: Meta directory format 1 working tree: Working tree format 3 branch: Branch format 5 repository: %s Branch is out of date: missing 1 revision. In the working tree: 1 unchanged 0 modified 0 added 0 removed 0 renamed 1 unknown 0 ignored 0 versioned subdirectories Branch history: 1 revision 1 committer 0 days old first revision: %s latest revision: %s Repository: 1 revision """ % (branch3.repository._format.get_format_description(), datestring_first, datestring_first, ), out) self.assertEqual('', err) # Out of date checkout out, err = self.run_bzr('info -v checkout') self.assertEqualDiff( """Checkout (format: knit) Location: checkout root: checkout checkout of branch: standalone Format: control: Meta directory format 1 working tree: Working tree format 3 branch: Branch format 5 repository: %s Branch is out of date: missing 1 revision. In the working tree: 1 unchanged 0 modified 0 added 0 removed 0 renamed 0 unknown 0 ignored 0 versioned subdirectories Branch history: 1 revision 1 committer 0 days old first revision: %s latest revision: %s Repository: 1 revision """ % (branch4.repository._format.get_format_description(), datestring_first, datestring_first, ), out) self.assertEqual('', err) # Out of date lightweight checkout out, err = self.run_bzr('info lightcheckout --verbose') self.assertEqualDiff( """Lightweight checkout (format: 1.6 or 1.6.1-rich-root or \ dirstate or dirstate-tags or \ pack-0.92 or rich-root or rich-root-pack) Location: light checkout root: lightcheckout checkout of branch: standalone Format: control: Meta directory format 1 working tree: Working tree format 4 branch: Branch format 4 repository: Weave repository format 6 Working tree is out of date: missing 1 revision. In the working tree: 1 unchanged 0 modified 0 added 0 removed 0 renamed 0 unknown 0 ignored 0 versioned subdirectories Branch history: 2 revisions 1 committer 0 days old first revision: %s latest revision: %s Repository: 2 revisions """ % (datestring_first, datestring_last,), out) self.assertEqual('', err)