Forgot to attach everything in the last mail.
On Fri, Apr 4, 2014 at 10:21 PM, Erik Carstensen <[email protected]>wrote: > BTW, I noticed that stgit tends to use space around the = in function > keyword arguments. PEP8 says there should be no space there. Is the > discrepancy intentional? > > On Fri, Apr 4, 2014 at 4:06 AM, Karl Wiberg <[email protected]> wrote: > > On Thu, Apr 3, 2014 at 6:54 AM, Erik Carstensen <[email protected]> >> wrote: >> >> > test_expect_success \ >> > 'No patch' \ >> > '! stg move --from foo' >> >> * It's possible to write tests using far fewer backslashes. See >> e.g. t/t3300-edit.sh. >> > > Fixed > > >> * Use general_error, command_error, or conflict from test-lib.sh >> instead of !. > > > Thanks! I also introduced a new function "expect_output". It makes the > test more readable, and gives you a hint upon failure. > > * So moving a patch to the same branch will pop it if necessary, and >> give it a new autogenerated name? Wouldn't it make more sense to >> just complain and do nothing? >> > > I was just checking that it doesn't do anything really bad; I thought it > was easier not to care much about it. But considering your remark on -f > below, it's easier to forbid it. Done now. > > > usage = ['DEST_BRANCH <patch1> [<patch2>] [<patch3>..<patch4>]'] >> > description = """ >> > Delete the given patches from the current branch, and add them >> unapplied to >> > DEST_BRANCH.""" >> > > Fixed > > >> > def find_unique_name(oldname, blacklist): >> > # TODO: is this the right place? >> >> No, you can delete it because you never call it. But if you did want >> it (and I actually think this scheme makes sense), then perhaps near >> make_patch_name in stgit/utils.py. >> > > I removed it. Easier to use the standard scheme. > > >> > if options.src: >> >> > iw = None # can't use index/workdir to manipulate another branch >> > else: >> > iw = src.repository.default_iw >> >> I would have named this src_iw or something, to make it clear which >> branch it belongs to. >> > > Fixed. Also, changed one use of src_iw; we must use None when pushing in > order to prevent the conflict from touching the working tree (perhaps this > is the error in delete as well?) > > > > out.info('Created %s on branch %s' % (", ".join(created), > dest.name)) > > > > This line is often going to get very long > > Fixed, along with silencing delete (also had to fix a bug there, see > patch). It now outputs: > Successfully moved patches: > master:a -> topic:a-0 > master:foo -> topic:foo > > which brings me to a wild class of ideas on argument syntax: We could > allow some colon-based notation, yielding a syntax familiar from > cross-device mv on systems such as Amiga: > stg move df0:foo df1: > to move patch foo from branch df0 to branch df1; > stg move df0:foo df1:bar > to also rename the patch to bar; > stg move df0:foo master:bar df1: > to move two patches from different branches to branch df1 > > The latter two cannot be expressed with the current parameter syntax. > However, the new uses are rather exotic, and the new syntax does not > provide a natural way to move a remote patch to the current branch without > naming the current branch. > > >> Also, you don't handle (or test!) the case where -f explicitly >> specifies the current branch. > > > Fixed now (kind of): I test that giving the current branch is equivalent > to omitting it, in the test where I check that source and destination > cannot be the same. >
diff --git a/stgit/lib/transaction.py b/stgit/lib/transaction.py
index 4d7214e..72f9a7f 100644
--- a/stgit/lib/transaction.py
+++ b/stgit/lib/transaction.py
@@ -286,7 +286,8 @@ class StackTransaction(object):
popped = [pn for pn in popped if not p(pn)]
self.unapplied = popped + [pn for pn in self.unapplied if not p(pn)]
self.hidden = [pn for pn in self.hidden if not p(pn)]
- self.__print_popped(popped)
+ if not quiet:
+ self.__print_popped(popped)
for pn in all_patches:
if p(pn):
s = ['', ' (empty)'][self.patches[pn].data.is_nochange()]
t3500-move.sh
Description: Bourne shell script
__copyright__ = """ Copyright (C) 2005, Catalin Marinas <[email protected]> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """ import itertools from stgit.argparse import opt from stgit.commands import common from stgit.lib import transaction from stgit import argparse from stgit import utils from stgit.out import out help = 'Move patches between branches' kind = 'patch' usage = ['<options> <patch1> [<patch2>] [<patch3>..<patch4>]'] description = """ Delete the given patches from one branch, and add them unapplied to another.""" args = [argparse.patch_range(argparse.applied_patches, argparse.unapplied_patches)] options = [ opt('-f', '--from', args=[argparse.stg_branches], dest='src', short='Move from branch BRANCH (default current)'), opt('-t', '--to', args=[argparse.stg_branches], dest='dest', short='Move to branch BRANCH (default current)')] directory = common.DirectoryHasRepositoryLib() def func(parser, options, args): """Move patches between branches.""" src = directory.repository.get_stack(options.src) dest = directory.repository.get_stack(options.dest) if src == dest: parser.error('Cannot move from a branch to itself') current = directory.repository.get_stack(None) if src != current: src_iw = None # can't use index/workdir to manipulate another branch else: src_iw = src.repository.default_iw if not len(args): parser.error('No patch specified') patches = common.parse_patches(args, list(src.patchorder.all), len(src.patchorder.applied)) trans = transaction.StackTransaction(src, 'move') commits = [(n, src.patches.get(n).commit) for n in patches] try: to_push = trans.delete_patches(lambda pn: pn in patches, quiet=True) for pn in to_push: trans.push_patch(pn, None) except transaction.TransactionHalted: out.info('Conflicts, everything rolled back.') return utils.STGIT_CONFLICT result = trans.run(src_iw) # Creating patches directly. Not using a transaction, because # this cannot fail created = [] for (name, commit) in commits: if dest.patches.exists(name): name = utils.make_patch_name( commit.data.message, dest.patches.exists) newpatch = dest.patches.new(name, commit, 'move') created.append(name) dest.patchorder.unapplied = (tuple(created) + dest.patchorder.unapplied) out.info('Successfully moved patches:') for ((oldname, _), newname) in zip(commits, created): out.info(' %s:%-*s -> %s:%-*s' % ( src.name, max(len(n) for (n, _) in commits), oldname, dest.name, max(map(len, created)), newname)) return result
_______________________________________________ stgit-users mailing list [email protected] https://mail.gna.org/listinfo/stgit-users
