From: "Karl Hasselström" <kha@treskal.com>
To: Catalin Marinas <catalin.marinas@gmail.com>
Cc: git@vger.kernel.org, "David Kågedal" <davidk@lysator.liu.se>
Subject: [StGit PATCH 1/5] Expose transaction abort function
Date: Fri, 14 Dec 2007 07:32:13 +0100 [thread overview]
Message-ID: <20071214063213.29290.54202.stgit@yoghurt> (raw)
In-Reply-To: <20071214062618.29290.70792.stgit@yoghurt>
Users of stack transactions may call abort() instead of run(), if they
wish to roll back the transaction instead of committing it.
Signed-off-by: Karl Hasselström <kha@treskal.com>
---
stgit/lib/transaction.py | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/stgit/lib/transaction.py b/stgit/lib/transaction.py
index 77333b3..663d393 100644
--- a/stgit/lib/transaction.py
+++ b/stgit/lib/transaction.py
@@ -77,6 +77,10 @@ class StackTransaction(object):
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:
+ self.__checkout(self.__stack.head.data.tree, iw)
def run(self, iw = None):
self.__check_consistency()
new_head = self.__head
@@ -85,9 +89,8 @@ class StackTransaction(object):
try:
self.__checkout(new_head.data.tree, iw)
except git.CheckoutException:
- # We have to abort the transaction. The only state we need
- # to restore is index+worktree.
- self.__checkout(self.__stack.head.data.tree, iw)
+ # We have to abort the transaction.
+ self.abort(iw)
self.__abort()
self.__stack.set_head(new_head, self.__msg)
next prev parent reply other threads:[~2007-12-14 6:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-14 6:32 [StGit PATCH 0/5] More experimental patches Karl Hasselström
2007-12-14 6:32 ` Karl Hasselström [this message]
2007-12-14 6:32 ` [StGit PATCH 2/5] stg coalesce: Support --file and --save-template Karl Hasselström
2007-12-14 6:32 ` [StGit PATCH 3/5] Set exit code to 3 on merge conflict Karl Hasselström
2007-12-14 6:32 ` [StGit PATCH 4/5] Convert "stg commit" to new infrastructure Karl Hasselström
2007-12-14 6:32 ` [StGit PATCH 5/5] Make "stg commit" fancier 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=20071214063213.29290.54202.stgit@yoghurt \
--to=kha@treskal.com \
--cc=catalin.marinas@gmail.com \
--cc=davidk@lysator.liu.se \
--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).