Exemplo n.º 1
0
    ),
    opt(
        '-s',
        '--submodules',
        action='store_true',
        short='Include submodules when refreshing patch contents',
    ),
    opt(
        '',
        '--no-submodules',
        action='store_false',
        dest='submodules',
        short='Exclude submodules when refreshing patch contents',
    )
] + (argparse.message_options(save_template=False) + argparse.hook_options() +
     argparse.sign_options() + argparse.author_options())

directory = common.DirectoryHasRepositoryLib()


def get_patch(stack, given_patch):
    """Get the name of the patch we are to refresh."""
    if given_patch:
        patch_name = given_patch
        if not stack.patches.exists(patch_name):
            raise common.CmdException('%s: no such patch' % patch_name)
        return patch_name
    else:
        if not stack.patchorder.applied:
            raise common.CmdException(
                'Cannot refresh top patch because no patches are applied')
Exemplo n.º 2
0
            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(
            "-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"),
    ]
    + (argparse.message_options(save_template=False) + argparse.sign_options() + argparse.author_options())
)

directory = common.DirectoryHasRepositoryLib()


def get_patch(stack, given_patch):
    """Get the name of the patch we are to refresh."""
    if given_patch:
        patch_name = given_patch
        if not stack.patches.exists(patch_name):
            raise common.CmdException("%s: no such patch" % patch_name)
        return patch_name
    else:
        if not stack.patchorder.applied:
            raise common.CmdException("Cannot refresh top patch, because no patches are applied")
Exemplo n.º 3
0
            '-s',
            '--submodules',
            action='store_true',
            short='Include submodules when refreshing patch contents',
        ),
        opt(
            '--no-submodules',
            action='store_false',
            dest='submodules',
            short='Exclude submodules when refreshing patch contents',
        ),
    ]
    + (
        argparse.message_options(save_template=False)
        + argparse.hook_options()
        + argparse.sign_options()
        + argparse.author_options()
    )
)

directory = DirectoryHasRepository()


def get_patch(stack, given_patch):
    """Get the name of the patch we are to refresh."""
    if given_patch:
        patch_name = given_patch
        if not stack.patches.exists(patch_name):
            raise CmdException('%s: no such patch' % patch_name)
        return patch_name
    else:
Exemplo n.º 4
0
top of the stack. Uncommitted changes in the work tree are not
included in the patch -- that is handled by linkstg:refresh[].

The given name must be unique in the stack, and may only contain
alphanumeric characters, dashes and underscores. If no name is given,
one is generated from the first line of the patch's commit message.

An editor will be launched to edit the commit message to be used for
the patch, unless the '--message' flag already specified one. The
'patchdescr.tmpl' template file (if available) is used to pre-fill the
editor."""

args = []
options = (argparse.author_options() +
           argparse.message_options(save_template=True) +
           argparse.sign_options() + argparse.hook_options())

directory = DirectoryHasRepository()


def func(parser, options, args):
    """Create a new patch."""
    stack = directory.repository.current_stack
    if stack.repository.default_index.conflicts():
        raise CmdException(
            'Cannot create a new patch -- resolve conflicts first')

    # Choose a name for the new patch -- or None, which means make one
    # up later when we've gotten hold of the commit message.
    if len(args) == 0:
        name = None
Exemplo n.º 5
0
top of the stack. Uncommitted changes in the work tree are not
included in the patch -- that is handled by linkstg:refresh[].

The given name must be unique in the stack, and may only contain
alphanumeric characters, dashes and underscores. If no name is given,
one is generated from the first line of the patch's commit message.

An editor will be launched to edit the commit message to be used for
the patch, unless the '--message' flag already specified one. The
'patchdescr.tmpl' template file (if available) is used to pre-fill the
editor."""

args = []
options = (argparse.author_options()
           + argparse.message_options(save_template = True)
           + argparse.sign_options())

directory = common.DirectoryHasRepositoryLib()

def func(parser, options, args):
    """Create a new patch."""
    stack = directory.repository.current_stack
    if stack.repository.default_index.conflicts():
        raise common.CmdException(
            'Cannot create a new patch -- resolve conflicts first')

    # Choose a name for the new patch -- or None, which means make one
    # up later when we've gotten hold of the commit message.
    if len(args) == 0:
        name = None
    elif len(args) == 1:
Exemplo n.º 6
0
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 = ['applied_patches', 'unapplied_patches', '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 = DirectoryHasRepository()


def func(parser, options, args):
Exemplo n.º 7
0
created on top of the currently applied patches, and is made the new
top of the stack. Uncommitted changes in the work tree are not
included in the patch -- that is handled by linkstg:refresh[].

The given name must be unique in the stack, and may only contain
alphanumeric characters, dashes and underscores. If no name is given,
one is generated from the first line of the patch's commit message.

An editor will be launched to edit the commit message to be used for
the patch, unless the '--message' flag already specified one. The
'patchdescr.tmpl' template file (if available) is used to pre-fill the
editor."""

args = []
options = (argparse.author_options() + argparse.message_options(
    save_template=True) + argparse.sign_options())

directory = common.DirectoryHasRepositoryLib()


def func(parser, options, args):
    """Create a new patch."""
    stack = directory.repository.current_stack
    if stack.repository.default_index.conflicts():
        raise common.CmdException(
            'Cannot create a new patch -- resolve conflicts first')

    # Choose a name for the new patch -- or None, which means make one
    # up later when we've gotten hold of the commit message.
    if len(args) == 0:
        name = None
Exemplo n.º 8
0
args = [argparse.all_branches]
options = [
    opt('-b',
        '--branch',
        args=[argparse.stg_branches],
        short='Use BRANCH instead of the default branch'),
    opt('-l',
        '--last',
        action='store_true',
        short='Show the last published patch'),
    opt('-u',
        '--unpublished',
        action='store_true',
        short='Show applied patches that have not been published')
] + (argparse.author_options() +
     argparse.message_options(save_template=False) + argparse.sign_options())

directory = common.DirectoryHasRepositoryLib()


def __create_commit(repository, tree, parents, options, message=''):
    """Return a new Commit object."""
    cd = git.CommitData(tree=tree,
                        parents=parents,
                        message=message,
                        author=git.Person.author(),
                        committer=git.Person.committer())
    cd = common.update_commit_data(cd, options)

    return repository.commit(cd)
Exemplo n.º 9
0
        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')
    ] + (argparse.message_options(save_template = False) +
         argparse.sign_options() + argparse.author_options())

directory = common.DirectoryHasRepositoryLib()

def get_patch(stack, given_patch):
    """Get the name of the patch we are to refresh."""
    if given_patch:
        patch_name = given_patch
        if not stack.patches.exists(patch_name):
            raise common.CmdException('%s: no such patch' % patch_name)
        return patch_name
    else:
        if not stack.patchorder.applied:
            raise common.CmdException(
                'Cannot refresh top patch, because no patches are applied')
        return stack.patchorder.applied[-1]
Exemplo n.º 10
0
Command-line options can be used to modify specific information
without invoking the editor. (With the --edit option, the editor is
invoked even if such command-line options are given.)

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."""

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.author_options() + argparse.diff_opts_option())

directory = common.DirectoryHasRepositoryLib()

def func(parser, options, args):
    """Edit the given patch or the current one.
    """
    stack = directory.repository.current_stack

    if len(args) == 0:
        if not stack.patchorder.applied:
            raise common.CmdException(
                'Cannot edit top patch, because no patches are applied')
        patchname = stack.patchorder.applied[-1]