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)
Exemple #2
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)