I had a look at this. It seemed easy until I discovered that series.push_patch() assumes the series to be the currently checked out one (uses 'git apply' to modify the git branch).
It's easy to implement as long as you require --unapplied, though; see attached patch. (the commented-out test fails. It can be revived once the push_patch() limitation is lifted) On Fri, Mar 21, 2014 at 1:26 PM, Karl Wiberg <[email protected]> wrote: > On Fri, Mar 21, 2014 at 1:15 PM, Catalin Marinas > <[email protected]> wrote: > > A first step would be converting the 'pick' command to stgit.lib, I > > think it gets easier afterwords. > > It's been a while since I looked at the code, but I don't think > that'll help---the required infrastructure should already be in place. > (Not that converting "pick" wouldn't be a good thing to do for other > reasons...) Neither "pick" nor this new command will do anything > significant that "push" doesn't already do. > > -- > Karl Wiberg, [email protected] > subrabbit.wordpress.com > www.treskal.com/kalle >
Add --dest option, to push a patch onto a remote branch. Currently requires --unapplied. From: Erik Carstensen <[email protected]> --- stgit/commands/pick.py | 30 ++++++++++++++++++++---------- t/t3400-pick.sh | 15 +++++++++++++++ 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/stgit/commands/pick.py b/stgit/commands/pick.py index 4c2840b..cef290e 100644 --- a/stgit/commands/pick.py +++ b/stgit/commands/pick.py @@ -52,6 +52,8 @@ options = [ 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('--dest', args = [argparse.stg_branches], metavar='BRANCH', + short = 'Push patch onto BRANCH instead of the current branch'), opt('-f', '--file', action = 'append', short = 'Only fold the given file (can be used multiple times)'), opt('--unapplied', action = 'store_true', @@ -64,12 +66,14 @@ def __pick_commit(commit_id, patchname, options): """ commit = git.Commit(commit_id) + dest = Series(options.dest) if options.dest else crt_series + if options.name: patchname = options.name elif patchname and options.revert: patchname = 'revert-' + patchname if patchname: - patchname = find_patch_name(patchname, crt_series.patch_exists) + patchname = find_patch_name(patchname, dest.patch_exists) if options.parent: parent = git_id(crt_series, options.parent) @@ -126,11 +130,11 @@ def __pick_commit(commit_id, patchname, options): out.start('Importing commit %s' % commit_id) - newpatch = crt_series.new_patch(patchname, message = message, can_edit = False, - unapplied = True, bottom = bottom, top = top, - author_name = author_name, - author_email = author_email, - author_date = author_date) + newpatch = dest.new_patch(patchname, message = message, can_edit = False, + unapplied = True, bottom = bottom, top = top, + author_name = author_name, + author_email = author_email, + author_date = author_date) # in case the patch name was automatically generated patchname = newpatch.get_name() @@ -152,12 +156,12 @@ def __pick_commit(commit_id, patchname, options): else: out.info("No log for %s\n" % patchname) - if not options.unapplied: - modified = crt_series.push_patch(patchname) - else: + if options.unapplied: modified = False + else: + modified = dest.push_patch(patchname) - if crt_series.empty_patch(patchname): + if dest.empty_patch(patchname): out.done('empty patch') elif modified: out.done('modified') @@ -174,6 +178,12 @@ def func(parser, options, args): if options.file and not options.fold: parser.error('--file can only be specified with --fold') + if options.dest and (options.fold or options.update): + parser.error('--dest cannot be combined with --fold or --update') + + if options.dest and not options.unapplied: + parser.error('--dest can only be specified with --unapplied') + if not options.unapplied: check_local_changes() check_conflicts() diff --git a/t/t3400-pick.sh b/t/t3400-pick.sh index 22b348c..76336f4 100755 --- a/t/t3400-pick.sh +++ b/t/t3400-pick.sh @@ -30,6 +30,21 @@ test_expect_success \ test "$(echo $(stg series --unapplied --noprefix))" = "D" ' +# test_expect_success \ +# 'Pick to remote branch' \ +# ' +# stg pick A --dest foo && +# test "$(echo $(stg series -b foo --applied --noprefix))" = "A B C D-foo A-0" +# ' + +test_expect_success \ + 'Pick --unapplied to remote branch' \ + ' + stg pick B --dest foo --unapplied && + test "$(echo $(stg series -b foo --applied --noprefix))" = "A B C D-foo" && + test "$(echo $(stg series -b foo --unapplied --noprefix))" = "B-0" + ' + test_expect_success \ 'Pick local unapplied patch' \ '
_______________________________________________ stgit-users mailing list [email protected] https://mail.gna.org/listinfo/stgit-users
