Allow stack.patchorder.all to return hidden patches
authorCatalin Marinas <catalin.marinas@gmail.com>
Fri, 6 Jun 2008 20:33:42 +0000 (21:33 +0100)
committerCatalin Marinas <catalin.marinas@gmail.com>
Fri, 6 Jun 2008 20:34:38 +0000 (21:34 +0100)
A new property, patchorder.all_visible, was added to return only the
applied + unapplied patches. This is used in the "commit" command to
avoid automatically committing the hidden patches.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
Acked-by: Karl Hasselström <kha@treskal.com>
stgit/commands/commit.py
stgit/lib/stack.py
stgit/lib/stackupgrade.py

index cc2f13a..df7fa67 100644 (file)
@@ -45,14 +45,14 @@ 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.all))
+    args = common.parse_patches(args, list(stack.patchorder.all_visible))
     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.all if pn in args]
+        patches = [pn for pn in stack.patchorder.all_visible if pn in args]
         bad = set(args) - set(patches)
         if bad:
-            raise common.CmdException('Bad patch names: %s'
+            raise common.CmdException('Nonexistent or hidden patch names: %s'
                                       % ', '.join(sorted(bad)))
     elif options.number != None:
         if options.number <= len(stack.patchorder.applied):
index f9e750e..bdd21b1 100644 (file)
@@ -102,8 +102,8 @@ class PatchOrder(object):
                          lambda self, val: self.__set_list('unapplied', val))
     hidden = property(lambda self: self.__get_list('hidden'),
                       lambda self, val: self.__set_list('hidden', val))
-    # don't return the hidden patches, these have to be returned explicitly
-    all = property(lambda self: self.applied + self.unapplied)
+    all = property(lambda self: self.applied + self.unapplied + self.hidden)
+    all_visible = property(lambda self: self.applied + self.unapplied)
 
 class Patches(object):
     """Creates L{Patch} objects. Makes sure there is only one such object
index 96ccb79..4b437dc 100644 (file)
@@ -90,6 +90,13 @@ def update_to_current_format_version(repository, branch):
         rm_ref('refs/bases/%s' % branch)
         set_format_version(2)
 
+    # compatibility with the new infrastructure. The changes here do not
+    # affect the compatibility with the old infrastructure (format version 2)
+    if get_format_version() == 2:
+        hidden_file = os.path.join(branch_dir, 'hidden')
+        if not os.path.isfile(hidden_file):
+            utils.create_empty_file(hidden_file)
+
     # Make sure we're at the latest version.
     fv = get_format_version()
     if not fv in [None, FORMAT_VERSION]: