Exemplo n.º 1
0
                         filename,
                         attachid,
                         pre_hook=pre_obsolete)

    # If attaching to an existing bug (and not suppressed on the command line), take the bug
    if not opts['new'] and not opts['no_take_bug']:
        result = bz.get_bug(auth,
                            bug,
                            include_fields=['assigned_to', 'status'])
        taker = auth.username(api_server)
        if result['assigned_to_detail']['name'] != taker:
            params = {'assigned_to': taker}
            if result['status'] != 'RESOLVED':
                params['status'] = 'ASSIGNED'
            try:
                result = bz.update_bug(auth, result['id'], params)
            except Exception as e:
                raise util.Abort(e.message)


@command('newbug', [
    ('c', 'comment', '', 'Comment to add with the bug'),
    ('e', 'edit', False, 'Open a text editor to modify bug fields'),
    ('i', 'interactive', False,
     'Interactive -- request confirmation before any permanent action'),
    ('f', 'force', False,
     'Proceed even if the working directory contains changes'),
    ('', 'take-bug', False, 'Assign bug to myself'),
] + newbug_opts, _('hg newbug [-e] [[-t] TITLE] [[-c] COMMENT]'))
def newbug(ui, repo, *args, **opts):
    """
Exemplo n.º 2
0
            return True
        url, filename, description = [kwargs[k] for k in ['url', 'filename', 'description']]
        return ui.prompt(_("Obsolete patch %s (%s) - %s (y/n)?") % (url, filename, description)) == 'y'

    obsolete_old_patches(ui, auth, bug, bugzilla, filename, attachid, pre_hook=pre_obsolete)

    # If attaching to an existing bug (and not suppressed on the command line), take the bug
    if not opts['new'] and not opts['no_take_bug']:
        result = bz.get_bug(auth, bug, include_fields=['assigned_to', 'status'])
        taker = auth.username(api_server)
        if result['assigned_to_detail']['name'] != taker:
            params = {'assigned_to': taker}
            if result['status'] != 'RESOLVED':
                params['status'] = 'ASSIGNED'
            try:
                result = bz.update_bug(auth, result['id'], params)
            except Exception as e:
                raise util.Abort(e.message)

@command('newbug', [
        ('c', 'comment', '', 'Comment to add with the bug'),
         ('e', 'edit', False,
          'Open a text editor to modify bug fields'),
         ('i', 'interactive', False,
          'Interactive -- request confirmation before any permanent action'),
         ('f', 'force', False,
          'Proceed even if the working directory contains changes'),
         ('', 'take-bug', False,
          'Assign bug to myself'),
         ] + newbug_opts,
        _('hg newbug [-e] [[-t] TITLE] [[-c] COMMENT]'))
            return True
        url, filename, description = [kwargs[k] for k in ['url', 'filename', 'description']]
        return ui.prompt(_("Obsolete patch %s (%s) - %s (y/n)?") % (url, filename, description)) == 'y'

    obsolete_old_patches(ui, api_server, auth, bug, bugzilla, filename, result['id'], pre_hook=pre_obsolete)

    # If attaching to an existing bug (and not suppressed on the command line), take the bug
    if not opts['new'] and not opts['no_take_bug']:
        req = bz.get_bug(api_server, auth, bug, include_fields=['assigned_to', 'status'])
        result = json.load(urlopen(ui, req))
        taker = auth.username(api_server)
        if result['assigned_to']['name'] != taker:
            result['assigned_to'] = {'name': taker}
            if result['status'] != 'RESOLVED':
                result['status'] = 'ASSIGNED'
            req = bz.update_bug(api_server, auth, result)
            try:
                result = json.load(urlopen(ui, req))
                assert result.get('ok', None)
            except Exception, e:
                raise util.Abort(_("Error when updating bug %s: %s") % (bug, result))


def newbug(ui, repo, *args, **opts):
    """
    Create a new bug in bugzilla

    A menu will be displayed for the product and component unless a default has
    been set in the [bzexport] section of the config file (keys are 'product'
    and 'component'), or if something has been specified on the command line.