def testGetBranchStackedOnUrl(self): # get_branch_stacked_on_url returns the URL of the stacked-on branch. self.make_branch('stacked-on') stacked_branch = self.make_branch('stacked') try: stacked_branch.set_stacked_on_url('../stacked-on') except errors.UnstackableBranchFormat: raise TestNotApplicable('This format does not support stacking.') # Deleting the stacked-on branch ensures that Bazaar will raise an # error if it tries to open the stacked-on branch. self.get_transport('.').delete_tree('stacked-on') self.assertEqual('../stacked-on', get_branch_stacked_on_url(stacked_branch.bzrdir))
def testGetBranchStackedOnUrl(self): # get_branch_stacked_on_url returns the URL of the stacked-on branch. self.make_branch('stacked-on') stacked_branch = self.make_branch('stacked') try: stacked_branch.set_stacked_on_url('../stacked-on') except errors.UnstackableBranchFormat: raise TestNotApplicable('This format does not support stacking.') # Deleting the stacked-on branch ensures that Bazaar will raise an # error if it tries to open the stacked-on branch. self.get_transport('.').delete_tree('stacked-on') self.assertEqual( '../stacked-on', get_branch_stacked_on_url(stacked_branch.bzrdir))
def updateStackedOn(self, branch_id, bzr_branch_url, stacked_on_location): """Stack the Bazaar branch at 'bzr_branch_url' on the given URL. :param branch_id: The database ID of the branch. This is only used for logging. :param bzr_branch_url: The lp-internal:/// URL of the Bazaar branch. :param stacked_on_location: The location to store in the branch's stacked_on_location configuration variable. """ try: bzrdir = BzrDir.open(bzr_branch_url) except errors.NotBranchError: self.logger.warn( "No bzrdir for %r at %r" % (branch_id, bzr_branch_url)) return try: current_stacked_on_location = get_branch_stacked_on_url(bzrdir) except errors.NotBranchError: self.logger.warn( "No branch for %r at %r" % (branch_id, bzr_branch_url)) except errors.NotStacked: self.logger.warn( "Branch for %r at %r is not stacked at all. Giving up." % (branch_id, bzr_branch_url)) except errors.UnstackableBranchFormat: self.logger.error( "Branch for %r at %r is unstackable. Giving up." % (branch_id, bzr_branch_url)) else: if current_stacked_on_location != stacked_on_location: self.logger.info( 'Branch for %r at %r stacked on %r, should be on %r.' % (branch_id, bzr_branch_url, current_stacked_on_location, stacked_on_location)) if not self.options.dry_run: set_branch_stacked_on_url(bzrdir, stacked_on_location)
def updateStackedOn(self, branch_id, bzr_branch_url, stacked_on_location): """Stack the Bazaar branch at 'bzr_branch_url' on the given URL. :param branch_id: The database ID of the branch. This is only used for logging. :param bzr_branch_url: The lp-internal:/// URL of the Bazaar branch. :param stacked_on_location: The location to store in the branch's stacked_on_location configuration variable. """ try: bzrdir = BzrDir.open(bzr_branch_url) except errors.NotBranchError: self.logger.warn("No bzrdir for %r at %r" % (branch_id, bzr_branch_url)) return try: current_stacked_on_location = get_branch_stacked_on_url(bzrdir) except errors.NotBranchError: self.logger.warn("No branch for %r at %r" % (branch_id, bzr_branch_url)) except errors.NotStacked: self.logger.warn( "Branch for %r at %r is not stacked at all. Giving up." % (branch_id, bzr_branch_url)) except errors.UnstackableBranchFormat: self.logger.error( "Branch for %r at %r is unstackable. Giving up." % (branch_id, bzr_branch_url)) else: if current_stacked_on_location != stacked_on_location: self.logger.info( 'Branch for %r at %r stacked on %r, should be on %r.' % (branch_id, bzr_branch_url, current_stacked_on_location, stacked_on_location)) if not self.options.dry_run: set_branch_stacked_on_url(bzrdir, stacked_on_location)