예제 #1
0
파일: status.py 프로젝트: guanqun/stgit
def status(files, modified, new, deleted, conflict, unknown, noexclude):
    """Show the tree status
    """
    cache_files = git.tree_status(files,
                                  unknown = (not files),
                                  noexclude = noexclude)
    filtered = (modified or new or deleted or conflict or unknown)

    if filtered:
        filestat = []
        if modified:
            filestat.append('M')
        if new:
            filestat.append('A')
            filestat.append('N')
        if deleted:
            filestat.append('D')
        if conflict:
            filestat.append('C')
        if unknown:
            filestat.append('?')
        cache_files = [x for x in cache_files if x[0] in filestat]

    output = []
    for st, fn in cache_files:
        if filtered:
            output.append(fn)
        else:
            output.append('%s %s' % (st, fn))
    for o in sorted(output):
        out.stdout(o)
예제 #2
0
def func(parser, options, args):
    """Show the patches modifying a file
    """
    if not args:
        files = [path for (stat, path) in git.tree_status(verbose=True)]
        # git.tree_status returns absolute paths
    else:
        files = git.ls_files(args)
    directory.cd_to_topdir()

    if not files:
        raise CmdException('No files specified or no local changes')

    applied = crt_series.get_applied()
    if not applied:
        raise CmdException('No patches applied')

    revs = git.modifying_revs(files, crt_series.get_base(),
                              crt_series.get_head())
    revs.reverse()

    # build the patch/revision mapping
    rev_patch = dict()
    for name in applied:
        patch = crt_series.get_patch(name)
        rev_patch[patch.get_top()] = patch

    # print the patch names
    diff_lines = []
    for rev in revs:
        patch = rev_patch[rev]
        if options.diff:
            diff_lines.extend([
                b'-' * 79,
                patch.get_name().encode('utf-8'),
                b'-' * 79,
                patch.get_description().encode('utf-8'),
                b'---',
                b'',
                git.diff(files, patch.get_bottom(), patch.get_top()),
            ])
        else:
            out.stdout(patch.get_name())

    if options.diff:
        pager(b'\n'.join(diff_lines))
예제 #3
0
파일: patches.py 프로젝트: snits/stgit
def func(parser, options, args):
    """Show the patches modifying a file
    """
    if not args:
        files = [path for (stat,path) in git.tree_status(verbose = True)]
        # git.tree_status returns absolute paths
    else:
        files = git.ls_files(args)
    directory.cd_to_topdir()

    if not files:
        raise CmdException('No files specified or no local changes')

    applied = crt_series.get_applied()
    if not applied:
        raise CmdException('No patches applied')

    revs = git.modifying_revs(files, crt_series.get_base(),
                              crt_series.get_head())
    revs.reverse()

    # build the patch/revision mapping
    rev_patch = dict()
    for name in applied:
        patch = crt_series.get_patch(name)
        rev_patch[patch.get_top()] = patch

    # print the patch names
    diff_output = ''
    for rev in revs:
        if rev in rev_patch:
            patch = rev_patch[rev]
            if options.diff:
                diff_output += diff_tmpl \
                               % (patch.get_name(), patch.get_description(),
                                  git.diff(files, patch.get_bottom(),
                                           patch.get_top()))
            else:
                out.stdout(patch.get_name())

    if options.diff:
        pager(diff_output)
예제 #4
0
파일: patches.py 프로젝트: saminigod/cygwin
def func(parser, options, args):
    """Show the patches modifying a file
    """
    if not args:
        files = [stat[1] for stat in git.tree_status(verbose=True)]
    else:
        files = args

    if not files:
        raise CmdException, 'No files specified or no local changes'

    applied = crt_series.get_applied()
    if not applied:
        raise CmdException, 'No patches applied'

    revs = git.modifying_revs(files, crt_series.get_base(),
                              crt_series.get_head())
    revs.reverse()

    # build the patch/revision mapping
    rev_patch = dict()
    for name in applied:
        patch = crt_series.get_patch(name)
        rev_patch[patch.get_top()] = patch

    # print the patch names
    diff_output = ''
    for rev in revs:
        if rev in rev_patch:
            patch = rev_patch[rev]
            if options.diff:
                diff_output += diff_tmpl \
                               % (patch.get_name(), patch.get_description(),
                                  git.diff(files, patch.get_bottom(),
                                           patch.get_top()))
            else:
                out.stdout(patch.get_name())

    if options.diff:
        pager(diff_output)
