[StGit PATCH 10/13] Refactor Series.new_patch

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: David
Date: Friday, September 14, 2007 - 3:32 pm

This shuffles some code so that the top and bottom never need to be
set to anything other than a valid commit and its parent.

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

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


diff --git a/stgit/stack.py b/stgit/stack.py
index 733a241..fdff5a4 100644
--- a/stgit/stack.py
+++ b/stgit/stack.py
@@ -864,13 +864,6 @@ class Series(PatchSet):
         patch = self.get_patch(name)
         patch.create()
 
-        if not bottom:
-            bottom = head
-        if not top:
-            top = head
-
-        patch.set_bottom(bottom)
-        patch.set_top(top)
         patch.set_description(descr)
         patch.set_authname(author_name)
         patch.set_authemail(author_email)
@@ -889,10 +882,15 @@ class Series(PatchSet):
             set_head = True
 
         if commit:
+            if top:
+                top_commit = git.get_commit(top)
+            else:
+                bottom = head
+                top_commit = git.get_commit(head)
+
             # create a commit for the patch (may be empty if top == bottom);
             # only commit on top of the current branch
             assert(unapplied or bottom == head)
-            top_commit = git.get_commit(top)
             commit_id = git.commit(message = descr, parents = [bottom],
                                    cache_update = False,
                                    tree_id = top_commit.get_tree(),
@@ -903,9 +901,12 @@ class Series(PatchSet):
                                    committer_name = committer_name,
                                    committer_email = committer_email)
             # set the patch top to the new commit
+            patch.set_bottom(bottom)
             patch.set_top(commit_id)
         else:
             assert top != bottom
+            patch.set_bottom(bottom)
+            patch.set_top(top)
 
         self.log_patch(patch, 'new')
 

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[StGit PATCH 06/13] Refactor Series.push_patch, David , (Fri Sep 14, 3:31 pm)
[StGit PATCH 10/13] Refactor Series.new_patch, David , (Fri Sep 14, 3:32 pm)
[StGit PATCH 12/13] Remove the 'bottom' field, David , (Fri Sep 14, 3:32 pm)
[StGit PATCH 13/13] Remove the 'top' field, David , (Fri Sep 14, 3:32 pm)
Re: [StGit PATCH 00/13] Eliminate 'top' and 'bottom' files, Catalin Marinas, (Sun Sep 16, 12:28 am)
Re: [StGit PATCH 13/13] Remove the 'top' field, David Kågedal, (Sun Sep 16, 3:22 am)
Re: [StGit PATCH 00/13] Eliminate 'top' and 'bottom' files, David Kågedal, (Sun Sep 16, 3:25 am)
Re: [StGit PATCH 00/13] Eliminate 'top' and 'bottom' files, David Kågedal, (Sun Sep 16, 3:28 am)
Re: [StGit PATCH 13/13] Remove the 'top' field, Karl , (Mon Sep 17, 12:30 am)