def create_date_str(timestamp=None, offset=None): """Just a wrapper around format_date to provide the right format. We don't want to use '%a' in the time string, because it is locale dependant. We also want to force timezone original, and show_offset Without parameters this function yields the current date in the local time zone. """ if timestamp is None and offset is None: timestamp = time.time() offset = local_time_offset() return format_date(timestamp, offset, date_fmt='%Y-%m-%d %H:%M:%S', timezone='original', show_offset=True)
def test_info_standalone(self): transport = self.get_transport() # Create initial standalone branch tree1 = self.make_branch_and_tree('standalone', 'knit') self.build_tree(['standalone/a']) tree1.add('a') branch1 = tree1.branch out, err = self.run_bzr('info standalone') self.assertEqualDiff( """Standalone tree (format: knit) Location: branch root: standalone """, out) self.assertEqual('', err) # Standalone branch - verbose mode out, err = self.run_bzr('info standalone -v') self.assertEqualDiff( """Standalone tree (format: knit) Location: branch root: standalone Format: control: Meta directory format 1 working tree: Working tree format 3 branch: Branch format 5 repository: Knit repository format 1 Control directory: 1 branches In the working tree: 0 unchanged 0 modified 1 added 0 removed 0 renamed 0 copied 0 unknown 0 ignored 0 versioned subdirectories Branch history: 0 revisions Repository: 0 revisions """, out) self.assertEqual('', err) # Standalone branch - really verbose mode out, err = self.run_bzr('info standalone -vv') self.assertEqualDiff( """Standalone tree (format: knit) Location: branch root: standalone Format: control: Meta directory format 1 working tree: Working tree format 3 branch: Branch format 5 repository: Knit repository format 1 Control directory: 1 branches In the working tree: 0 unchanged 0 modified 1 added 0 removed 0 renamed 0 copied 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.last_revision()) datestring_first = osutils.format_date(rev.timestamp, rev.timezone) # Branch standalone with push location branch2 = branch1.controldir.sprout('branch').open_branch() branch2.set_push_location(branch1.controldir.root_transport.base) out, err = self.run_bzr('info branch') self.assertEqualDiff( """Standalone tree (format: knit) 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: knit) Location: branch root: branch Related branches: push branch: standalone parent branch: standalone Format: control: Meta directory format 1 working tree: Working tree format 3 branch: Branch format 5 repository: Knit repository format 1 Control directory: 1 branches In the working tree: 1 unchanged 0 modified 0 added 0 removed 0 renamed 0 copied 0 unknown 0 ignored 0 versioned subdirectories Branch history: 1 revision 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.controldir.sprout('bound') knit1_format = controldir.format_registry.make_controldir('knit') upgrade.upgrade('bound', knit1_format) branch3 = controldir.ControlDir.open('bound').open_branch() branch3.bind(branch1) bound_tree = branch3.controldir.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 Control directory: 1 branches In the working tree: 1 unchanged 0 modified 0 added 0 removed 0 renamed 0 copied 0 unknown 0 ignored 0 versioned subdirectories Branch history: 1 revision 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 = controldir.ControlDir.create_branch_convenience( 'checkout', format=knit1_format) branch4.bind(branch1) branch4.controldir.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 Control directory: 1 branches In the working tree: 1 unchanged 0 modified 0 added 0 removed 0 renamed 0 copied 0 unknown 0 ignored 0 versioned subdirectories Branch history: 1 revision 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') if "metaweave" in controldir.format_registry: format_description = "knit or metaweave" else: format_description = "knit" self.assertEqualDiff( """Lightweight checkout (format: %s) Location: light checkout root: lightcheckout checkout of branch: standalone Format: control: Meta directory format 1 working tree: Working tree format 3 branch: Branch format 5 repository: Knit repository format 1 Control directory: 1 branches In the working tree: 1 unchanged 0 modified 0 added 0 removed 0 renamed 0 copied 0 unknown 0 ignored 0 versioned subdirectories Branch history: 1 revision 0 days old first revision: %s latest revision: %s Repository: 1 revision """ % ( format_description, 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.last_revision()) datestring_last = osutils.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: knit) Location: branch root: branch Related branches: push branch: standalone parent branch: standalone Format: control: Meta directory format 1 working tree: Working tree format 3 branch: Branch format 5 repository: Knit repository format 1 Control directory: 1 branches In the working tree: 1 unchanged 0 modified 0 added 0 removed 0 renamed 0 copied 0 unknown 0 ignored 0 versioned subdirectories Branch history: 1 revision 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 Control directory: 1 branches Branch is out of date: missing 1 revision. In the working tree: 1 unchanged 0 modified 0 added 0 removed 0 renamed 0 copied 0 unknown 0 ignored 0 versioned subdirectories Branch history: 1 revision 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 Control directory: 1 branches Branch is out of date: missing 1 revision. In the working tree: 1 unchanged 0 modified 0 added 0 removed 0 renamed 0 copied 0 unknown 0 ignored 0 versioned subdirectories Branch history: 1 revision 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: %s) Location: light checkout root: lightcheckout checkout of branch: standalone Format: control: Meta directory format 1 working tree: Working tree format 3 branch: Branch format 5 repository: Knit repository format 1 Control directory: 1 branches Working tree is out of date: missing 1 revision. In the working tree: 1 unchanged 0 modified 0 added 0 removed 0 renamed 0 copied 0 unknown 0 ignored 0 versioned subdirectories Branch history: 2 revisions 0 days old first revision: %s latest revision: %s Repository: 2 revisions """ % ( format_description, datestring_first, datestring_last, ), out) self.assertEqual('', err)
def test_info_shared_repository_with_trees(self): format = controldir.format_registry.make_controldir('knit') transport = self.get_transport() # Create shared repository with working trees repo = self.make_repository('repo', shared=True, format=format) repo.set_make_working_trees(True) out, err = self.run_bzr('info -v repo') self.assertEqualDiff( """Shared repository with trees (format: dirstate or dirstate-tags or knit) Location: shared repository: repo Format: control: Meta directory format 1 repository: %s Control directory: 0 branches Create working tree for new branches inside the repository. Repository: 0 revisions """ % (format.repository_format.get_format_description(), ), out) self.assertEqual('', err) # Create two branches repo.controldir.root_transport.mkdir('branch1') branch1 = controldir.ControlDir.create_branch_convenience( 'repo/branch1', format=format) branch2 = branch1.controldir.sprout('repo/branch2').open_branch() # Empty first branch out, err = self.run_bzr('info repo/branch1 --verbose') self.assertEqualDiff( """Repository tree (format: knit) Location: shared repository: repo repository branch: repo/branch1 Format: control: Meta directory format 1 working tree: Working tree format 3 branch: %s repository: %s Control directory: 1 branches In the working tree: 0 unchanged 0 modified 0 added 0 removed 0 renamed 0 copied 0 unknown 0 ignored 0 versioned subdirectories Branch history: 0 revisions Repository: 0 revisions """ % ( format.get_branch_format().get_format_description(), format.repository_format.get_format_description(), ), out) self.assertEqual('', err) # Update first branch self.build_tree(['repo/branch1/a']) tree1 = branch1.controldir.open_workingtree() tree1.add('a') tree1.commit('commit one') rev = repo.get_revision(branch1.last_revision()) datestring_first = osutils.format_date(rev.timestamp, rev.timezone) out, err = self.run_bzr('info -v repo/branch1') self.assertEqualDiff( """Repository tree (format: knit) Location: shared repository: repo repository branch: repo/branch1 Format: control: Meta directory format 1 working tree: Working tree format 3 branch: %s repository: %s Control directory: 1 branches In the working tree: 1 unchanged 0 modified 0 added 0 removed 0 renamed 0 copied 0 unknown 0 ignored 0 versioned subdirectories Branch history: 1 revision 0 days old first revision: %s latest revision: %s Repository: 1 revision """ % ( format.get_branch_format().get_format_description(), format.repository_format.get_format_description(), datestring_first, datestring_first, ), out) self.assertEqual('', err) # Out of date second branch out, err = self.run_bzr('info repo/branch2 --verbose') self.assertEqualDiff( """Repository tree (format: knit) Location: shared repository: repo repository branch: repo/branch2 Related branches: parent branch: repo/branch1 Format: control: Meta directory format 1 working tree: Working tree format 3 branch: %s repository: %s Control directory: 1 branches In the working tree: 0 unchanged 0 modified 0 added 0 removed 0 renamed 0 copied 0 unknown 0 ignored 0 versioned subdirectories Branch history: 0 revisions Repository: 1 revision """ % ( format.get_branch_format().get_format_description(), format.repository_format.get_format_description(), ), out) self.assertEqual('', err) # Update second branch tree2 = branch2.controldir.open_workingtree() tree2.pull(branch1) out, err = self.run_bzr('info -v repo/branch2') self.assertEqualDiff( """Repository tree (format: knit) Location: shared repository: repo repository branch: repo/branch2 Related branches: parent branch: repo/branch1 Format: control: Meta directory format 1 working tree: Working tree format 3 branch: %s repository: %s Control directory: 1 branches In the working tree: 1 unchanged 0 modified 0 added 0 removed 0 renamed 0 copied 0 unknown 0 ignored 0 versioned subdirectories Branch history: 1 revision 0 days old first revision: %s latest revision: %s Repository: 1 revision """ % ( format.get_branch_format().get_format_description(), format.repository_format.get_format_description(), datestring_first, datestring_first, ), out) self.assertEqual('', err) # Show info about repository with revisions out, err = self.run_bzr('info -v repo') self.assertEqualDiff( """Shared repository with trees (format: dirstate or dirstate-tags or knit) Location: shared repository: repo Format: control: Meta directory format 1 repository: %s Control directory: 0 branches Create working tree for new branches inside the repository. Repository: 1 revision """ % (format.repository_format.get_format_description(), ), out) self.assertEqual('', err)
def test_info_shared_repository(self): format = controldir.format_registry.make_controldir('knit') transport = self.get_transport() # Create shared repository repo = self.make_repository('repo', shared=True, format=format) repo.set_make_working_trees(False) out, err = self.run_bzr('info -v repo') self.assertEqualDiff( """Shared repository (format: dirstate or dirstate-tags or knit) Location: shared repository: %s Format: control: Meta directory format 1 repository: %s Control directory: 0 branches Repository: 0 revisions """ % ( 'repo', format.repository_format.get_format_description(), ), out) self.assertEqual('', err) # Create branch inside shared repository repo.controldir.root_transport.mkdir('branch') branch1 = controldir.ControlDir.create_branch_convenience( 'repo/branch', format=format) out, err = self.run_bzr('info -v repo/branch') self.assertEqualDiff( """Repository branch (format: dirstate or knit) Location: shared repository: repo repository branch: repo/branch Format: control: Meta directory format 1 branch: %s repository: %s Control directory: 1 branches Branch history: 0 revisions Repository: 0 revisions """ % ( format.get_branch_format().get_format_description(), format.repository_format.get_format_description(), ), out) self.assertEqual('', err) # Create lightweight checkout transport.mkdir('tree') transport.mkdir('tree/lightcheckout') tree2 = branch1.create_checkout('tree/lightcheckout', lightweight=True) branch2 = tree2.branch self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2, shared_repo=repo, repo_branch=branch1, verbose=True) # Create normal checkout tree3 = branch1.create_checkout('tree/checkout') self.assertCheckoutStatusOutput('tree/checkout --verbose', tree3, verbose=True, light_checkout=False, repo_branch=branch1) # Update lightweight checkout self.build_tree(['tree/lightcheckout/a']) tree2.add('a') tree2.commit('commit one') rev = repo.get_revision(branch2.last_revision()) datestring_first = osutils.format_date(rev.timestamp, rev.timezone) out, err = self.run_bzr('info tree/lightcheckout --verbose') self.assertEqualDiff( """Lightweight checkout (format: %s) Location: light checkout root: tree/lightcheckout checkout of branch: repo/branch shared repository: repo Format: control: Meta directory format 1 working tree: Working tree format 6 branch: %s repository: %s Control directory: 1 branches In the working tree: 1 unchanged 0 modified 0 added 0 removed 0 renamed 0 copied 0 unknown 0 ignored 0 versioned subdirectories Branch history: 1 revision 0 days old first revision: %s latest revision: %s Repository: 1 revision """ % ( self._repo_strings, format.get_branch_format().get_format_description(), format.repository_format.get_format_description(), datestring_first, datestring_first, ), out) self.assertEqual('', err) # Out of date checkout out, err = self.run_bzr('info -v tree/checkout') self.assertEqualDiff( """Checkout (format: unnamed) Location: checkout root: tree/checkout checkout of branch: repo/branch Format: control: Meta directory format 1 working tree: Working tree format 6 branch: %s repository: %s Control directory: 1 branches Branch is out of date: missing 1 revision. In the working tree: 0 unchanged 0 modified 0 added 0 removed 0 renamed 0 copied 0 unknown 0 ignored 0 versioned subdirectories Branch history: 0 revisions Repository: 0 revisions """ % ( format.get_branch_format().get_format_description(), format.repository_format.get_format_description(), ), out) self.assertEqual('', err) # Update checkout tree3.update() self.build_tree(['tree/checkout/b']) tree3.add('b') out, err = self.run_bzr('info tree/checkout --verbose') self.assertEqualDiff( """Checkout (format: unnamed) Location: checkout root: tree/checkout checkout of branch: repo/branch Format: control: Meta directory format 1 working tree: Working tree format 6 branch: %s repository: %s Control directory: 1 branches In the working tree: 1 unchanged 0 modified 1 added 0 removed 0 renamed 0 copied 0 unknown 0 ignored 0 versioned subdirectories Branch history: 1 revision 0 days old first revision: %s latest revision: %s Repository: 1 revision """ % ( format.get_branch_format().get_format_description(), format.repository_format.get_format_description(), datestring_first, datestring_first, ), out) self.assertEqual('', err) tree3.commit('commit two') # Out of date lightweight checkout rev = repo.get_revision(branch1.last_revision()) datestring_last = osutils.format_date(rev.timestamp, rev.timezone) out, err = self.run_bzr('info tree/lightcheckout --verbose') self.assertEqualDiff( """Lightweight checkout (format: %s) Location: light checkout root: tree/lightcheckout checkout of branch: repo/branch shared repository: repo Format: control: Meta directory format 1 working tree: Working tree format 6 branch: %s repository: %s Control directory: 1 branches Working tree is out of date: missing 1 revision. In the working tree: 1 unchanged 0 modified 0 added 0 removed 0 renamed 0 copied 0 unknown 0 ignored 0 versioned subdirectories Branch history: 2 revisions 0 days old first revision: %s latest revision: %s Repository: 2 revisions """ % ( self._repo_strings, format.get_branch_format().get_format_description(), format.repository_format.get_format_description(), datestring_first, datestring_last, ), out) self.assertEqual('', err) # Show info about shared branch out, err = self.run_bzr('info repo/branch --verbose') self.assertEqualDiff( """Repository branch (format: dirstate or knit) Location: shared repository: repo repository branch: repo/branch Format: control: Meta directory format 1 branch: %s repository: %s Control directory: 1 branches Branch history: 2 revisions 0 days old first revision: %s latest revision: %s Repository: 2 revisions """ % ( format.get_branch_format().get_format_description(), format.repository_format.get_format_description(), datestring_first, datestring_last, ), out) self.assertEqual('', err) # Show info about repository with revisions out, err = self.run_bzr('info -v repo') self.assertEqualDiff( """Shared repository (format: dirstate or dirstate-tags or knit) Location: shared repository: repo Format: control: Meta directory format 1 repository: %s Control directory: 0 branches Repository: 2 revisions """ % (format.repository_format.get_format_description(), ), out) self.assertEqual('', err)