예제 #5
0
파일: refresh.py 프로젝트: saminigod/cygwin
def func(parser, options, args):
    autoresolved = config.get('stgit.autoresolved')

    if autoresolved != 'yes':
        check_conflicts()

    if options.patch:
        if args or options.update:
            raise CmdException, \
                  'Only full refresh is available with the --patch option'
        patch = options.patch
        if not crt_series.patch_applied(patch):
            raise CmdException, 'Patches "%s" not applied' % patch
    else:
        patch = crt_series.get_current()
        if not patch:
            raise CmdException, 'No patches applied'

    if not options.force:
        check_head_top_equal()

    if options.undo:
        out.start('Undoing the refresh of "%s"' % patch)
        crt_series.undo_refresh()
        out.done()
        return

    if options.author:
        options.authname, options.authemail = name_email(options.author)

    if options.sign:
        sign_str = 'Signed-off-by'
        if options.ack:
            raise CmdException, '--ack and --sign were both specified'
    elif options.ack:
        sign_str = 'Acked-by'
    else:
        sign_str = None

    files = [x[1] for x in git.tree_status(verbose=True)]
    if args:
        files = [f for f in files if f in args]

    if files or not crt_series.head_top_equal() \
           or options.edit or options.message \
           or options.authname or options.authemail or options.authdate \
           or options.commname or options.commemail \
           or options.sign or options.ack:

        if options.patch:
            applied = crt_series.get_applied()
            between = applied[:applied.index(patch):-1]
            pop_patches(between, keep=True)
        elif options.update:
            rev1 = git_id('//bottom')
            rev2 = git_id('//top')
            patch_files = git.barefiles(rev1, rev2).split('\n')
            files = [f for f in files if f in patch_files]
            if not files:
                out.info('No modified files for updating patch "%s"' % patch)
                return

        out.start('Refreshing patch "%s"' % patch)

        if autoresolved == 'yes':
            resolved_all()
        crt_series.refresh_patch(files=files,
                                 message=options.message,
                                 edit=options.edit,
                                 show_patch=options.showpatch,
                                 author_name=options.authname,
                                 author_email=options.authemail,
                                 author_date=options.authdate,
                                 committer_name=options.commname,
                                 committer_email=options.commemail,
                                 backup=True,
                                 sign_str=sign_str,
                                 notes=options.annotate)

        if crt_series.empty_patch(patch):
            out.done('empty patch')
        else:
            out.done()

        if options.patch:
            between.reverse()
            push_patches(between)
    elif options.annotate:
        # only annotate the top log entry as there is no need to
        # refresh the patch and generate a full commit
        crt_series.log_patch(crt_series.get_patch(patch),
                             None,
                             notes=options.annotate)
    else:
        out.info('Patch "%s" is already up to date' % patch)
예제 #6
0
파일: refresh.py 프로젝트: c0ns0le/cygwin
def func(parser, options, args):
    autoresolved = config.get('stgit.autoresolved')

    if autoresolved != 'yes':
        check_conflicts()

    if options.patch:
        if args or options.update:
            raise CmdException, \
                  'Only full refresh is available with the --patch option'
        patch = options.patch
        if not crt_series.patch_applied(patch):
            raise CmdException, 'Patches "%s" not applied' % patch
    else:
        patch = crt_series.get_current()
        if not patch:
            raise CmdException, 'No patches applied'

    if not options.force:
        check_head_top_equal()

    if options.undo:
        out.start('Undoing the refresh of "%s"' % patch)
        crt_series.undo_refresh()
        out.done()
        return

    if options.author:
        options.authname, options.authemail = name_email(options.author)

    if options.sign:
        sign_str = 'Signed-off-by'
        if options.ack:
            raise CmdException, '--ack and --sign were both specified'
    elif options.ack:
        sign_str = 'Acked-by'
    else:
        sign_str = None

    files = [x[1] for x in git.tree_status(verbose = True)]
    if args:
        files = [f for f in files if f in args]

    if files or not crt_series.head_top_equal() \
           or options.edit or options.message \
           or options.authname or options.authemail or options.authdate \
           or options.commname or options.commemail \
           or options.sign or options.ack:

        if options.patch:
            applied = crt_series.get_applied()
            between = applied[:applied.index(patch):-1]
            pop_patches(between, keep = True)
        elif options.update:
            rev1 = git_id('//bottom')
            rev2 = git_id('//top')
            patch_files = git.barefiles(rev1, rev2).split('\n')
            files = [f for f in files if f in patch_files]
            if not files:
                out.info('No modified files for updating patch "%s"' % patch)
                return

        out.start('Refreshing patch "%s"' % patch)

        if autoresolved == 'yes':
            resolved_all()
        crt_series.refresh_patch(files = files,
                                 message = options.message,
                                 edit = options.edit,
                                 show_patch = options.showpatch,
                                 author_name = options.authname,
                                 author_email = options.authemail,
                                 author_date = options.authdate,
                                 committer_name = options.commname,
                                 committer_email = options.commemail,
                                 backup = True, sign_str = sign_str,
                                 notes = options.annotate)

        if crt_series.empty_patch(patch):
            out.done('empty patch')
        else:
            out.done()

        if options.patch:
            between.reverse()
            push_patches(between)
    elif options.annotate:
        # only annotate the top log entry as there is no need to
        # refresh the patch and generate a full commit
        crt_series.log_patch(crt_series.get_patch(patch), None,
                             notes = options.annotate)
    else:
        out.info('Patch "%s" is already up to date' % patch)