Ejemplo n.º 1
0
def func(parser, options, args):
    stack = directory.repository.current_stack
    iw = stack.repository.default_iw
    if len(args) >= 1:
        ref, patches = args[0], args[1:]
        state = log.get_stack_state(stack.repository, ref,
                                    stack.repository.rev_parse(ref))
    elif options.hard:
        iw.checkout_hard(stack.head.data.tree)
        return utils.STGIT_SUCCESS
    else:
        raise CmdException('Wrong options or number of arguments')

    trans = transaction.StackTransaction(
        stack,
        'reset',
        discard_changes=options.hard,
        allow_bad_head=True,
    )
    try:
        if patches:
            log.reset_stack_partially(trans, iw, state, patches)
        else:
            log.reset_stack(trans, iw, state)
    except transaction.TransactionHalted:
        pass
    return trans.run(iw, allow_bad_head=not patches)
Ejemplo n.º 2
0
 def __init__(self, repository, name):
     super().__init__(repository, name)
     if not stackupgrade.update_to_current_format_version(repository, name):
         raise StackException('%s: branch not initialized' % name)
     state = log.get_stack_state(self.repository, self.state_ref)
     self.patchorder = PatchOrder(state)
     self.patches = Patches(self, state)
Ejemplo n.º 3
0
def func(parser, options, args):
    if options.clear:
        if options.diff or options.number or options.full or options.graphical:
            parser.error('cannot combine --clear with other options')
        elif args:
            parser.error('cannot combine --clear with patch arguments')

    if options.graphical:
        for o in ['diff', 'number', 'full']:
            if getattr(options, o):
                parser.error('cannot combine --graphical and --%s' % o)

    stack = directory.repository.get_stack(options.branch)

    if options.clear:
        stack.clear_log()
        return

    patches = parse_patches(args, list(stack.patchorder.all))
    state = log.get_stack_state(stack.repository, stack.state_ref)
    pathlim = ['patches/%s' % pn for pn in patches]

    if options.graphical:
        cmd = ['gitk', state.simplified.sha1, '--'] + pathlim
        # Discard the exit codes generated by SIGINT, SIGKILL, and SIGTERM.
        stack.repository.run(cmd).returns([0, -2, -9, -15]).run()
    else:
        show_log(
            stack.repository,
            state.simplified,
            pathlim,
            options.number,
            options.full,
            options.diff,
        )