def bug_comment_from_user_id(bugdir, id):
    p = libbe.util.id.parse_user(bugdir, id)
    if not p['type'] in ['bug', 'comment']:
        raise libbe.command.UserError(
            '%s is a %s id, not a bug or comment id' % (id, p['type']))
    if p['bugdir'] != bugdir.uuid:
        raise libbe.command.UserError("%s doesn't belong to this bugdir (%s)" %
                                      (id, bugdir.uuid))
    bug = bugdir.bug_from_uuid(p['bug'])
    if 'comment' in p:
        comment = bug.comment_from_uuid(p['comment'])
    else:
        comment = bug.comment_root
    return (bug, comment)
Пример #2
0
def bug_comment_from_user_id(bugdir, id):
    p = libbe.util.id.parse_user(bugdir, id)
    if not p['type'] in ['bug', 'comment']:
        raise libbe.command.UserError(
            '%s is a %s id, not a bug or comment id' % (id, p['type']))
    if p['bugdir'] != bugdir.uuid:
        raise libbe.command.UserError(
            "%s doesn't belong to this bugdir (%s)"
            % (id, bugdir.uuid))
    bug = bugdir.bug_from_uuid(p['bug'])
    if 'comment' in p:
        comment = bug.comment_from_uuid(p['comment'])
    else:
        comment = bug.comment_root
    return (bug, comment)
Пример #3
0
 def _merge_comments(self,
                     bugdirs,
                     bug,
                     root_comment,
                     comments,
                     params,
                     accept_changes,
                     accept_extra_strings,
                     accept_comments=True):
     if len(comments) == 0:
         return
     if bug is None:
         raise libbe.command.UserError(
             'No root bug for merging comments:\n{}'.format('\n\n'.join(
                 [c.string() for c in comments])))
     bug.load_comments(load_full=True)
     if root_comment.uuid == libbe.comment.INVALID_UUID:
         root_comment = bug.comment_root
     else:
         root_comment = bug.comment_from_uuid(root_comment.uuid)
     new_bug = libbe.bug.Bug(bugdir=bug.bugdir, uuid=bug.uuid)
     new_bug.explicit_attrs = []
     new_bug.comment_root = copy.deepcopy(bug.comment_root)
     if root_comment.uuid == libbe.comment.INVALID_UUID:
         new_root_comment = new_bug.comment_root
     else:
         new_root_comment = new_bug.comment_from_uuid(root_comment.uuid)
     for new in new_bug.comments():
         new.explicit_attrs = []
     try:
         new_bug.add_comments(
             comments,
             default_parent=root_comment,
             ignore_missing_references=params['ignore-missing-references'])
     except libbe.comment.MissingReference as e:
         raise libbe.command.UserError(e)
     bug.merge(new_bug,
               accept_changes=accept_changes,
               accept_extra_strings=accept_extra_strings,
               accept_comments=accept_comments)
     yield bug
Пример #4
0
def bugdir_bug_comment_from_user_id(bugdirs, id):
    p = libbe.util.id.parse_user(bugdirs, id)
    if not p['type'] in ['bugdir', 'bug', 'comment']:
        raise libbe.command.UserError(
            '{} is a {} id, not a bugdir, bug, or comment id'.format(
                id, p['type']))
    if p['bugdir'] not in bugdirs:
        raise libbe.command.UserError(
            "{} doesn't belong to any bugdirs in {}".format(
                id, sorted(bugdirs.keys())))
    bugdir = bugdirs[p['bugdir']]
    if p['bugdir'] != bugdir.uuid:
        raise libbe.command.UserError("%s doesn't belong to this bugdir (%s)" %
                                      (id, bugdir.uuid))
    if 'bug' in p:
        bug = bugdir.bug_from_uuid(p['bug'])
        if 'comment' in p:
            comment = bug.comment_from_uuid(p['comment'])
        else:
            comment = bug.comment_root
    else:
        bug = comment = None
    return (bugdir, bug, comment)
Пример #5
0
def bugdir_bug_comment_from_user_id(bugdirs, id):
    p = libbe.util.id.parse_user(bugdirs, id)
    if not p['type'] in ['bugdir', 'bug', 'comment']:
        raise libbe.command.UserError(
            '{} is a {} id, not a bugdir, bug, or comment id'.format(
                id, p['type']))
    if p['bugdir'] not in bugdirs:
        raise libbe.command.UserError(
            "{} doesn't belong to any bugdirs in {}".format(
                id, sorted(bugdirs.keys())))
    bugdir = bugdirs[p['bugdir']]
    if p['bugdir'] != bugdir.uuid:
        raise libbe.command.UserError(
            "%s doesn't belong to this bugdir (%s)"
            % (id, bugdir.uuid))
    if 'bug' in p:
        bug = bugdir.bug_from_uuid(p['bug'])
        if 'comment' in p:
            comment = bug.comment_from_uuid(p['comment'])
        else:
            comment = bug.comment_root
    else:
        bug = comment = None
    return (bugdir, bug, comment)
Пример #6
0
 def _merge_comments(
     self, bugdirs, bug, root_comment, comments, params, accept_changes, accept_extra_strings, accept_comments=True
 ):
     if len(comments) == 0:
         return
     if bug is None:
         raise libbe.command.UserError(
             "No root bug for merging comments:\n{}".format("\n\n".join([c.string() for c in comments]))
         )
     bug.load_comments(load_full=True)
     if root_comment.uuid == libbe.comment.INVALID_UUID:
         root_comment = bug.comment_root
     else:
         root_comment = bug.comment_from_uuid(root_comment.uuid)
     new_bug = libbe.bug.Bug(bugdir=bug.bugdir, uuid=bug.uuid)
     new_bug.explicit_attrs = []
     new_bug.comment_root = copy.deepcopy(bug.comment_root)
     if root_comment.uuid == libbe.comment.INVALID_UUID:
         new_root_comment = new_bug.comment_root
     else:
         new_root_comment = new_bug.comment_from_uuid(root_comment.uuid)
     for new in new_bug.comments():
         new.explicit_attrs = []
     try:
         new_bug.add_comments(
             comments, default_parent=root_comment, ignore_missing_references=params["ignore-missing-references"]
         )
     except libbe.comment.MissingReference as e:
         raise libbe.command.UserError(e)
     bug.merge(
         new_bug,
         accept_changes=accept_changes,
         accept_extra_strings=accept_extra_strings,
         accept_comments=accept_comments,
     )
     yield bug