当前位置: 首页>>代码示例>>Python>>正文


Python argparse.opt函数代码示例

本文整理汇总了Python中stgit.argparse.opt函数的典型用法代码示例。如果您正苦于以下问题:Python opt函数的具体用法?Python opt怎么用?Python opt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了opt函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: opt

description = """
Create, clone, switch between, rename, or delete development branches
within a git repository.

'stg branch'::
        Display the name of the current branch.

'stg branch' <branch>::
        Switch to the given branch."""

args = [argparse.all_branches]
options = [
    opt('-l', '--list', action = 'store_true',
        short = 'List the branches contained in this repository', long = """
        List each branch in the current repository, followed by its
        branch description (if any). The current branch is prefixed
        with '>'. Branches that have been initialized for StGit (with
        linkstg:init[]) are prefixed with 's'. Protected branches are
        prefixed with 'p'."""),
    opt('-c', '--create', action = 'store_true',
        short = 'Create (and switch to) a new branch', long = """
        Create (and switch to) a new branch. The new branch is already
        initialized as an StGit patch stack, so you do not have to run
        linkstg:init[] manually. If you give a committish argument,
        the new branch is based there; otherwise, it is based at the
        current HEAD.

        StGit will try to detect the branch off of which the new
        branch is forked, as well as the remote repository from which
        that parent branch is taken (if any), so that running
        linkstg:pull[] will automatically pull new commits from the
开发者ID:miracle2k,项目名称:stgit,代码行数:31,代码来源:branch.py

示例2: opt

usage = ['[options] [--] [<patch-range>]']
description = """
Show all the patches in the series, or just those in the given range,
ordered from top to bottom.

The applied patches are prefixed with a +++ (except the current patch,
which is prefixed with a +>+), the unapplied patches with a +-+, and
the hidden patches with a +!+.

Empty patches are prefixed with a '0'."""

args = [argparse.patch_range(argparse.applied_patches,
                             argparse.unapplied_patches,
                             argparse.hidden_patches)]
options = [
    opt('-b', '--branch', args = [argparse.stg_branches],
        short = 'Use BRANCH instead of the default branch'),
    opt('-a', '--all', action = 'store_true',
        short = 'Show all patches, including the hidden ones'),
    opt('-A', '--applied', action = 'store_true',
        short = 'Show the applied patches only'),
    opt('-U', '--unapplied', action = 'store_true',
        short = 'Show the unapplied patches only'),
    opt('-H', '--hidden', action = 'store_true',
        short = 'Show the hidden patches only'),
    opt('-m', '--missing', metavar = 'BRANCH',  args = [argparse.stg_branches],
        short = 'Show patches in BRANCH missing in current'),
    opt('-c', '--count', action = 'store_true',
        short = 'Print the number of patches in the series'),
    opt('-d', '--description', action = 'store_true',
        short = 'Show a short description for each patch'),
    opt('--author', action = 'store_true',
开发者ID:terinjokes,项目名称:stgit,代码行数:32,代码来源:series.py

示例3: current

"""

from stgit.argparse import opt
from stgit.commands import common
from stgit.out import out
from stgit import argparse

help = 'Print the name of the top patch'
kind = 'stack'
usage = ['']
description = """
Print the name of the current (topmost) patch."""

args = []
options = [
    opt('-b', '--branch', args = [argparse.stg_branches],
        short = 'Use BRANCH instead of the default branch')]

directory = common.DirectoryHasRepositoryLib()

def func(parser, options, args):
    """Show the name of the topmost patch
    """
    if len(args) != 0:
        parser.error('incorrect number of arguments')

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

    if applied:
        out.stdout(applied[-1])
    else:
开发者ID:terinjokes,项目名称:stgit,代码行数:32,代码来源:top.py

示例4: patch

"""

help = 'Show the files modified by a patch (or the current patch)'
kind = 'patch'
usage = ['[options] [--] [[<branch>:]<patch>]']
description = """
List the files modified by the given patch (defaulting to the current
one). Passing the '--stat' option shows the diff statistics for the
given patch. Note that this command doesn't show the files modified in
the working tree and not yet included in the patch by a 'refresh'
command. Use the 'diff' or 'status' commands for these files."""

args = [argparse.applied_patches, argparse.unapplied_patches,
        argparse.hidden_patches]
options = [
    opt('-s', '--stat', action = 'store_true',
        short = 'Show the diffstat'),
    opt('--bare', action = 'store_true',
        short = 'Bare file names (useful for scripting)'),
    ] + argparse.diff_opts_option()

directory = DirectoryHasRepository(log=False)
crt_series = None


def func(parser, options, args):
    """Show the files modified by a patch (or the current patch)
    """
    if len(args) == 0:
        patch = 'HEAD'
    elif len(args) == 1:
        patch = args[0]
开发者ID:snits,项目名称:stgit,代码行数:32,代码来源:files.py

示例5: repository

kind = 'stack'
usage = ['[options] [<repository>]']
description = """
Pull the latest changes from the given remote repository (defaulting
to branch.<name>.remote, or 'origin' if not set). This command works
by popping all the patches from the stack, pulling the changes in the
parent repository, setting the base of the stack to the latest parent
HEAD and pushing the patches back (unless '--nopush' is specified).
The 'push' operation can fail if there are conflicts. They need to be
resolved and the patch pushed again.

Check the 'git fetch' documentation for the <repository> format."""

args = [argparse.repo]
options = [
    opt('-n', '--nopush', action = 'store_true',
        short = 'Do not push the patches back after pulling'),
    opt('-m', '--merged', action = 'store_true',
        short = 'Check for patches merged upstream')]

directory = DirectoryGotoToplevel(log = True)

def func(parser, options, args):
    """Pull the changes from a remote repository
    """
    policy = config.get('branch.%s.stgit.pull-policy' % crt_series.get_name()) or \
             config.get('stgit.pull-policy')

    if policy == 'rebase':
        # parent is local
        if len(args) == 1:
            parser.error('specifying a repository is meaningless for policy="%s"' % policy)
开发者ID:miracle2k,项目名称:stgit,代码行数:32,代码来源:pull.py

示例6: opt

  %(description)s - patch description
  %(shortdescr)s  - the first line of the patch description
  %(longdescr)s   - the rest of the patch description, after the first line
  %(diffstat)s    - the diff statistics
  %(authname)s    - author's name
  %(authemail)s   - author's e-mail
  %(authdate)s    - patch creation date
  %(commname)s    - committer's name
  %(commemail)s   - committer's e-mail"""

args = [argparse.patch_range(argparse.applied_patches,
                             argparse.unapplied_patches,
                             argparse.hidden_patches)]
options = [
    opt('-d', '--dir', args = [argparse.dir],
        short = 'Export patches to DIR instead of the default'),
    opt('-p', '--patch', action = 'store_true',
        short = 'Append .patch to the patch names'),
    opt('-e', '--extension',
        short = 'Append .EXTENSION to the patch names'),
    opt('-n', '--numbered', action = 'store_true',
        short = 'Prefix the patch names with order numbers'),
    opt('-t', '--template', metavar = 'FILE', args = [argparse.files],
        short = 'Use FILE as a template'),
    opt('-b', '--branch', args = [argparse.stg_branches],
        short = 'Use BRANCH instead of the default branch'),
    opt('-s', '--stdout', action = 'store_true',
        short = 'Dump the patches to the standard output'),
    ] + argparse.diff_opts_option()

directory = common.DirectoryHasRepositoryLib()
开发者ID:miracle2k,项目名称:stgit,代码行数:31,代码来源:export.py

示例7: opt

The -n/--number option specifies the number of patches to uncommit. In
this case, at most one patch name may be specified. It is used as
prefix to which the patch number is appended. If no patch names are
provided on the command line, StGIT automatically generates them based
on the first line of the patch description.

The -t/--to option specifies that all commits up to and including the
given commit should be uncommitted.

Only commits with exactly one parent can be uncommitted; in other
words, you can't uncommit a merge."""

args = []
options = [
    opt('-n', '--number', type = 'int',
        short = 'Uncommit the specified number of commits'),
    opt('-t', '--to', args = [argparse.commit],
        short = 'Uncommit to the specified commit'),
    opt('-x', '--exclusive', action = 'store_true',
        short = 'Exclude the commit specified by the --to option')]

directory = common.DirectoryHasRepositoryLib()

def func(parser, options, args):
    """Uncommit a number of patches.
    """
    stack = directory.repository.current_stack
    if options.to:
        if options.number:
            parser.error('cannot give both --to and --number')
        if len(args) != 0:
开发者ID:samv,项目名称:stgit,代码行数:31,代码来源:uncommit.py

示例8: opt

from stgit import argparse, stack, git

help = 'Synchronise patches with a branch or a series'
kind = 'patch'
usage = ['[options] [<patch1>] [<patch2>] [<patch3>..<patch4>]']
description = """
For each of the specified patches perform a three-way merge with the
same patch in the specified branch or series. The command can be used
for keeping patches on several branches in sync. Note that the
operation may fail for some patches because of conflicts. The patches
in the series must apply cleanly."""

args = [argparse.patch_range(argparse.applied_patches,
                             argparse.unapplied_patches)]
options = [
    opt('-a', '--all', action = 'store_true',
        short = 'Synchronise all the applied patches'),
    opt('-B', '--ref-branch', args = [argparse.stg_branches],
        short = 'Syncronise patches with BRANCH'),
    opt('-s', '--series', args = [argparse.files],
        short = 'Syncronise patches with SERIES')]

directory = DirectoryGotoToplevel(log = True)

def __check_all():
    check_local_changes()
    check_conflicts()
    check_head_top_equal(crt_series)

def __branch_merge_patch(remote_series, pname):
    """Merge a patch from a remote branch into the current tree.
    """
开发者ID:miracle2k,项目名称:stgit,代码行数:32,代码来源:sync.py

示例9: opt

Behind the scenes, stg refresh first creates a new temporary patch
with your updates, and then merges that patch into the patch you asked
to have refreshed. If you asked to refresh a patch other than the
topmost patch, there can be conflicts; in that case, the temporary
patch will be left for you to take care of, for example with stg
squash.

The creation of the temporary patch is recorded in a separate entry in
the patch stack log; this means that one undo step will undo the merge
between the other patch and the temp patch, and two undo steps will
additionally get rid of the temp patch."""

args = [argparse.dirty_files]
options = [
    opt('-u', '--update', action = 'store_true',
        short = 'Only update the current patch files'),
    opt('-i', '--index', action = 'store_true',
        short = 'Refresh from index instead of worktree', long = """
        Instead of setting the patch top to the current contents of
        the worktree, set it to the current contents of the index."""),
    opt('-F', '--force', action = 'store_true',
        short = 'Force refresh even if index is dirty', long = """
        Instead of warning the user when some work has already been staged (such
        as with git add interactive mode) force a full refresh."""),
    opt('-p', '--patch', args = [argparse.other_applied_patches,
                                 argparse.unapplied_patches],
        short = 'Refresh (applied) PATCH instead of the top patch'),
    opt('-e', '--edit', action = 'store_true',
        short = 'Invoke an editor for the patch description'),
    opt('-a', '--annotate', metavar = 'NOTE',
        short = 'Annotate the patch log entry')
开发者ID:terinjokes,项目名称:stgit,代码行数:31,代码来源:refresh.py

示例10: diff

from stgit.lib import git as gitlib

help = 'Show the tree diff'
kind = 'wc'
usage = ['[options] [--] [<files or dirs>]']
description = """
Show the diff (default) or diffstat between the current working copy
or a tree-ish object and another tree-ish object (defaulting to HEAD).
File names can also be given to restrict the diff output. The
tree-ish object has the format accepted by the linkstg:id[] command."""

args = [argparse.known_files, argparse.dirty_files]
options = [
    opt('-r', '--range', metavar = 'rev1[..[rev2]]', dest = 'revs',
        args = [argparse.patch_range(argparse.applied_patches,
                                     argparse.unapplied_patches,
                                     argparse.hidden_patches)],
        short = 'Show the diff between revisions'),
    opt('-s', '--stat', action = 'store_true',
        short = 'Show the stat instead of the diff'),
    ] + argparse.diff_opts_option()

directory = DirectoryHasRepository(log = False)

def func(parser, options, args):
    """Show the tree diff
    """
    args = git.ls_files(args)
    directory.cd_to_topdir()

    if options.revs:
开发者ID:terinjokes,项目名称:stgit,代码行数:31,代码来源:diff.py

示例11: opt

  %(authname)s     - author's name
  %(commemail)s    - committer's e-mail
  %(commname)s     - committer's name
  %(diff)s         - unified diff of the patch
  %(fromauth)s     - 'From: author\n\n' if different from sender
  %(longdescr)s    - the rest of the patch description, after the first line
  %(patch)s        - patch name
  %(prefix)s       - 'prefix' string passed on the command line
  %(pspace)s       - ' ' if %(prefix)s is non-empty, otherwise empty string
  %(shortdescr)s   - the first line of the patch description"""

args = [argparse.patch_range(argparse.applied_patches,
                             argparse.unapplied_patches,
                             argparse.hidden_patches)]
options = [
    opt('-a', '--all', action = 'store_true',
        short = 'E-mail all the applied patches'),
    opt('--to', action = 'append',
        short = 'Add TO to the To: list'),
    opt('--cc', action = 'append',
        short = 'Add CC to the Cc: list'),
    opt('--bcc', action = 'append',
        short = 'Add BCC to the Bcc: list'),
    opt('--auto', action = 'store_true',
        short = 'Automatically cc the patch signers'),
    opt('--no-thread', action = 'store_true',
        short = 'Do not send subsequent messages as replies'),
    opt('--unrelated', action = 'store_true',
        short = 'Send patches without sequence numbering'),
    opt('--attach', action = 'store_true',
        short = 'Send a patch as attachment'),
    opt('--attach-inline', action = 'store_true',
开发者ID:samv,项目名称:stgit,代码行数:32,代码来源:mail.py

示例12: opt

Show the status of the whole working copy or the given files. The
command also shows the files in the current directory which are not
under revision control. The files are prefixed as follows:

  M - locally modified
  N - newly added to the repository
  D - deleted from the repository
  C - conflict
  ? - unknown

An 'stg refresh' command clears the status of the modified, new and
deleted files."""

args = [argparse.files]
options = [
    opt('-m', '--modified', action = 'store_true',
        short = 'Show modified files only'),
    opt('-n', '--new', action = 'store_true',
        short = 'Show new files only'),
    opt('-d', '--deleted', action = 'store_true',
        short = 'Show deleted files only'),
    opt('-c', '--conflict', action = 'store_true',
        short = 'Show conflict files only'),
    opt('-u', '--unknown', action = 'store_true',
        short = 'Show unknown files only'),
    opt('-x', '--noexclude', action = 'store_true',
        short = 'Do not exclude any files from listing'),
    opt('--reset', action = 'store_true',
        short = 'Reset the current tree changes')]

directory = DirectoryHasRepository(needs_current_series = False, log = False)
开发者ID:guanqun,项目名称:stgit,代码行数:31,代码来源:status.py

示例13: opt

If the patch diff is edited but does not apply, no changes are made to
the patch at all. The edited patch is saved to a file which you can
feed to "stg edit --file", once you have made sure it does apply.

With --set-tree you set the git tree of the patch to the specified
TREE-ISH without changing the tree of any other patches. When used on
the top patch, the index and work tree will be updated to match the
tree.  This low-level option is primarily meant to be used by tools
built on top of StGit, such as the Emacs mode. See also the --set-tree
flag of stg push."""

args = [argparse.applied_patches, argparse.unapplied_patches,
        argparse.hidden_patches]
options = (
    [ opt('-d', '--diff', action = 'store_true',
          short = 'Edit the patch diff'),
      opt('-e', '--edit', action = 'store_true',
          short = 'Invoke interactive editor') ] +
    argparse.sign_options() +
    argparse.message_options(save_template = True) +
    argparse.hook_options() +
    argparse.author_options() + argparse.diff_opts_option() +
    [ opt('-t', '--set-tree', action = 'store',
          metavar = 'TREE-ISH',
          short = 'Set the git tree of the patch to TREE-ISH') ])

directory = common.DirectoryHasRepositoryLib()

def func(parser, options, args):
    """Edit the given patch or the current one.
    """
开发者ID:snits,项目名称:stgit,代码行数:31,代码来源:edit.py

示例14: opt

from stgit.commands.common import *
from stgit import argparse, git
from stgit.lib import git as gitlib

help = 'Show the commit corresponding to a patch'
kind = 'patch'
usage = ['[options] [--] [<patch1>] [<patch2>] [<patch3>..<patch4>]']
description = """
Show the commit log and the diff corresponding to the given patches.
The output is similar to that generated by 'git show'."""

args = [argparse.patch_range(argparse.applied_patches,
                             argparse.unapplied_patches,
                             argparse.hidden_patches)]
options = [
    opt('-b', '--branch', args = [argparse.stg_branches],
        short = 'Use BRANCH instead of the default branch'),
    opt('-a', '--applied', action = 'store_true',
        short = 'Show the applied patches'),
    opt('-u', '--unapplied', action = 'store_true',
        short = 'Show the unapplied patches'),
    opt('-s', '--stat', action = 'store_true',
        short = 'Show a diffstat summary of the specified patches'),
    ] + argparse.diff_opts_option()

directory = DirectoryHasRepository(log = False)

def func(parser, options, args):
    """Show commit log and diff
    """
    if options.applied:
        patches = crt_series.get_applied()
开发者ID:GymWenFLL,项目名称:tpp_libs,代码行数:32,代码来源:show.py

示例15: opt

help = 'Display the patch changelog'
kind = 'stack'
usage = ['[options] [<patches>]']
description = """
List the history of the patch stack: the stack log. If one or more
patch names are given, limit the list to the log entries that touch
the named patches.

"stg undo" and "stg redo" let you step back and forth in the patch
stack. "stg reset" lets you go directly to any state."""

args = [argparse.patch_range(argparse.applied_patches,
                             argparse.unapplied_patches,
                             argparse.hidden_patches)]
options = [
    opt('-b', '--branch', args = [argparse.stg_branches],
        short = 'Use BRANCH instead of the default one'),
    opt('-d', '--diff', action = 'store_true',
        short = 'Show the refresh diffs'),
    opt('-n', '--number', type = 'int',
        short = 'Limit the output to NUMBER commits'),
    opt('-f', '--full', action = 'store_true',
        short = 'Show the full commit ids'),
    opt('-g', '--graphical', action = 'store_true',
        short = 'Run gitk instead of printing'),
    opt('--clear', action = 'store_true',
        short = 'Clear the log history')]

directory = common.DirectoryHasRepositoryLib()

def show_log(stacklog, pathlim, num, full, show_diff):
    cmd = ['git', 'log']
开发者ID:miracle2k,项目名称:stgit,代码行数:32,代码来源:log.py


注:本文中的stgit.argparse.opt函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。