def test_email_extracted_from_name_alternate(self): # Check that a valid email address is extracted from the name. name = '[email protected] (Harry Potter)' author = RevisionSet()._createRevisionAuthor(name) self.assertEqual(name, author.name) self.assertEqual('*****@*****.**', author.email) self.assertEqual(None, author.person)
def test_bad_email_not_set(self): # Check that a name that doesn't have an email address, doesn't set # one. name = 'Harry Potter' author = RevisionSet()._createRevisionAuthor(name) self.assertEqual(name, author.name) self.assertEqual(None, author.email) self.assertEqual(None, author.person)
def setUp(self): # Create a revision author that doesn't have a user yet. super(TestNewlyValidatedEmailsLinkRevisionAuthors, self).setUp() with dbuser("branchscanner"): self.author = RevisionSet()._createRevisionAuthor( '"Harry Potter" <*****@*****.**>') # Reget the revision author as we have crossed a transaction boundary. self.author = RevisionAuthor.byName(self.author.name)
def test_new_future_revision_date(self): # A revision with a future date gets the revision date set to # date_created. now = datetime.now(pytz.UTC) future_date = now + timedelta(days=1) revision = RevisionSet().new('rev_id', 'log body', future_date, 'author', [], {}) self.assertEqual(revision.date_created, revision.revision_date) self.assertTrue(revision.revision_date <= now)
def getRevisionMessage(self, revision_id, revno): """Return the log message for a revision. :param revision_id: The revision-id of the revision. :param revno: The revno of the revision in the branch. :return: The log message entered for this revision. """ self.bzr_branch.lock_read() try: graph = self.bzr_branch.repository.get_graph() merged_revisions = self.getMergedRevisionIDs(revision_id, graph) authors = self.getAuthors(merged_revisions, graph) revision_set = RevisionSet() rev_authors = revision_set.acquireRevisionAuthors(authors) outf = StringIO() pretty_authors = [] for rev_author in rev_authors.values(): if rev_author.person is None: displayname = rev_author.name else: displayname = rev_author.person.unique_displayname pretty_authors.append(' %s' % displayname) if len(pretty_authors) > 0: outf.write('Merge authors:\n') pretty_authors.sort(key=lambda x: x.lower()) outf.write('\n'.join(pretty_authors[:5])) if len(pretty_authors) > 5: outf.write('...\n') outf.write('\n') bmps = self.findRelatedBMP(merged_revisions) if len(bmps) > 0: outf.write('Related merge proposals:\n') for bmp in bmps: outf.write(' %s\n' % canonical_url(bmp)) proposer = bmp.registrant outf.write(' proposed by: %s\n' % proposer.unique_displayname) for review in bmp.votes: # If comment is None, this is a request for a review, not # a completed review. if review.comment is None: continue outf.write(' review: %s - %s\n' % (review.comment.vote.title, review.reviewer.unique_displayname)) info = RevisionInfo(self.bzr_branch, revno, revision_id) lf = log_formatter('long', to_file=outf) show_log(self.bzr_branch, lf, start_revision=info, end_revision=info, verbose=True) finally: self.bzr_branch.unlock() return outf.getvalue()
def _createRevisionAuthor(self): switch_dbuser("branchscanner") return RevisionSet()._createRevisionAuthor( '"Harry Potter" <*****@*****.**>')
def test_new_past_revision_date(self): # A revision created with a revision date in the past works fine. past_date = datetime(2009, 1, 1, tzinfo=pytz.UTC) revision = RevisionSet().new('rev_id', 'log body', past_date, 'author', [], {}) self.assertEqual(past_date, revision.revision_date)