def test_scheduleTranslationTemplatesBuild_subscribed(self): # If the feature is enabled, a TipChanged event for a branch that # generates templates will schedule a templates build. branch = self._makeTranslationBranch() removeSecurityProxy(branch).last_scanned_id = 'null:' commit = DirectBranchCommit(branch) commit.writeFile('POTFILES.in', 'foo') commit.commit('message') notify(events.TipChanged(branch, None, False)) branchjobs = list(TranslationTemplatesBuildJob.iterReady()) self.assertEqual(1, len(branchjobs)) self.assertEqual(branch, branchjobs[0].branch)
def test_scheduleTranslationTemplatesBuild_subscribed(self): # If the feature is enabled, a TipChanged event for a branch that # generates templates will schedule a templates build. branch = self._makeTranslationBranch() removeSecurityProxy(branch).last_scanned_id = 'null:' commit = DirectBranchCommit(branch) commit.writeFile('POTFILES.in', 'foo') commit.commit('message') notify(events.TipChanged(branch, commit.bzrbranch, False)) self.assertEqual( 1, TranslationTemplatesBuild.findByBranch(branch).count())
def commit_file(branch, path, contents, merge_parents=None): """Create a commit that updates a file to specified contents. This will create or modify the file, as needed. """ committer = DirectBranchCommit( removeSecurityProxy(branch), no_race_check=True, merge_parents=merge_parents) committer.writeFile(path, contents) try: return committer.commit('committing') finally: committer.unlock()
def test_commit_uses_merge_parents(self): # DirectBranchCommit.commit returns uses merge parents self._tearDownCommitter() # Merge parents cannot be specified for initial commit, so do an # empty commit. self.tree.commit('foo', committer='foo@bar', rev_id=b'foo') self.db_branch.last_mirrored_id = 'foo' committer = DirectBranchCommit( self.db_branch, merge_parents=[b'parent-1', b'parent-2']) committer.last_scanned_id = (committer.bzrbranch.last_revision()) committer.writeFile('file.txt', b'contents') committer.commit('') branch_revision_id = committer.bzrbranch.last_revision() branch_revision = committer.bzrbranch.repository.get_revision( branch_revision_id) self.assertEqual([b'parent-1', b'parent-2'], branch_revision.parent_ids[1:])
def test_commit_uses_merge_parents(self): # DirectBranchCommit.commit returns uses merge parents self._tearDownCommitter() # Merge parents cannot be specified for initial commit, so do an # empty commit. self.tree.commit('foo', committer='foo@bar', rev_id='foo') self.db_branch.last_mirrored_id = 'foo' committer = DirectBranchCommit( self.db_branch, merge_parents=['parent-1', 'parent-2']) committer.last_scanned_id = ( committer.bzrbranch.last_revision()) committer.writeFile('file.txt', 'contents') committer.commit('') branch_revision_id = committer.bzrbranch.last_revision() branch_revision = committer.bzrbranch.repository.get_revision( branch_revision_id) self.assertEqual( ['parent-1', 'parent-2'], branch_revision.parent_ids[1:])
def _createBranch(self, content_map=None): """Create a working branch. :param content_map: optional dict mapping file names to file contents. Each of these files with their contents will be written to the branch. :return: a fresh lp.code.model.Branch backed by a real bzr branch. """ db_branch, tree = self.create_branch_and_tree() populist = DirectBranchCommit(db_branch) last_revision = populist.bzrbranch.last_revision() db_branch.last_scanned_id = populist.last_scanned_id = last_revision if content_map is not None: for name, contents in content_map.iteritems(): populist.writeFile(name, contents) populist.commit("Populating branch.") return db_branch