def test_import_revision_with_url(self):
     # Importing a revision passing the url parameter works.
     self.commitRevision()
     counts = self.getCounts()
     bzrsync = BzrSync(self.db_branch)
     bzrsync.syncBranchAndClose()
     self.assertCounts(counts, new_revisions=1, new_numbers=1, new_authors=1)
 def test_import_revision_with_url(self):
     # Importing a revision passing the url parameter works.
     self.commitRevision()
     counts = self.getCounts()
     bzrsync = BzrSync(self.db_branch)
     bzrsync.syncBranchAndClose()
     self.assertCounts(
         counts, new_revisions=1, new_numbers=1, new_authors=1)
Exemple #3
0
 def run(self):
     """See `IBranchScanJob`."""
     from lp.services.scripts import log
     with server(get_ro_server(), no_replace=True):
         try:
             with try_advisory_lock(LockType.BRANCH_SCAN, self.branch.id,
                                    Store.of(self.branch)):
                 bzrsync = BzrSync(self.branch, log)
                 bzrsync.syncBranchAndClose()
         except LostObjectError:
             log.warning('Skipping branch %s because it has been deleted.' %
                         self._cached_branch_name)
 def test_uncommit_branch(self):
     """RevisionMailJob for removed revisions runs via Celery."""
     db_branch, tree = self.prepare('RevisionMailJob')
     tree.commit('message')
     bzr_sync = BzrSync(db_branch)
     with block_on_job():
         bzr_sync.syncBranchAndClose(tree.branch)
     pop_remote_notifications()
     uncommit(tree.branch)
     with block_on_job():
         bzr_sync.syncBranchAndClose(tree.branch)
     self.assertEqual(1, len(pop_remote_notifications()))
 def run(self):
     """See `IBranchScanJob`."""
     from lp.services.scripts import log
     with server(get_ro_server(), no_replace=True):
         try:
             with try_advisory_lock(
                 LockType.BRANCH_SCAN, self.branch.id,
                 Store.of(self.branch)):
                 bzrsync = BzrSync(self.branch, log)
                 bzrsync.syncBranchAndClose()
         except LostObjectError:
             log.warning('Skipping branch %s because it has been deleted.'
                 % self._cached_branch_name)
 def test_revisions_added(self):
     """RevisionsAddedJob for added revisions runs via Celery."""
     # Enable RevisionMailJob to let celery activate a new connection
     # before trying to flush sent emails calling pop_remote_notifications.
     db_branch, tree = self.prepare('RevisionMailJob RevisionsAddedJob')
     tree.commit('message')
     bzr_sync = BzrSync(db_branch)
     with block_on_job():
         bzr_sync.syncBranchAndClose(tree.branch)
     pop_remote_notifications()
     tree.commit('message2')
     with block_on_job():
         bzr_sync.syncBranchAndClose(tree.branch)
     self.assertEqual(1, len(pop_remote_notifications()))
    def makeBzrSync(self, db_branch):
        """Create a BzrSync instance for the test branch.

        This method allow subclasses to instrument the BzrSync instance used
        in syncBranch.
        """
        return BzrSync(db_branch)
 def test_ancestry_already_present(self):
     # If a BranchRevision is being added, and it's already in the DB, but
     # not found through the graph operations, we should schedule it for
     # deletion anyway.
     rev1_id = self.bzr_tree.commit("initial commit", committer="*****@*****.**")
     merge_tree = self.bzr_tree.bzrdir.sprout("merge").open_workingtree()
     merge_id = merge_tree.commit("mergeable commit", committer="*****@*****.**")
     self.bzr_tree.merge_from_branch(merge_tree.branch)
     rev2_id = self.bzr_tree.commit("merge", committer="*****@*****.**")
     self.useContext(read_locked(self.bzr_tree))
     syncer = BzrSync(self.db_branch)
     syncer.syncBranchAndClose(self.bzr_tree.branch)
     self.assertEqual(rev2_id, self.db_branch.last_scanned_id)
     self.db_branch.last_scanned_id = rev1_id
     db_ancestry, db_history = self.db_branch.getScannerData()
     branchrevisions_to_delete = syncer.planDatabaseChanges(
         self.bzr_branch, [rev1_id, rev2_id], db_ancestry, db_history
     )[1]
     self.assertIn(merge_id, branchrevisions_to_delete)
 def test_ancestry_already_present(self):
     # If a BranchRevision is being added, and it's already in the DB, but
     # not found through the graph operations, we should schedule it for
     # deletion anyway.
     rev1_id = self.bzr_tree.commit('initial commit',
                                    committer='*****@*****.**')
     merge_tree = self.bzr_tree.bzrdir.sprout('merge').open_workingtree()
     merge_id = merge_tree.commit('mergeable commit',
                                  committer='*****@*****.**')
     self.bzr_tree.merge_from_branch(merge_tree.branch)
     rev2_id = self.bzr_tree.commit('merge', committer='*****@*****.**')
     self.useContext(read_locked(self.bzr_tree))
     syncer = BzrSync(self.db_branch)
     syncer.syncBranchAndClose(self.bzr_tree.branch)
     self.assertEqual(rev2_id, self.db_branch.last_scanned_id)
     self.db_branch.last_scanned_id = rev1_id
     db_ancestry, db_history = self.db_branch.getScannerData()
     branchrevisions_to_delete = syncer.planDatabaseChanges(
         self.bzr_branch, [rev1_id, rev2_id], db_ancestry, db_history)[1]
     self.assertIn(merge_id, branchrevisions_to_delete)
Exemple #10
0
 def test_uncommit_branch(self):
     """RevisionMailJob for removed revisions runs via Celery."""
     db_branch, tree = self.prepare('RevisionMailJob')
     tree.commit('message')
     bzr_sync = BzrSync(db_branch)
     with block_on_job():
         bzr_sync.syncBranchAndClose(tree.branch)
     pop_remote_notifications()
     uncommit(tree.branch)
     with block_on_job():
         bzr_sync.syncBranchAndClose(tree.branch)
     self.assertEqual(1, len(pop_remote_notifications()))
Exemple #11
0
 def test_revisions_added(self):
     """RevisionsAddedJob for added revisions runs via Celery."""
     # Enable RevisionMailJob to let celery activate a new connection
     # before trying to flush sent emails calling pop_remote_notifications.
     db_branch, tree = self.prepare('RevisionMailJob RevisionsAddedJob')
     tree.commit('message')
     bzr_sync = BzrSync(db_branch)
     with block_on_job():
         bzr_sync.syncBranchAndClose(tree.branch)
     pop_remote_notifications()
     tree.commit('message2')
     with block_on_job():
         bzr_sync.syncBranchAndClose(tree.branch)
     self.assertEqual(1, len(pop_remote_notifications()))
 def test_revisionsToInsert_empty(self):
     # An empty branch should have no revisions.
     self.assertEqual(
         [], list(BzrSync.revisionsToInsert([], 0, set())))
Exemple #13
0
 def test_empty_branch(self):
     """RevisionMailJob for empty branches runs via Celery."""
     db_branch, tree = self.prepare('RevisionMailJob')
     with block_on_job():
         BzrSync(db_branch).syncBranchAndClose(tree.branch)
     self.assertEqual(1, len(pop_remote_notifications()))
 def test_revisionsToInsert_empty(self):
     # An empty branch should have no revisions.
     self.assertEqual([], list(BzrSync.revisionsToInsert([], 0, set())))