Ejemplo n.º 1
0
 def _get_author_user(self, revisionid):
     # TODO: these queries are very expensive, cache them
     revision = phlcon_differential.query(self._multi_conduit,
                                          [revisionid])[0]
     author_user = phlcon_user.query_usernames_from_phids(
         self._multi_conduit, [revision.authorPHID])[0]
     return author_user
Ejemplo n.º 2
0
 def _get_author_user(self, revisionid):
     # TODO: these queries are very expensive, cache them
     revision = phlcon_differential.query(
         self._multi_conduit, [revisionid])[0]
     author_user = phlcon_user.query_usernames_from_phids(
         self._multi_conduit, [revision.authorPHID])[0]
     return author_user
Ejemplo n.º 3
0
    def testEmptyLists(self):
        users = phlcon_user.query_users_from_usernames(self.conduit, [])
        self.assertEqual(len(users), 0)

        users = phlcon_user.query_users_from_phids(self.conduit, [])
        self.assertEqual(len(users), 0)

        users = phlcon_user.query_usernames_from_phids(self.conduit, [])
        self.assertEqual(len(users), 0)

        users = phlcon_user.query_users_from_emails(self.conduit, [])
        self.assertEqual(len(users), 0)
def processUpdatedBranch(
        mailer, conduit, gitContext, review_branch, working_branch):
    abdte = abdt_exception
    if working_branch is None:
        print "create review for " + review_branch.branch
        tryCreateReview(
            mailer, conduit, gitContext, review_branch, mail_on_fail=True)
    else:
        commenter = abdcmnt_commenter.Commenter(conduit, working_branch.id)
        if abdt_naming.isStatusBadPreReview(working_branch):
            hasChanged = not phlgit_branch.is_identical(
                gitContext.clone,
                review_branch.remote_branch,
                working_branch.remote_branch)
            print "try again to create review for " + review_branch.branch
            phlgit_push.delete(
                gitContext.clone,
                working_branch.branch,
                gitContext.remote)
            tryCreateReview(
                mailer,
                conduit,
                gitContext,
                review_branch,
                mail_on_fail=hasChanged)
        else:
            print "update review for " + review_branch.branch
            revision = phlcon_differential.query(
                conduit, [working_branch.id])[0]
            author_user = phlcon_user.query_usernames_from_phids(
                conduit, [revision.authorPHID])[0]
            try:
                updateReview(
                    conduit,
                    gitContext,
                    review_branch,
                    working_branch,
                    author_user)
            except abdte.LandingException as e:
                print "landing exception"
                abdt_workingbranch.pushBadLand(
                    gitContext, review_branch, working_branch)
                commenter.exception(e)
                with phlsys_conduit.act_as_user_context(conduit, author_user):
                    phlcon_differential.create_comment(
                        conduit,
                        working_branch.id,
                        action=phlcon_differential.Action.rethink)
            except abdte.AbdUserException as e:
                print "user exception"
                abdt_workingbranch.pushBadInReview(
                    gitContext, review_branch, working_branch)
                commenter.exception(e)
Ejemplo n.º 5
0
    def testAliceEmail(self):
        users = phlcon_user.query_users_from_emails(
            self.conduit, [self.test_email])
        self.assertEqual(len(users), 1)
        self.assertEqual(users[0], self.test_user)

        user = phlcon_user.query_user_from_email(self.conduit, self.test_email)
        self.assertEqual(user.userName, self.test_user)

        phidUsers = phlcon_user.query_users_from_phids(
            self.conduit, [user.phid])
        self.assertEqual(phidUsers[0].userName, self.test_user)

        phidUsernames = phlcon_user.query_usernames_from_phids(
            self.conduit, [user.phid])
        self.assertEqual(phidUsernames[0], self.test_user)
def land(conduit, wb, gitContext, branch):
    clone = gitContext.clone
    print "landing " + wb.remote_branch + " onto " + wb.remote_base
    name, email, user = abdt_conduitgit.getPrimaryNameEmailAndUserFromBranch(
        clone, conduit, wb.remote_base, wb.remote_branch)
    d = phlcon_differential
    with phlsys_conduit.act_as_user_context(conduit, user):
        phlgit_checkout.new_branch_force_based_on(
            clone, wb.base, wb.remote_base)

        # compose the commit message
        message = d.get_commit_message(conduit, wb.id)

        try:
            with phlsys_fs.nostd():
                squashMessage = phlgit_merge.squash(
                    clone,
                    wb.remote_branch,
                    message,
                    name + " <" + email + ">")
        except phlsys_subprocess.CalledProcessError as e:
            clone.call("reset", "--hard")  # fix the working copy
            raise abdt_exception.LandingException(
                '\n' + e.stdout, branch, wb.base)

        print "- pushing " + wb.remote_base
        phlgit_push.push(clone, wb.base, gitContext.remote)
        print "- deleting " + wb.branch
        phlgit_push.delete(clone, wb.branch, gitContext.remote)
        print "- deleting " + branch
        phlgit_push.delete(clone, branch, gitContext.remote)

    print "- commenting on revision " + str(wb.id)
    commenter = abdcmnt_commenter.Commenter(conduit, wb.id)
    commenter.landedReview(branch, wb.base, squashMessage)

    authorPHID = d.query(conduit, [wb.id])[0].authorPHID
    authorUser = phlcon_user.query_usernames_from_phids(
        conduit, [authorPHID])[0]
    # TODO: there's a potential race condition on the author here
    with phlsys_conduit.act_as_user_context(conduit, authorUser):
        d.close(conduit, wb.id)