From: "Karl Hasselström" <kha@treskal.com>
To: Catalin Marinas <catalin.marinas@gmail.com>
Cc: git@vger.kernel.org
Subject: [StGit PATCH 07/10] Log conflicts separately
Date: Mon, 21 Apr 2008 00:11:01 +0200 [thread overview]
Message-ID: <20080420221101.5837.13630.stgit@yoghurt> (raw)
In-Reply-To: <20080420215625.5837.82896.stgit@yoghurt>
This patch makes commands that produce a conflict log that final
conflicting push separately from the rest of the command's effects.
This makes it possible for the user to roll back just the final
conflicting push if she desires. (Rolling back the whole operation is
of course still possible, by resetting to the state yet another step
back in the log.)
This change only applies to the new-infrastructure commands.
Signed-off-by: Karl Hasselström <kha@treskal.com>
---
stgit/lib/transaction.py | 47 +++++++++++++++++++++++++++++++---------------
1 files changed, 32 insertions(+), 15 deletions(-)
diff --git a/stgit/lib/transaction.py b/stgit/lib/transaction.py
index 4c3b448..92bcfd5 100644
--- a/stgit/lib/transaction.py
+++ b/stgit/lib/transaction.py
@@ -42,6 +42,7 @@ class StackTransaction(object):
self.__patches = _TransPatchMap(stack)
self.__applied = list(self.__stack.patchorder.applied)
self.__unapplied = list(self.__stack.patchorder.unapplied)
+ self.__conflicting_push = None
self.__error = None
self.__current_tree = self.__stack.head.data.tree
self.__base = self.__stack.base
@@ -121,19 +122,26 @@ class StackTransaction(object):
out.error(self.__error)
# Write patches.
- for pn, commit in self.__patches.iteritems():
- if self.__stack.patches.exists(pn):
- p = self.__stack.patches.get(pn)
- if commit == None:
- p.delete()
+ def write(msg):
+ for pn, commit in self.__patches.iteritems():
+ if self.__stack.patches.exists(pn):
+ p = self.__stack.patches.get(pn)
+ if commit == None:
+ p.delete()
+ else:
+ p.set_commit(commit, msg)
else:
- p.set_commit(commit, self.__msg)
- else:
- self.__stack.patches.new(pn, commit, self.__msg)
- _print_current_patch(self.__stack.patchorder.applied, self.__applied)
- self.__stack.patchorder.applied = self.__applied
- self.__stack.patchorder.unapplied = self.__unapplied
- log.log_entry(self.__stack, self.__msg)
+ self.__stack.patches.new(pn, commit, msg)
+ self.__stack.patchorder.applied = self.__applied
+ self.__stack.patchorder.unapplied = self.__unapplied
+ log.log_entry(self.__stack, msg)
+ old_applied = self.__stack.patchorder.applied
+ write(self.__msg)
+ if self.__conflicting_push != None:
+ self.__patches = _TransPatchMap(self.__stack)
+ self.__conflicting_push()
+ write(self.__msg + ' (CONFLICT)')
+ _print_current_patch(old_applied, self.__applied)
if self.__error:
return utils.STGIT_CONFLICT
@@ -223,18 +231,27 @@ class StackTransaction(object):
cd = cd.set_tree(tree)
if any(getattr(cd, a) != getattr(orig_cd, a) for a in
['parent', 'tree', 'author', 'message']):
- self.patches[pn] = self.__stack.repository.commit(cd)
+ comm = self.__stack.repository.commit(cd)
else:
+ comm = None
s = ' (unmodified)'
- del self.unapplied[self.unapplied.index(pn)]
- self.applied.append(pn)
out.info('Pushed %s%s' % (pn, s))
+ def update():
+ if comm:
+ self.patches[pn] = comm
+ del self.unapplied[self.unapplied.index(pn)]
+ self.applied.append(pn)
if merge_conflict:
# We've just caused conflicts, so we must allow them in
# the final checkout.
self.__allow_conflicts = lambda trans: True
+ # Save this update so that we can run it a little later.
+ self.__conflicting_push = update
self.__halt('Merge conflict')
+ else:
+ # Update immediately.
+ update()
def reorder_patches(self, applied, unapplied, iw = None):
"""Push and pop patches to attain the given ordering."""
next prev parent reply other threads:[~2008-04-20 22:12 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 ` [StGit PATCH 02/10] Add property with a list of all patch names Karl Hasselström
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 ` Karl Hasselström [this message]
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=20080420221101.5837.13630.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).