All of lore.kernel.org
 help / color / mirror / Atom feed
From: "David Kågedal" <davidk@lysator.liu.se>
To: git@vger.kernel.org, catalin.marinas@gmail.com
Subject: [StGit PATCH 08/13] Add a 'bottom' parameter to Series.refresh_patch and use it
Date: Sat, 15 Sep 2007 00:31:49 +0200	[thread overview]
Message-ID: <20070914223149.7001.39170.stgit@morpheus.local> (raw)
In-Reply-To: <20070914222819.7001.55921.stgit@morpheus.local>

By specifying a bottom for the new patch commit, it is no longer
necessary to update the bottom of the patch before calling
refresh_patch.  This ensures that the patch top always correspond to a
commit object, and the bottom to its parent.

Signed-off-by: David Kågedal <davidk@lysator.liu.se>
---

 stgit/stack.py |   24 ++++++++----------------
 1 files changed, 8 insertions(+), 16 deletions(-)


diff --git a/stgit/stack.py b/stgit/stack.py
index 03ce218..fd19a82 100644
--- a/stgit/stack.py
+++ b/stgit/stack.py
@@ -748,7 +748,7 @@ class Series(PatchSet):
                       author_date = None,
                       committer_name = None, committer_email = None,
                       backup = False, sign_str = None, log = 'refresh',
-                      notes = None):
+                      notes = None, bottom = None):
         """Generates a new commit for the topmost patch
         """
         patch = self.get_current_patch()
@@ -780,7 +780,8 @@ class Series(PatchSet):
 
         descr = add_sign_line(descr, sign_str, committer_name, committer_email)
 
-        bottom = patch.get_bottom()
+        if not bottom:
+            bottom = patch.get_bottom()
 
         commit_id = git.commit(files = files,
                                message = descr, parents = [bottom],
@@ -1026,20 +1027,15 @@ class Series(PatchSet):
         unapplied = self.get_unapplied()
         assert(name in unapplied)
 
-        patch = self.get_patch(name)
+        # patch = self.get_patch(name)
         head = git.get_head()
 
-        # The top is updated by refresh_patch since we need an empty
-        # commit
-        patch.set_bottom(head, backup = True)
-        patch.set_top(head, backup = True)
-
         append_string(self.__applied_file, name)
 
         unapplied.remove(name)
         write_strings(self.__unapplied_file, unapplied)
 
-        self.refresh_patch(cache_update = False, log = 'push(m)')
+        self.refresh_patch(bottom = head, cache_update = False, log = 'push(m)')
 
     def push_patch(self, name):
         """Pushes a patch on the stack
@@ -1071,11 +1067,6 @@ class Series(PatchSet):
         ex = None
         modified = False
 
-        # new patch needs to be refreshed.
-        # The current patch is empty after merge.
-        patch.set_bottom(head, backup = True)
-        patch.set_top(head, backup = True)
-
         # Try the fast applying first. If this fails, fall back to the
         # three-way merge
         if not git.apply_diff(bottom, top):
@@ -1103,13 +1094,14 @@ class Series(PatchSet):
                 log = 'push(m)'
             else:
                 log = 'push'
-            self.refresh_patch(cache_update = False, log = log)
+            self.refresh_patch(bottom = head, cache_update = False, log = log)
         else:
             # we store the correctly merged files only for
             # tracking the conflict history. Note that the
             # git.merge() operations should always leave the index
             # in a valid state (i.e. only stage 0 files)
-            self.refresh_patch(cache_update = False, log = 'push(c)')
+            self.refresh_patch(bottom = head, cache_update = False,
+                               log = 'push(c)')
             raise StackException, str(ex)
 
         return modified

  parent reply	other threads:[~2007-09-14 22:32 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-14 22:31 [StGit PATCH 00/13] Eliminate 'top' and 'bottom' files David Kågedal
2007-09-14 22:31 ` [StGit PATCH 01/13] Add some more tests of "stg status" output David Kågedal
2007-09-14 22:31 ` [StGit PATCH 02/13] Clear up semantics of tree_status David Kågedal
2007-09-14 22:31 ` [StGit PATCH 03/13] Moved that status function to the status command file David Kågedal
2007-09-14 22:36   ` David Kågedal
2007-09-14 22:31 ` [StGit PATCH 04/13] Split Series.push_patch in two David Kågedal
2007-09-14 22:31 ` [StGit PATCH 05/13] Remove dead code from push_empty_patch David Kågedal
2007-09-14 22:31 ` [StGit PATCH 06/13] Refactor Series.push_patch David Kågedal
2007-09-14 22:31 ` [StGit PATCH 07/13] Clean up Series.refresh_patch David Kågedal
2007-09-14 22:31 ` David Kågedal [this message]
2007-09-14 22:31 ` [StGit PATCH 09/13] Clear up the semantics of Series.new_patch David Kågedal
2007-10-08 13:16   ` Catalin Marinas
2007-10-08 13:25     ` Karl Hasselström
2007-10-09 21:01       ` Catalin Marinas
2007-10-10  7:43         ` David Kågedal
2007-10-11 20:42           ` Catalin Marinas
2007-10-10  7:45         ` Karl Hasselström
2007-10-10  8:15           ` Karl Hasselström
2007-09-14 22:32 ` [StGit PATCH 10/13] Refactor Series.new_patch David Kågedal
2007-09-14 22:32 ` [StGit PATCH 11/13] Check bottom and invariants David Kågedal
2007-09-14 22:32 ` [StGit PATCH 12/13] Remove the 'bottom' field David Kågedal
2007-09-14 22:32 ` [StGit PATCH 13/13] Remove the 'top' field David Kågedal
2007-09-15 23:36   ` Karl Hasselström
2007-09-16 10:22     ` David Kågedal
2007-09-17  7:30       ` Karl Hasselström
2007-09-15 23:42 ` [StGit PATCH 00/13] Eliminate 'top' and 'bottom' files Karl Hasselström
2007-09-16  7:28   ` Catalin Marinas
2007-09-16 10:28     ` David Kågedal
2007-09-17  8:17     ` Karl Hasselström
2007-09-16 10:25   ` David Kågedal

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=20070914223149.7001.39170.stgit@morpheus.local \
    --to=davidk@lysator.liu.se \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.