git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
To: Catalin Marinas <catalin.marinas@gmail.com>
Cc: git@vger.kernel.org
Subject: [patch 06/11] Avoid allowing --undo if it doesn't change anything
Date: Fri, 16 Sep 2005 21:35:19 +0200	[thread overview]
Message-ID: <20050916193518.18681.9261.stgit@zion.home.lan> (raw)
In-Reply-To: <20050916193511.18681.24189.stgit@zion.home.lan>

From: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>

Avoid top/bottom backup files identical to current ones. Simply remove
them.

Also, change restore_old_boundaries() to handle gracefully the new
situation rather than print an exception.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
---

 stgit/commands/push.py |    6 ++++--
 stgit/stack.py         |   17 +++++++++++++----
 2 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/stgit/commands/push.py b/stgit/commands/push.py
--- a/stgit/commands/push.py
+++ b/stgit/commands/push.py
@@ -66,8 +66,10 @@ def func(parser, options, args):
         print 'Undoing the "%s" push...' % patch,
         sys.stdout.flush()
         resolved_all()
-        crt_series.undo_push()
-        print 'done'
+        if crt_series.undo_push():
+            print 'done'
+        else:
+            print 'done (patch unchanged)'
         print_crt_patch()
 
         return
diff --git a/stgit/stack.py b/stgit/stack.py
--- a/stgit/stack.py
+++ b/stgit/stack.py
@@ -170,7 +170,11 @@ class Patch:
 
     def set_bottom(self, string, backup = False):
         if backup:
-            self.__set_field('bottom.old', self.__get_field('bottom'))
+            curr = self.__get_field('bottom')
+            if curr != string:
+                self.__set_field('bottom.old', curr)
+            else:
+                self.__set_field('bottom.old', None)
         self.__set_field('bottom', string)
 
     def get_top(self):
@@ -178,7 +182,11 @@ class Patch:
 
     def set_top(self, string, backup = False):
         if backup:
-            self.__set_field('top.old', self.__get_field('top'))
+            curr = self.__get_field('top')
+            if curr != string:
+                self.__set_field('top.old', curr)
+            else:
+                self.__set_field('top.old', None)
         self.__set_field('top', string)
 
     def restore_old_boundaries(self):
@@ -188,8 +196,9 @@ class Patch:
         if top and bottom:
             self.__set_field('bottom', bottom)
             self.__set_field('top', top)
+            return True
         else:
-            raise StackException, 'No patch undo information'
+            return False
 
     def get_description(self):
         return self.__get_field('description', True)
@@ -571,7 +580,7 @@ class Series:
         patch = Patch(name, self.__patch_dir)
         git.reset()
         self.pop_patch(name)
-        patch.restore_old_boundaries()
+        return patch.restore_old_boundaries()
 
     def pop_patch(self, name):
         """Pops the top patch from the stack

  parent reply	other threads:[~2005-09-16 19:38 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-16 19:35 [patch 01/11] Fix typo: comitter->committer Paolo 'Blaisorblade' Giarrusso
2005-09-16 19:35 ` [patch 02/11] Make "empty patch" checking optional in "series" command Paolo 'Blaisorblade' Giarrusso
2005-09-17  8:17   ` Catalin Marinas
2005-09-16 19:35 ` [patch 03/11] stg diff / files: don't update directory cache unless needed Paolo 'Blaisorblade' Giarrusso
2005-09-16 19:35 ` [patch 04/11] Fix "mail" command when description contains "From" lines Paolo 'Blaisorblade' Giarrusso
2005-09-16 19:35 ` [patch 05/11] Make "stg files" output match "quilt files" one Paolo 'Blaisorblade' Giarrusso
2005-09-16 19:35 ` Paolo 'Blaisorblade' Giarrusso [this message]
2005-09-16 19:35 ` [patch 07/11] Implement fast-forward when only tree (but not commits) match Paolo 'Blaisorblade' Giarrusso
2005-09-16 19:35 ` [patch 08/11] Fix "stg clean" when stack is empty Paolo 'Blaisorblade' Giarrusso
2005-09-16 19:35 ` [patch 09/11] Allow mailing a given patch list Paolo 'Blaisorblade' Giarrusso
2005-09-16 19:35 ` [patch 10/11] Fix "stg mail" address parsing for hyphen Paolo 'Blaisorblade' Giarrusso
2005-09-16 19:35 ` [patch 11/11] Detect description in quilt patches Paolo 'Blaisorblade' Giarrusso

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=20050916193518.18681.9261.stgit@zion.home.lan \
    --to=blaisorblade@yahoo.it \
    --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).