예제 #1
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)
    patches = parse_patches(args, list(stack.patchorder.all))
    logref = log.log_ref(stack.name)
    try:
        logcommit = stack.repository.refs.get(logref)
    except KeyError:
        out.info('Log is empty')
        return

    if options.clear:
        log.delete_log(stack.repository, stack.name)
        return

    stacklog = log.get_log_entry(stack.repository, logref, logcommit)
    pathlim = [os.path.join('patches', pn) for pn in patches]

    if options.graphical:
        cmd = ['gitk', stacklog.simplified.sha1, '--'] + pathlim
        # Discard the exit codes generated by SIGINT, SIGKILL, and SIGTERM.
        Run(*cmd).returns([0, -2, -9, -15]).run()
    else:
        show_log(stacklog.simplified, pathlim, options.number, options.full,
                 options.diff)
예제 #2
0
파일: reset.py 프로젝트: wberrier/stgit
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)
예제 #3
0
파일: log.py 프로젝트: miracle2k/stgit
def func(parser, options, args):
    if options.branch:
        stack = directory.repository.get_stack(options.branch)
    else:
        stack = directory.repository.current_stack
    patches = common.parse_patches(args, list(stack.patchorder.all))
    logref = log.log_ref(stack.name)
    try:
        logcommit = stack.repository.refs.get(logref)
    except KeyError:
        out.info('Log is empty')
        return

    if options.clear:
        log.delete_log(stack.repository, stack.name)
        return

    stacklog = log.get_log_entry(stack.repository, logref, logcommit)
    pathlim = [os.path.join('patches', pn) for pn in patches]

    if options.graphical:
        for o in ['diff', 'number', 'full']:
            if getattr(options, o):
                parser.error('cannot combine --graphical and --%s' % o)
        # Discard the exit codes generated by SIGINT, SIGKILL, and SIGTERM.
        run.Run(*(['gitk', stacklog.simplified.sha1, '--'] + pathlim)
                 ).returns([0, -2, -9, -15]).run()
    else:
        show_log(stacklog.simplified, pathlim,
                 options.number, options.full, options.diff)
예제 #4
0
파일: reset.py 프로젝트: miracle2k/stgit
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)