git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Karl Hasselström" <kha@treskal.com>
To: Catalin Marinas <catalin.marinas@gmail.com>
Cc: git@vger.kernel.org
Subject: [StGit PATCH 02/10] Add property with a list of all patch names
Date: Mon, 21 Apr 2008 00:10:33 +0200	[thread overview]
Message-ID: <20080420221033.5837.39163.stgit@yoghurt> (raw)
In-Reply-To: <20080420215625.5837.82896.stgit@yoghurt>

This simplifies the code in a number of places.

Signed-off-by: Karl Hasselström <kha@treskal.com>

---

 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 bf40427..9a46097 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 ee95836..ab89590 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 14bf442..872ed77 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 b6765bc..9ab178c 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."""

  parent reply	other threads:[~2008-04-20 22:11 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-20 22:10 [StGit PATCH 00/10] Updated "stg reset" series Karl Hasselström
2008-04-20 22:10 ` [StGit PATCH 01/10] Prevent most commands from running when there are conflicts Karl Hasselström
2008-04-20 22:10 ` Karl Hasselström [this message]
2008-04-20 22:10 ` [StGit PATCH 03/10] Library functions for tree and blob manipulation Karl Hasselström
2008-04-20 22:10 ` [StGit PATCH 04/10] Write to a stack log when stack is modified Karl Hasselström
2008-04-20 22:10 ` [StGit PATCH 05/10] Add utility function for reordering patches Karl Hasselström
2008-04-20 22:10 ` [StGit PATCH 06/10] New command: stg reset Karl Hasselström
2008-04-20 22:11 ` [StGit PATCH 07/10] Log conflicts separately Karl Hasselström
2008-04-20 22:11 ` [StGit PATCH 08/10] Log conflicts separately for all commands Karl Hasselström
2008-04-20 22:11 ` [StGit PATCH 09/10] Add a --hard flag to stg reset Karl Hasselström
2008-04-20 22:11 ` [StGit PATCH 10/10] Don't write a log entry if there were no changes Karl Hasselström

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080420221033.5837.39163.stgit@yoghurt \
    --to=kha@treskal.com \
    --cc=catalin.marinas@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).