def testDifferentBranchFormats(self): # identical_formats should return False when both branches have the # different branch formats. self.assertFalse( identical_formats( StubBranch(BzrDirFormatA(), RepoFormatA(), BranchFormatA()), StubBranch(BzrDirFormatA(), RepoFormatA(), BranchFormatB())))
def testAllIdentical(self): # identical_formats should return True when both branches have the same # bzrdir, repository, and branch formats. self.assertTrue( identical_formats( StubBranch(BzrDirFormatA(), RepoFormatA(), BranchFormatA()), StubBranch(BzrDirFormatA(), RepoFormatA(), BranchFormatA())))
def testDifferentBranchFormats(self): # identical_formats should return False when both branches have the # different branch formats. self.failIf( identical_formats( StubBranch(BzrDirFormatA(), RepoFormatA(), BranchFormatA()), StubBranch(BzrDirFormatA(), RepoFormatA(), BranchFormatB())))
def testAllIdentical(self): # identical_formats should return True when both branches have the same # bzrdir, repository, and branch formats. self.failUnless( identical_formats( StubBranch(BzrDirFormatA(), RepoFormatA(), BranchFormatA()), StubBranch(BzrDirFormatA(), RepoFormatA(), BranchFormatA())))
def testDifferentRepositoryFormats(self): # identical_formats should return False when both branches have the # different repository formats. self.failIf( identical_formats( StubBranch(BzrDirFormatA(), RepoFormatA(), BranchFormatA()), StubBranch(BzrDirFormatA(), RepoFormatB(), BranchFormatA())))
def openDestinationBranch(self, source_branch, destination_url): """Open or create the destination branch at 'destination_url'. :param source_branch: The Bazaar branch that will be mirrored. :param destination_url: The place to make the destination branch. This URL must point to a writable location. :return: The opened or created branch. """ try: branch = Branch.open(destination_url) except (errors.NotBranchError, errors.IncompatibleRepositories): # Make a new branch in the same format as the source branch. return self.createDestinationBranch( source_branch, destination_url) # Check that destination branch is in the same format as the source. if identical_formats(source_branch, branch): return branch self.log('Formats differ.') return self.createDestinationBranch(source_branch, destination_url)