Esempio n. 1
0
def GetMergeIssueDetails(issue_tracker, commit_cache_key):
    """Get's the issue this one might be merged into.

  Returns: A dict with the following fields:
    issue: The issue details from the issue tracker service.
    id: The id of the issue we should merge into. This may be set to None if
        either there is no other bug with this culprit, or we shouldn't try to
        merge into that bug.
    comments: Additional comments to add to the bug.
  """
    merge_issue_key = layered_cache.GetExternal(commit_cache_key)
    if not merge_issue_key:
        return {'issue': {}, 'id': None, 'comments': ''}

    merge_issue = issue_tracker.GetIssue(merge_issue_key)
    if not merge_issue:
        return {'issue': {}, 'id': None, 'comments': ''}

    # Check if we can duplicate this issue against an existing issue.
    merge_issue_id = None
    additional_comments = ""

    # We won't duplicate against an issue that itself is already
    # a duplicate though. Could follow the whole chain through but we'll
    # just keep things simple and flat for now.
    if merge_issue.get('status') != issue_tracker_service.STATUS_DUPLICATE:
        merge_issue_id = str(merge_issue.get('id'))

    return {
        'issue': merge_issue,
        'id': merge_issue_id,
        'comments': additional_comments
    }
Esempio n. 2
0
 def testGetAndSet_External(self):
   layered_cache.SetExternal('str', 'Hello, World!')
   layered_cache.SetExternal('dict', {'hello': [1, 2, 3]})
   self.assertEqual(
       'Hello, World!',
       cPickle.loads(
           ndb.Key('CachedPickledString',
                   'externally_visible__str').get().value))
   self.assertEqual(None,
                    ndb.Key('CachedPickledString', 'internal_only__str').get())
   self.assertEqual('Hello, World!', layered_cache.GetExternal('str'))
   self.assertEqual({'hello': [1, 2, 3]},
                    cPickle.loads(
                        ndb.Key('CachedPickledString',
                                'externally_visible__dict').get().value))
   self.assertEqual(
       None,
       ndb.Key('CachedPickledString', 'internal_only__dict').get())
   self.assertEqual({'hello': [1, 2, 3]}, layered_cache.GetExternal('dict'))
def GetMergeIssueDetails(issue_tracker, commit_cache_key):
    """Get's the issue this one might be merged into.

  Returns: A dict with the following fields:
    issue: The issue details from the issue tracker service.
    id: The id of the issue we should merge into. This may be set to None if
        either there is no other bug with this culprit, or we shouldn't try to
        merge into that bug.
    comments: Additional comments to add to the bug.
  """
    merge_issue_key = layered_cache.GetExternal(commit_cache_key)
    if not merge_issue_key:
        return {'issue': {}, 'id': None, 'comments': ''}

    merge_issue = issue_tracker.GetIssue(merge_issue_key)
    if not merge_issue:
        return {'issue': {}, 'id': None, 'comments': ''}

    # Check if we can duplicate this issue against an existing issue.
    merge_issue_id = None
    additional_comments = ""

    # We won't duplicate against an issue that itself is already
    # a duplicate though. Could follow the whole chain through but we'll
    # just keep things simple and flat for now.
    if merge_issue.get('status') != issue_tracker_service.STATUS_DUPLICATE:
        merge_issue_id = str(merge_issue.get('id'))

    # We also don't want to duplicate against an issue that already has a bunch
    # of bisects pointing at different culprits.
    if merge_issue_id:
        jobs = try_job.TryJob.query(
            try_job.TryJob.bug_id == int(merge_issue_id)).fetch()
        culprits = set([j.GetCulpritCL() for j in jobs if j.GetCulpritCL()])
        if len(culprits) >= 2:
            additional_comments += _NOT_DUPLICATE_MULTIPLE_BUGS_MSG % merge_issue_id
            merge_issue_id = None

    return {
        'issue': merge_issue,
        'id': merge_issue_id,
        'comments': additional_comments
    }