Signed-off-by: Karl Hasselström <kha@treskal.com>
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""
-import sys, os
-from optparse import OptionParser, make_option
-
-from stgit.commands.common import *
-from stgit.utils import *
+from stgit.commands import common
+from stgit.lib import transaction
-from stgit import stack, git
help = 'permanently store the applied patches into stack base'
usage = """%prog [options]
help = 'permanently store the applied patches into stack base'
usage = """%prog [options]
Use this command only if you want to permanently store the applied
patches and no longer manage them with StGIT."""
Use this command only if you want to permanently store the applied
patches and no longer manage them with StGIT."""
-directory = DirectoryGotoToplevel()
+directory = common.DirectoryHasRepositoryLib()
if len(args) != 0:
parser.error('incorrect number of arguments')
if len(args) != 0:
parser.error('incorrect number of arguments')
- check_local_changes()
- check_conflicts()
- check_head_top_equal(crt_series)
-
- applied = crt_series.get_applied()
- if not applied:
- raise CmdException, 'No patches applied'
-
- if crt_series.get_protected():
- raise CmdException, 'This branch is protected. Commit is not permitted'
-
- crt_head = git.get_head()
-
- out.start('Committing %d patches' % len(applied))
-
- crt_series.pop_patch(applied[0])
- git.switch(crt_head)
-
- for patch in applied:
- crt_series.delete_patch(patch)
-
+ stack = directory.repository.current_stack
+ patches = stack.patchorder.applied
+ if not patches:
+ raise CmdException('No patches to commit')
+ out.start('Committing %d patches' % len(patches))
+ trans = transaction.StackTransaction(stack, 'stg commit')
+ for pn in patches:
+ trans.patches[pn] = None
+ trans.applied = []
+ trans.base = stack.head
+ trans.run()
self.__unapplied = list(self.__stack.patchorder.unapplied)
self.__error = None
self.__current_tree = self.__stack.head.data.tree
self.__unapplied = list(self.__stack.patchorder.unapplied)
self.__error = None
self.__current_tree = self.__stack.head.data.tree
+ self.__base = self.__stack.base
stack = property(lambda self: self.__stack)
patches = property(lambda self: self.__patches)
def __set_applied(self, val):
stack = property(lambda self: self.__stack)
patches = property(lambda self: self.__patches)
def __set_applied(self, val):
def __set_unapplied(self, val):
self.__unapplied = list(val)
unapplied = property(lambda self: self.__unapplied, __set_unapplied)
def __set_unapplied(self, val):
self.__unapplied = list(val)
unapplied = property(lambda self: self.__unapplied, __set_unapplied)
+ def __set_base(self, val):
+ assert not self.__applied
+ self.__base = val
+ base = property(lambda self: self.__base, __set_base)
def __checkout(self, tree, iw):
if not self.__stack.head_top_equal():
out.error(
def __checkout(self, tree, iw):
if not self.__stack.head_top_equal():
out.error(
if self.__applied:
return self.__patches[self.__applied[-1]]
else:
if self.__applied:
return self.__patches[self.__applied[-1]]
else:
- return self.__stack.base
def abort(self, iw = None):
# The only state we need to restore is index+worktree.
if iw:
def abort(self, iw = None):
# The only state we need to restore is index+worktree.
if iw: