aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCatalin Marinas <catalin.marinas@gmail.com>2010-02-05 13:44:59 +0000
committerCatalin Marinas <catalin.marinas@gmail.com>2010-02-05 13:44:59 +0000
commitba52890d6274b54c024388e79203f902d55476c7 (patch)
treed92f36112e3fd8c6df6424ab8862a646ae60ee17
parente2a3c618b016f84b9e6fe44e77bb798b2b9c718f (diff)
downloadstgit-ba52890d6274b54c024388e79203f902d55476c7.tar.gz
Record a single transaction for conflicting push operations
StGit commands resulting in a conflicting patch pushing record two transactions in the log (with one of them being inconsistent with HEAD != top). Undoing such operations requires two "stg undo" (possibly with --hard) commands which is unintuitive. This patch changes such operations to only record one log entry and "stg undo" reverts the stack to the state prior to the operation. Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com> Cc: Gustav HÃ¥llberg <gustav@virtutech.com> Cc: Karl Wiberg <kha@treskal.com>
-rw-r--r--stgit/lib/transaction.py35
-rwxr-xr-xt/t3101-reset-hard.sh2
-rwxr-xr-xt/t3103-undo-hard.sh4
3 files changed, 19 insertions, 22 deletions
diff --git a/stgit/lib/transaction.py b/stgit/lib/transaction.py
index 30a153b..d82e724 100644
--- a/stgit/lib/transaction.py
+++ b/stgit/lib/transaction.py
@@ -90,7 +90,6 @@ class StackTransaction(object):
self.__applied = list(self.__stack.patchorder.applied)
self.__unapplied = list(self.__stack.patchorder.unapplied)
self.__hidden = list(self.__stack.patchorder.hidden)
- self.__conflicting_push = None
self.__error = None
self.__current_tree = self.__stack.head.data.tree
self.__base = self.__stack.base
@@ -232,10 +231,9 @@ class StackTransaction(object):
self.__stack.patchorder.hidden = self.__hidden
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()
+ if not self.__conflicts:
+ write(self.__msg)
+ else:
write(self.__msg + ' (CONFLICT)')
if print_current_patch:
_print_current_patch(old_applied, self.__applied)
@@ -358,26 +356,25 @@ class StackTransaction(object):
elif not merge_conflict and cd.is_nochange():
s = 'empty'
out.done(s)
- def update():
- if comm:
- self.patches[pn] = comm
- if pn in self.hidden:
- x = self.hidden
- else:
- x = self.unapplied
- del x[x.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
+ self.__patches = _TransPatchMap(self.__stack)
- # Save this update so that we can run it a little later.
- self.__conflicting_push = update
- self.__halt("%d merge conflict(s)" % len(self.__conflicts))
+ # Update the stack state
+ if comm:
+ self.patches[pn] = comm
+ if pn in self.hidden:
+ x = self.hidden
else:
- # Update immediately.
- update()
+ x = self.unapplied
+ del x[x.index(pn)]
+ self.applied.append(pn)
+
+ if merge_conflict:
+ self.__halt("%d merge conflict(s)" % len(self.__conflicts))
def push_tree(self, pn):
"""Push the named patch without updating its tree."""
diff --git a/t/t3101-reset-hard.sh b/t/t3101-reset-hard.sh
index bd97b3a..45e86dc 100755
--- a/t/t3101-reset-hard.sh
+++ b/t/t3101-reset-hard.sh
@@ -47,7 +47,7 @@ test_expect_success 'Try to reset with --hard' '
stg reset --hard master.stgit^~1 &&
stg status a > actual.txt &&
test_cmp expected.txt actual.txt &&
- test "$(echo $(stg series))" = "> p1 - p2 - p3"
+ test "$(echo $(stg series))" = "+ p1 + p2 > p3"
'
test_done
diff --git a/t/t3103-undo-hard.sh b/t/t3103-undo-hard.sh
index 2d0f382..df14b1f 100755
--- a/t/t3103-undo-hard.sh
+++ b/t/t3103-undo-hard.sh
@@ -46,11 +46,11 @@ test_expect_success 'Try to undo without --hard' '
cat > expected.txt <<EOF
EOF
-test_expect_failure 'Try to undo with --hard' '
+test_expect_success 'Try to undo with --hard' '
stg undo --hard &&
stg status a > actual.txt &&
test_cmp expected.txt actual.txt &&
- test "$(echo $(stg series))" = "> p1 - p2 - p3" &&
+ test "$(echo $(stg series))" = "+ p1 + p2 > p3" &&
test "$(stg id)" = "$(stg id $(stg top))"
'