Beispiel #1
0
"""

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()
Beispiel #2
0
"""

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]
Beispiel #3
0
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',
Beispiel #4
0
several stack modifications).

The '--unpublished' option can be used to check if there are applied patches
that have not been published to the public branch. This is done by trying to
revert the patches in the public tree (similar to the 'push --merged'
detection). The '--last' option tries to find the last published patch by
checking the SHA1 of the patch tree agains the public tree. This may fail if
the stack was rebased since the last publish command.

The public branch name can be set via the branch.<branch>.public configuration
variable (defaulting to "<branch>.public").
"""

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())
Beispiel #5
0
  %(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()
Beispiel #6
0
  %(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',
Beispiel #7
0
from stgit.lib import log, transaction

help = 'Undo the last undo operation'
kind = 'stack'
usage = ['']
description = """
If the last command was an undo, reset the patch stack to the state it
had before the undo. Consecutive invocations of "stg redo" will undo
the effects of consecutive invocations of "stg undo".

It is an error to run "stg redo" if the last command was not an
undo."""

args = []
options = [
    opt('-n', '--number', type = 'int', metavar = 'N', default = 1,
        short = 'Undo the last N undos'),
    opt('--hard', action = 'store_true',
        short = 'Discard changes in your index/worktree')]

directory = common.DirectoryHasRepositoryLib()

def func(parser, options, args):
    stack = directory.repository.current_stack
    if options.number < 1:
        raise common.CmdException('Bad number of undos to redo')
    state = log.undo_state(stack, -options.number)
    trans = transaction.StackTransaction(stack, 'redo %d' % options.number,
                                         discard_changes = options.hard,
                                         allow_bad_head = True)
    try:
        log.reset_stack(trans, stack.repository.default_iw, state)
Beispiel #8
0
If no patch is specified on command-line, the current patch gets sunk.
By default patches are sunk to the bottom of the stack, but the '--to'
option allows one to place them under any applied patch.

Sinking internally involves popping all patches (or all patches
including <target patch>), then pushing the patches to sink, and then
(unless '--nopush' is also given) pushing back into place the
formerly-applied patches."""

args = [patch_range('applied_patches', 'unapplied_patches')]
options = [
    opt(
        '-n',
        '--nopush',
        action='store_true',
        short='Do not push the patches back after sinking',
        long="""
        Do not push back on the stack the formerly-applied patches.
        Only the patches to sink are pushed.""",
    ),
    opt(
        '-t',
        '--to',
        metavar='TARGET',
        args=['applied_patches'],
        short='Sink patches below the TARGET patch',
        long="""
        Specify a target patch to place the patches below, instead of
        sinking them to the bottom of the stack.""",
    )
] + keep_option()
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=['commit'],
        short='Uncommit to the specified commit',
    ),
    opt(
        '-x',
        '--exclusive',
        action='store_true',
        short='Exclude the commit specified by the --to option',
    ),
]
Beispiel #10
0
along with this program; if not, see http://www.gnu.org/licenses/.
"""

help = 'Show the applied patches modifying a file'
kind = 'stack'
usage = ['[options] [--] [<files or dirs>]']
description = """
Show the applied patches modifying the given files. Without arguments,
it shows the patches affected by the local tree modifications. The
'--diff' option also lists the patch log and the diff for the given
files."""

args = [argparse.known_files]
options = [
    opt('-d',
        '--diff',
        action='store_true',
        short='Show the diff for the given files'),
    opt('-b',
        '--branch',
        args=[argparse.stg_branches],
        short='Use BRANCH instead of the default branch')
]

directory = DirectoryHasRepository(log=False)
crt_series = None

diff_tmpl = \
          '-------------------------------------------------------------------------------\n' \
          '%s\n' \
          '-------------------------------------------------------------------------------\n' \
          '%s' \
Beispiel #11
0
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 = [patch_range('applied_patches', 'unapplied_patches')]
options = [
    opt(
        '-a',
        '--all',
        action='store_true',
        short='Synchronise all the applied patches',
    ),
    opt(
        '-B',
        '--ref-branch',
        args=['stg_branches'],
        short='Syncronise patches with BRANCH',
    ),
    opt(
        '-s',
        '--series',
        args=['files'],
        short='Syncronise patches with SERIES',
    ),
]
Beispiel #12
0
"""

