Exemple #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_log_entry(
            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)
def func(parser, options, args):
    stack = directory.repository.current_stack
    if options.number < 1:
        raise CmdException('Bad number of commands to undo')
    state = log.undo_state(stack, options.number)
    trans = transaction.StackTransaction(stack, discard_changes=options.hard)
    try:
        log.reset_stack(trans, stack.repository.default_iw, state)
    except transaction.TransactionHalted:
        pass
    return trans.execute('undo %d' % options.number,
                         stack.repository.default_iw,
                         allow_bad_head=True)
Exemple #3
0
def func(parser, options, args):
    stack = directory.repository.current_stack
    if options.number < 1:
        raise common.CmdException('Bad number of undos to redo')
    state = log.undo_state(stack, -options.number)
    trans = transaction.StackTransaction(stack, 'redo %d' % options.number,
                                         discard_changes = options.hard,
                                         allow_bad_head = True)
    try:
        log.reset_stack(trans, stack.repository.default_iw, state)
    except transaction.TransactionHalted:
        pass
    return trans.run(stack.repository.default_iw, allow_bad_head = True)
Exemple #4
0
def func(parser, options, args):
    stack = directory.repository.current_stack
    if len(args) >= 1:
        ref, patches = args[0], args[1:]
        state = log.get_log_entry(stack.repository, ref,
                                  stack.repository.rev_parse(ref))
    else:
        raise common.CmdException('Wrong number of arguments')
    trans = transaction.StackTransaction(stack, 'reset',
                                         discard_changes = options.hard,
                                         allow_bad_head = True)
    try:
        if patches:
            log.reset_stack_partially(trans, stack.repository.default_iw,
                                      state, patches)
        else:
            log.reset_stack(trans, stack.repository.default_iw, state)
    except transaction.TransactionHalted:
        pass
    return trans.run(stack.repository.default_iw, allow_bad_head = not patches)