From a5920051ee4326489c4b43e85d93f71d4c4ce34a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Karl=20Hasselstr=C3=B6m?= Date: Tue, 20 May 2008 23:33:25 +0200 Subject: [PATCH] Add property with a list of all patch names MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This simplifies the code in a number of places. Signed-off-by: Karl Hasselström --- stgit/commands/coalesce.py | 3 +-- stgit/commands/commit.py | 6 ++---- stgit/commands/delete.py | 4 +--- stgit/commands/uncommit.py | 2 +- stgit/lib/stack.py | 1 + 5 files changed, 6 insertions(+), 10 deletions(-) diff --git a/stgit/commands/coalesce.py b/stgit/commands/coalesce.py index 07a9753..412968a 100644 --- a/stgit/commands/coalesce.py +++ b/stgit/commands/coalesce.py @@ -115,8 +115,7 @@ def _coalesce(stack, iw, name, msg, save_template, patches): def func(parser, options, args): stack = directory.repository.current_stack - patches = common.parse_patches(args, (list(stack.patchorder.applied) - + list(stack.patchorder.unapplied))) + patches = common.parse_patches(args, list(stack.patchorder.all)) if len(patches) < 2: raise common.CmdException('Need at least two patches') return _coalesce(stack, stack.repository.default_iw, options.name, diff --git a/stgit/commands/commit.py b/stgit/commands/commit.py index e95b67f..cc2f13a 100644 --- a/stgit/commands/commit.py +++ b/stgit/commands/commit.py @@ -45,13 +45,11 @@ options = [make_option('-n', '--number', type = 'int', def func(parser, options, args): """Commit a number of patches.""" stack = directory.repository.current_stack - args = common.parse_patches(args, (list(stack.patchorder.applied) - + list(stack.patchorder.unapplied))) + args = common.parse_patches(args, list(stack.patchorder.all)) if len([x for x in [args, options.number != None, options.all] if x]) > 1: parser.error('too many options') if args: - patches = [pn for pn in (stack.patchorder.applied - + stack.patchorder.unapplied) if pn in args] + patches = [pn for pn in stack.patchorder.all if pn in args] bad = set(args) - set(patches) if bad: raise common.CmdException('Bad patch names: %s' diff --git a/stgit/commands/delete.py b/stgit/commands/delete.py index 13a23c6..de46085 100644 --- a/stgit/commands/delete.py +++ b/stgit/commands/delete.py @@ -41,9 +41,7 @@ def func(parser, options, args): stack = directory.repository.current_stack iw = stack.repository.default_iw if args: - patches = set(common.parse_patches( - args, (list(stack.patchorder.applied) - + list(stack.patchorder.unapplied)))) + patches = set(common.parse_patches(args, list(stack.patchorder.all))) else: parser.error('No patches specified') def allow_conflicts(trans): diff --git a/stgit/commands/uncommit.py b/stgit/commands/uncommit.py index 05e49e0..eb39fcc 100644 --- a/stgit/commands/uncommit.py +++ b/stgit/commands/uncommit.py @@ -116,7 +116,7 @@ def func(parser, options, args): next_commit = get_parent(next_commit) patch_nr = len(commits) - taken_names = set(stack.patchorder.applied + stack.patchorder.unapplied) + taken_names = set(stack.patchorder.all) if patchnames: for pn in patchnames: if pn in taken_names: diff --git a/stgit/lib/stack.py b/stgit/lib/stack.py index 3de3776..af1c994 100644 --- a/stgit/lib/stack.py +++ b/stgit/lib/stack.py @@ -96,6 +96,7 @@ class PatchOrder(object): lambda self, val: self.__set_list('applied', val)) unapplied = property(lambda self: self.__get_list('unapplied'), lambda self, val: self.__set_list('unapplied', val)) + all = property(lambda self: self.applied + self.unapplied) class Patches(object): """Creates Patch objects.""" -- 2.11.0