help = 'Delete patches'
kind = 'patch'
usage = ['[options] [--] <patch1> [<patch2>] [<patch3>..<patch4>]']
description = """
Delete the patches passed as arguments."""

args = [patch_range('applied_patches', 'unapplied_patches')]
options = [
    opt(
        '--spill',
        action='store_true',
        short='Spill patch contents to worktree and index',
        long="""
        Delete the patches, but do not touch the index and worktree.
        This only works with applied patches at the top of the stack.
        The effect is to "spill" the patch contents into the index and
        worktree. This can be useful e.g. if you want to split a patch
        into several smaller pieces.""",
    ),
    opt(
        '-b',
        '--branch',
        args=['stg_branches'],
        short='Use BRANCH instead of the default branch',
    ),
    opt('-t', '--top', action='store_true', short='Delete top patch'),
]

directory = DirectoryHasRepository()
Beispiel #13
0
  %(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 = [patch_range('applied_patches', 'unapplied_patches', 'hidden_patches')]
options = [
    opt(
        '-d',
        '--dir',
        args=['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',
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.

Given the --clear option, the log history will be deleted.
This may be useful if the tree view has become too cluttered
to be useful."""

args = [patch_range('applied_patches', 'unapplied_patches', 'hidden_patches')]
options = [
    opt(
        '-b',
        '--branch',
        args=['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(
Beispiel #15
0
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()
Beispiel #16
0
along with this program; if not, see http://www.gnu.org/licenses/.
"""

help = 'Delete the empty patches in the series'
kind = 'stack'
usage = ['']
description = """
Delete the empty patches in the whole series or only those applied or
unapplied. A patch is considered empty if the two commit objects
representing its boundaries refer to the same tree object."""

args = []
options = [
    opt(
        '-a',
        '--applied',
        action='store_true',
        short='Delete the empty applied patches',
    ),
    opt(
        '-u',
        '--unapplied',
        action='store_true',
        short='Delete the empty unapplied patches',
    ),
]

directory = common.DirectoryHasRepositoryLib()


def _clean(stack, clean_applied, clean_unapplied):
    trans = transaction.StackTransaction(stack, 'clean', allow_conflicts=True)
Beispiel #17
0
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)
Beispiel #18
0
  %(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 = [patch_range('applied_patches', 'unapplied_patches', 'hidden_patches')]
options = [
    opt(
        '-a',
        '--all',
        action='store_true',
        short='E-mail all the applied patches',
    ),
    opt(
        '--to',
        action='append',
        args=['mail_aliases'],
        short='Add TO to the To: list',
    ),
    opt(
        '--cc',
        action='append',
        args=['mail_aliases'],
        short='Add CC to the Cc: list',
    ),
    opt(
Beispiel #19
0
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')
Beispiel #20
0
mail format, the Subject, From and Date headers being used for
generating the patch information. The command can also read series and
mbox files.

If a patch does not apply cleanly, the failed diff is written to the
.stgit-failed.patch file and an empty StGit patch is added to the
stack.

The patch description has to be separated from the data with a '---'
line."""

args = ['files']
options = [
    opt(
        '-m',
        '--mail',
        action='store_true',
        short='Import the patch from a standard e-mail file',
    ),
    opt(
        '-M',
        '--mbox',
        action='store_true',
        short='Import a series of patches from an mbox file',
    ),
    opt(
        '-s',
        '--series',
        action='store_true',
        short='Import a series of patches',
        long="Import a series of patches from a series file or a tar archive.",
    ),
Beispiel #21
0
help = 'Pop one or more patches from the stack'
kind = 'stack'
usage = ['[options] [--] [<patch1>] [<patch2>] [<patch3>..<patch4>]']
description = """
Pop the topmost patch or a range of patches from the stack. The
command fails if there are conflicts or local changes (and --keep was
not specified).

A series of pop and push operations are performed so that only the
patches passed on the command line are popped from the stack. Some of
the push operations may fail because of conflicts ("stg undo" would
revert the last push operation)."""

args = [argparse.patch_range(argparse.applied_patches)]
options = [
    opt('-a', '--all', action = 'store_true',
        short = 'Pop all the applied patches'),
    opt('-s', '--spill', action = 'store_true',
        short = 'Pop a patch, keeping its modifications in the tree'),
    opt('-n', '--number', type = 'int',
        short = 'Pop the specified number of patches', long = '''
        Pop the specified number of patches.

        With a negative number, pop all but that many patches.'''),
    ] + argparse.keep_option()

directory = common.DirectoryHasRepositoryLib()

def func(parser, options, args):
    """Pop the given patches or the topmost one from the stack."""
    stack = directory.repository.current_stack
    iw = stack.repository.default_iw
Beispiel #22
0
description = """
Push one or more patches (defaulting to the first unapplied one) onto
the stack. The 'push' operation allows patch reordering by commuting
them with the three-way merge algorithm. If there are conflicts while
pushing a patch, those conflicts are written to the work tree, and the
command halts. Conflicts raised during the push operation have to be
fixed and the 'git add --update' command run (alternatively, you may
undo the conflicting push with 'stg undo').

The command also notifies when the patch becomes empty (fully merged
upstream) or is modified (three-way merged) by the 'push' operation."""

args = [argparse.patch_range(argparse.unapplied_patches)]
options = [
    opt('-a',
        '--all',
        action='store_true',
        short='Push all the unapplied patches'),
    opt('-n',
        '--number',
        type='int',
        short='Push the specified number of patches',
        long='''
        Push the specified number of patches.

        With a negative number, push all but that many patches.'''),
    opt('--reverse',
        action='store_true',
        short='Push the patches in reverse order'),
    opt('--set-tree',
        action='store_true',
        short='Push the patch with the original tree',
Beispiel #23
0
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']
Beispiel #24
0
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)
crt_series = None


def func(parser, options, args):
Beispiel #25
0
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:
Beispiel #26
0
opposite of 'stg uncommit'. Use this command if you no longer want to
manage a patch with StGIT.

By default, the bottommost patch is committed. If patch names are
given, the stack is rearranged so that those patches are at the
bottom, and then they are committed.

The -n/--number option specifies the number of applied patches to
commit (counting from the bottom of the stack). If -a/--all is given,
all applied patches are committed."""

args = [patch_range('applied_patches', 'unapplied_patches')]
options = [
    opt(
        '-n',
        '--number',
        type='int',
        short='Commit the specified number of patches',
    ),
    opt('-a', '--all', action='store_true',
        short='Commit all applied patches'),
]

directory = DirectoryHasRepository()


def func(parser, options, args):
    """Commit a number of patches."""
    stack = directory.repository.current_stack
    args = parse_patches(args, list(stack.patchorder.all_visible))
    exclusive = [args, options.number is not None, options.all]
    if sum(map(bool, exclusive)) > 1:
Beispiel #27
0
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)
Beispiel #28
0
kind = 'stack'
usage = ['[options] [--] [<state> [<patchnames>]]']
description = """
Reset the patch stack to an earlier state. If no state is specified,
reset only the changes in the worktree.

The state is specified with a commit id from a stack log; "stg log" lets
you view this log, and "stg reset" lets you reset to any state you see
in the log. If one or more patch names are given, reset only those
patches, and leave the rest alone."""

args = [patch_range('applied_patches', 'unapplied_patches', 'hidden_patches')]
options = [
    opt(
        '--hard',
        action='store_true',
        short='Discard changes in your index/worktree',
    ),
]

directory = common.DirectoryHasRepositoryLib()


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:
Beispiel #29
0
"""

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:
Beispiel #30
0
  2. Push the given patches in the order they were given on the
     command line.

  3. Squash the given patches into one big patch.

  4. Allow the user to edit the commit message of the new patch
     interactively.

  5. Push the other patches that were popped in step (1).

Conflicts can occur whenever we push a patch; that is, in step (2) and
(5). If there are conflicts, the command will stop so that you can
resolve them."""

args = [patch_range('applied_patches', 'unapplied_patches')]
options = ([opt('-n', '--name', short='Name of squashed patch')] +
           argparse.message_options(save_template=True) +
           argparse.hook_options())

directory = DirectoryHasRepository()


class SaveTemplateDone(Exception):
    pass


def _append_comment(message, comment):
    return '\n'.join([
        message,
        '',
        '---',
Beispiel #31
0
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
Beispiel #32
0
mail format, the Subject, From and Date headers being used for
generating the patch information. The command can also read series and
mbox files.

If a patch does not apply cleanly, the failed diff is written to the
.stgit-failed.patch file and an empty StGIT patch is added to the
stack.

The patch description has to be separated from the data with a '---'
line."""

args = ['files']
options = [
    opt(
        '-m',
        '--mail',
        action='store_true',
        short='Import the patch from a standard e-mail file',
    ),
    opt(
        '-M',
        '--mbox',
        action='store_true',
        short='Import a series of patches from an mbox file',
    ),
    opt(
        '-s',
        '--series',
        action='store_true',
        short='Import a series of patches',
        long="""
        Import a series of patches from a series file or a tar archive.""",
Beispiel #33
0
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.
    """
Beispiel #34
0
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 = ['known_files', 'dirty_files']
options = [
    opt(
        '-r',
        '--range',
        metavar='rev1[..[rev2]]',
        dest='revs',
        args=[
            patch_range(
                'applied_patches',
                'unapplied_patches',
                'hidden_patches',
            )
        ],
        short='Show the diff between revisions',
    ),
    opt(
        '-s',
        '--stat',
        action='store_true',
        short='Show the stat instead of the diff',
    ),
] + diff_opts_option()

directory = DirectoryHasRepository()
Beispiel #35
0
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:
Beispiel #36
0
"""

help = 'Rename a patch'
kind = 'patch'
usage = ['[options] [--] [oldpatch] <newpatch>']
description = """
Rename <oldpatch> into <newpatch> in a series. If <oldpatch> is not
given, the top-most patch will be renamed."""

args = [
    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')
]

directory = DirectoryHasRepository(log=True)
crt_series = None


def func(parser, options, args):
    """Rename a patch in the series
    """
    crt = crt_series.get_current()

    if len(args) == 2:
        old, new = args
    elif len(args) == 1:
Beispiel #37
0
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.
    """
Beispiel #38
0
The '--unpublished' option can be used to check if there are applied patches
that have not been published to the public branch. This is done by trying to
revert the patches in the public tree (similar to the 'push --merged'
detection). The '--last' option tries to find the last published patch by
checking the SHA1 of the patch tree agains the public tree. This may fail if
the stack was rebased since the last publish command.

The public branch name can be set via the branch.<branch>.public configuration
variable (defaulting to "<branch>.public").
"""

args = ['all_branches']
options = [
    opt(
        '-b',
        '--branch',
        args=['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',
    ),
    opt(
Beispiel #39
0
"""

help = 'Push patches to the top, even if applied'
kind = 'stack'
usage = ['[--] <patches>',
         '-s <series>']
description = """
Push a patch or a range of patches to the top even if applied. The
necessary pop and push operations will be performed to accomplish
this. The '--series' option can be used to rearrange the (top) patches
as specified by the given series file (or the standard input)."""

args = [argparse.patch_range(argparse.applied_patches,
                             argparse.unapplied_patches)]
options = [
    opt('-s', '--series', metavar = 'FILE',
        short = 'Rearrange according to the series FILE')
    ] + argparse.keep_option()

directory = common.DirectoryHasRepositoryLib()

def func(parser, options, args):
    """Reorder patches to make the named patch the topmost one.
    """
    if options.series and args:
        parser.error('<patches> cannot be used with --series')
    elif not options.series and not args:
        parser.error('incorrect number of arguments')

    stack = directory.repository.current_stack

    if options.series:
Beispiel #40
0
the rebase by executing the following sequence:

        $ git add --update
        $ stg refresh
        $ stg goto top-patch

Or if you want to skip that patch:

        $ stg undo --hard
        $ stg push next-patch..top-patch"""

args = ['commit']
options = [
    opt(
        '-i',
        '--interactive',
        action='store_true',
        short='Open an interactive editor to manipulate patches',
    ),
    opt(
        '-n',
        '--nopush',
        action='store_true',
        short='Do not push the patches back after rebasing',
    ),
    opt(
        '-m',
        '--merged',
        action='store_true',
        short='Check for patches merged upstream',
    ),
]
Beispiel #41
0
usage = ['[options] [--] [<patch1>] [<patch2>] [<patch3>..<patch4>]']
description = """
Push one or more patches (defaulting to the first unapplied one) onto
the stack. The 'push' operation allows patch reordering by commuting
them with the three-way merge algorithm. If there are conflicts while
pushing a patch, those conflicts are written to the work tree, and the
command halts. Conflicts raised during the push operation have to be
fixed and the 'git add --update' command run (alternatively, you may
undo the conflicting push with 'stg undo').

The command also notifies when the patch becomes empty (fully merged
upstream) or is modified (three-way merged) by the 'push' operation."""

args = [argparse.patch_range(argparse.unapplied_patches)]
options = [
    opt('-a', '--all', action = 'store_true',
        short = 'Push all the unapplied patches'),
    opt('-n', '--number', type = 'int',
        short = 'Push the specified number of patches', long = '''
        Push the specified number of patches.

        With a negative number, push all but that many patches.'''),
    opt('--reverse', action = 'store_true',
        short = 'Push the patches in reverse order'),
    opt('--set-tree', action = 'store_true',
        short = 'Push the patch with the original tree', long = """
        Push the patches, but don't perform a merge. Instead, the
        resulting tree will be identical to the tree that the patch
        previously created.

        This can be useful when splitting a patch by first popping the
        patch and creating a new patch with some of the
Beispiel #42
0
within a git repository.

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

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

args = ['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
Beispiel #43
0
     command line.

  3. Squash the given patches into one big patch.

  4. Allow the user to edit the commit message of the new patch
     interactively.

  5. Push the other patches that were popped in step (1).

Conflicts can occur whenever we push a patch; that is, in step (2) and
(5). If there are conflicts, the command will stop so that you can
resolve them."""

args = [argparse.patch_range(argparse.applied_patches,
                             argparse.unapplied_patches)]
options = [opt('-n', '--name', short = 'Name of squashed patch')
           ] + argparse.message_options(save_template = True)

directory = common.DirectoryHasRepositoryLib()

class SaveTemplateDone(Exception):
    pass

def _squash_patches(trans, patches, msg, save_template):
    cd = trans.patches[patches[0]].data
    cd = git.CommitData(tree = cd.tree, parents = cd.parents)
    for pn in patches[1:]:
        c = trans.patches[pn]
        tree = trans.stack.repository.simple_merge(
            base = c.data.parent.data.tree,
            ours = cd.tree, theirs = c.data.tree)
Beispiel #44
0
help = 'Push patches to the top, even if applied'
kind = 'stack'
usage = ['[--] <patches>', '-s <series>']
description = """
Float a patch or range of patches to be the top-most applied patches.
The patches to be floated may currently be either applied or unapplied.
The necessary pop and push operations will be performed to float the
named patches.  Patches not specified will remain applied or unapplied
as they were prior to the float operation."""

args = [patch_range('applied_patches', 'unapplied_patches')]
options = [
    opt(
        '-s',
        '--series',
        metavar='FILE',
        short='Rearrange according to the series FILE',
    )
] + keep_option()

directory = DirectoryHasRepository()


def func(parser, options, args):
    """Reorder patches to make the named patch the topmost one.
    """
    if options.series and args:
        parser.error('<patches> cannot be used with --series')
    elif not options.series and not args:
        parser.error('incorrect number of arguments')
Beispiel #45
0
can be overridden with the '--name' option. The patch can either be a
normal file with the description at the top or it can have standard
mail format, the Subject, From and Date headers being used for
generating the patch information. The command can also read series and
mbox files.

If a patch does not apply cleanly, the failed diff is written to the
.stgit-failed.patch file and an empty StGIT patch is added to the
stack.

The patch description has to be separated from the data with a '---'
line."""

args = [argparse.files]
options = [
    opt('-m', '--mail', action = 'store_true',
        short = 'Import the patch from a standard e-mail file'),
    opt('-M', '--mbox', action = 'store_true',
        short = 'Import a series of patches from an mbox file'),
    opt('-s', '--series', action = 'store_true',
        short = 'Import a series of patches', long = """
        Import a series of patches from a series file or a tar archive."""),
    opt('-u', '--url', action = 'store_true',
        short = 'Import a patch from a URL'),
    opt('-n', '--name',
        short = 'Use NAME as the patch name'),
    opt('-p', '--strip', type = 'int', metavar = 'N',
        short = 'Remove N leading slashes from diff paths (default 1)'),
    opt('-t', '--stripname', action = 'store_true',
        short = 'Strip numbering and extension from patch name'),
    opt('-i', '--ignore', action = 'store_true',
        short = 'Ignore the applied patches in the series'),
Beispiel #46
0
You should have received a copy of the GNU General Public License
along with this program; if not, see http://www.gnu.org/licenses/.
"""

help = 'Print the name of the next patch'
kind = 'stack'
usage = ['']
description = """
Print the name of the next patch."""

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

directory = DirectoryHasRepository()


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

    stack = directory.repository.get_stack(options.branch)
    unapplied = stack.patchorder.unapplied
Beispiel #47
0
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
Beispiel #48
0
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',
Beispiel #49
0
kind = 'stack'
usage = ['[options] [--] [<state> [<patchnames>]]']
description = """
Reset the patch stack to an earlier state. If no state is specified,
reset only the changes in the worktree.

The state is specified with a commit id from a stack log; "stg log" lets
you view this log, and "stg reset" lets you reset to any state you see
in the log. If one or more patch names are given, reset only those
patches, and leave the rest alone."""

args = [argparse.patch_range(argparse.applied_patches,
                             argparse.unapplied_patches,
                             argparse.hidden_patches)]
options = [
    opt('--hard', action = 'store_true',
        short = 'Discard changes in your index/worktree')]

directory = common.DirectoryHasRepositoryLib()

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 common.CmdException('Wrong options or number of arguments')
Beispiel #50
0
usage = [
    '[options] [--] ([<patch1>] [<patch2>] [<patch3>..<patch4>])|<commit>'
]
description = """
Import one or more patches from a different branch or a commit object
into the current series. By default, the name of the imported patch is
used as the name of the current patch. It can be overridden with the
'--name' option. A commit object can be reverted with the '--revert'
option. The log and author information are those of the commit
object."""

args = [patch_range('applied_patches', 'unapplied_patches', 'hidden_patches')]
options = [
    opt(
        '-n',
        '--name',
        short='Use NAME as the patch name',
    ),
    opt(
        '-B',
        '--ref-branch',
        args=['stg_branches'],
        short='Pick patches from BRANCH',
    ),
    opt(
        '-r',
        '--revert',
        action='store_true',
        short='Revert the given commit object',
    ),
    opt(
Beispiel #51
0
help = 'Import a patch from a different branch or a commit object'
kind = 'patch'
usage = ['[options] [--] ([<patch1>] [<patch2>] [<patch3>..<patch4>])|<commit>']
description = """
Import one or more patches from a different branch or a commit object
into the current series. By default, the name of the imported patch is
used as the name of the current patch. It can be overridden with the
'--name' option. A commit object can be reverted with the '--revert'
option. The log and author information are those of the commit
object."""

args = [argparse.patch_range(argparse.applied_patches,
                             argparse.unapplied_patches,
                             argparse.hidden_patches)]
options = [
    opt('-n', '--name',
        short = 'Use NAME as the patch name'),
    opt('-B', '--ref-branch', args = [argparse.stg_branches],
        short = 'Pick patches from BRANCH'),
    opt('-r', '--revert', action = 'store_true',
        short = 'Revert the given commit object'),
    opt('-p', '--parent', metavar = 'COMMITID', args = [argparse.commit],
        short = 'Use COMMITID as parent'),
    opt('-x', '--expose', action = 'store_true',
        short = 'Append the imported commit id to the patch log'),
    opt('--fold', action = 'store_true',
        short = 'Fold the commit object into the current patch'),
    opt('--update', action = 'store_true',
        short = 'Like fold but only update the current patch files'),
    opt('-f', '--file', action = 'append',
        short = 'Only fold the given file (can be used multiple times)'),
    opt('--unapplied', action = 'store_true',
Beispiel #52
0
help = 'Undo the last undo operation'
kind = 'stack'
usage = ['']
description = """
If the last command was an undo, reset the patch stack to the state it
had before the undo. Consecutive invocations of "stg redo" will undo
the effects of consecutive invocations of "stg undo".

It is an error to run "stg redo" if the last command was not an
undo."""

args = []
options = [
    opt('-n',
        '--number',
        type='int',
        metavar='N',
        default=1,
        short='Undo the last N undos'),
    opt('--hard',
        action='store_true',
        short='Discard changes in your index/worktree')
]

directory = common.DirectoryHasRepositoryLib()


def func(parser, options, args):
    stack = directory.repository.current_stack
    if options.number < 1:
        raise common.CmdException('Bad number of undos to redo')
    state = log.undo_state(stack, -options.number)
Beispiel #53
0
easily committed or pushed.

If no patch is specified on command-line, the current patch gets sunk.
By default patches are sunk to the bottom of the stack, but the '--to'
option allows one to place them under any applied patch.

Sinking internally involves popping all patches (or all patches
including <target patch>), then pushing the patches to sink, and then
(unless '--nopush' is also given) pushing back into place the
formerly-applied patches."""

args = [argparse.patch_range(argparse.applied_patches,
                             argparse.unapplied_patches)]
options = [
    opt('-n', '--nopush', action = 'store_true',
        short = 'Do not push the patches back after sinking', long = """
        Do not push back on the stack the formerly-applied patches.
        Only the patches to sink are pushed."""),
    opt('-t', '--to', metavar = 'TARGET', args = [argparse.applied_patches],
        short = 'Sink patches below the TARGET patch', long = """
        Specify a target patch to place the patches below, instead of
        sinking them to the bottom of the stack.""")
    ] + argparse.keep_option()

directory = common.DirectoryHasRepositoryLib()

def func(parser, options, args):
    """Sink patches down the stack.
    """
    stack = directory.repository.current_stack

    if options.to and not options.to in stack.patchorder.applied:
Beispiel #54
0
help = 'Integrate a GNU diff patch into the current patch'
kind = 'patch'
usage = ['[options] [--] [<file>]']
description = """
Apply the given GNU diff file (or the standard input) onto the top of
the current patch. With the '--threeway' option, the patch is applied
onto the bottom of the current patch and a three-way merge is
performed with the current top. With the --base option, the patch is
applied onto the specified base and a three-way merged is performed
with the current top."""

args = ['files']
options = [
    opt(
        '-t',
        '--threeway',
        action='store_true',
        short='Perform a three-way merge with the current patch',
    ),
    opt(
        '-b',
        '--base',
        args=['commit'],
        short='Use BASE instead of HEAD when applying the patch',
    ),
    opt(
        '-p',
        '--strip',
        type='int',
        metavar='N',
        short='Remove N leading slashes from diff paths (default 1)',
    ),
Beispiel #55
0
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(
            "-p",
            "--patch",
            args=[argparse.other_applied_patches, argparse.unapplied_patches],
            short="Refresh (applied) PATCH instead of the top patch",
        ),
Beispiel #56
0
the rebase by executing the following sequence:

        $ git add --update
        $ stg refresh
        $ stg goto top-patch

Or if you want to skip that patch:

        $ stg undo --hard
        $ stg push next-patch..top-patch"""

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

directory = DirectoryGotoTopLevel()


def func(parser, options, args):
    """Rebase the current stack
Beispiel #57
0
help = 'Pop one or more patches from the stack'
kind = 'stack'
usage = ['[options] [<patch1>] [<patch2>] [<patch3>..<patch4>]']
description = """
Pop the topmost patch or a range of patches from the stack. The
command fails if there are conflicts or local changes (and --keep was
not specified).

A series of pop and push operations are performed so that only the
patches passed on the command line are popped from the stack. Some of
the push operations may fail because of conflicts ("stg undo" would
revert the last push operation)."""

args = [argparse.patch_range(argparse.applied_patches)]
options = [
    opt('-a', '--all', action = 'store_true',
        short = 'Pop all the applied patches'),
    opt('-n', '--number', type = 'int',
        short = 'Pop the specified number of patches', long = '''
        Pop the specified number of patches.

        With a negative number, pop all but that many patches.'''),
    ] + argparse.keep_option()

directory = common.DirectoryHasRepositoryLib()

def func(parser, options, args):
    """Pop the given patches or the topmost one from the stack."""
    stack = directory.repository.current_stack
    iw = stack.repository.default_iw
    clean_iw = (not options.keep and iw) or None
    trans = transaction.StackTransaction(stack, 'pop',
Beispiel #58
0
You should have received a copy of the GNU General Public License
along with this program; if not, see http://www.gnu.org/licenses/.
"""

help = 'Show the applied patches modifying a file'
kind = 'stack'
usage = ['[options] [--] [<files or dirs>]']
description = """
Show the applied patches modifying the given files. Without arguments,
it shows the patches affected by the local tree modifications. The
'--diff' option also lists the patch log and the diff for the given
files."""

args = [argparse.known_files]
options = [
    opt('-d', '--diff', action = 'store_true',
        short = 'Show the diff for the given files'),
    opt('-b', '--branch', args = [argparse.stg_branches],
        short = 'Use BRANCH instead of the default branch')]

directory = DirectoryHasRepository(log=False)
crt_series = None

diff_tmpl = \
          '-------------------------------------------------------------------------------\n' \
          '%s\n' \
          '-------------------------------------------------------------------------------\n' \
          '%s' \
          '---\n\n' \
          '%s'

def func(parser, options, args):
Beispiel #59
0
from stgit.lib import transaction
from stgit import argparse

help = 'Delete patches'
kind = 'patch'
usage = ['[options] [--] <patch1> [<patch2>] [<patch3>..<patch4>]']
description = """
Delete the patches passed as arguments."""

args = [argparse.patch_range(argparse.applied_patches,
                             argparse.unapplied_patches)]
options = [
    opt('--spill', action = 'store_true',
        short = 'Spill patch contents to worktree and index', long = """
        Delete the patches, but do not touch the index and worktree.
        This only works with applied patches at the top of the stack.
        The effect is to "spill" the patch contents into the index and
        worktree. This can be useful e.g. if you want to split a patch
        into several smaller pieces."""),
    opt('-b', '--branch', args = [argparse.stg_branches],
        short = 'Use BRANCH instead of the default branch'),
    opt('-t', '--top', action = 'store_true',
        short = 'Delete top patch'),]

directory = common.DirectoryHasRepositoryLib()

def func(parser, options, args):
    """Delete one or more patches."""
    stack = directory.repository.get_stack(options.branch)
    if options.branch:
        iw = None # can't use index/workdir to manipulate another branch
Beispiel #60
0
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):