git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] Stgit - patch history / add extra parents
@ 2005-08-18 19:57 Jan Veldeman
  2005-08-19  9:53 ` Catalin Marinas
  0 siblings, 1 reply; 22+ messages in thread
From: Jan Veldeman @ 2005-08-18 19:57 UTC (permalink / raw)
  To: git

Hi,

I like stgit very much, but I feel there is still something missing:
stgit is very handy when you use it for patches which should be pushed to
mainline rather quickly. But for pacthes which won't be pushed immediately
to mainline, it would be usefull to have a history of the patches itself.

The patch below, together with the following script could be used to
make snapshots of the patch stack (I call it freeze, as I thought snapshot
was already going to be used for something else):

#!/bin/bash
# stg-freeze
set -ex
top=$(stg top)

# Freeze the current stack
branchname=$(basename $(readlink .git/HEAD))
while read patch
do
	cp .git/patches/$branchname/$patch/top .git/patches/$branchname/$patch/parent
done < .git/patches/$branchname/applied

# Refresh the patches
stg pop -a
stg push -t $top
# end stg-freeze

Note: this is a proof of concept, when/if it would be incorporated, it
should be implemented in stgit itself, and a bit more efficient, especially
the refreshing of the patches ;-)

This is how it works: when not doing anything, stgit works as normal.
Once stg-freeze is called, it creates .git/patches/$branchname/$patch/parent
which contains the SHA1 id of the "frozen" patch. By refreshing the stack,
all patches now include the corresponding frozen patch as a parent.

The following script is a test I use. Add stg-freeze to the path and
source/run it in an empty directory, view with gitk afterwards:

###
echo "Initial commit" | cg-init
stg init

stg new a -mpatch-1
echo a > a
stg add a
stg refresh -mpatch-1
stg new b -mpatch-2
echo b > b
stg add b
stg refresh -mpatch-2
stg-freeze
stg pop
echo a2 >> a
stg refresh -mpatch-1-update
stg push
stg-freeze
echo b2 >> b
stg refresh -mpatch-2-update


stg pop -a
echo c > c
cg-add c
cg-commit -m"Mainline advance"
stg push -a

stg-freeze

stg pop -a
echo d > d
cg-add d
cg-commit -m"Mainline advance 2"
stg push -a

stg pop -a
echo e > e
cg-add e
cg-commit -m"Mainline advance 3"
stg push -a

###

Comments/remarks are very welcome.

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


diff --git a/stgit/stack.py b/stgit/stack.py
--- a/stgit/stack.py
+++ b/stgit/stack.py
@@ -140,6 +140,13 @@ class Patch:
         elif os.path.isfile(fname):
             os.remove(fname)
 
+    def get_parents(self):
+        parents=[]
+        if (self.__get_field('parent') != None):
+                parents = parents + [self.__get_field('parent')]
+        parents = parents + [ self.get_bottom() ]
+        return parents
+
     def get_bottom(self):
         return self.__get_field('bottom')
 
@@ -362,7 +369,7 @@ class Series:
         if not committer_email:
             committer_email = patch.get_commemail()
 
-        commit_id = git.commit(message = descr, parents = [patch.get_bottom()],
+        commit_id = git.commit(message = descr, parents = patch.get_parents(),
                                allowempty = True,
                                author_name = author_name,
                                author_email = author_email,

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2005-08-31 17:13 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-18 19:57 [RFC] Stgit - patch history / add extra parents Jan Veldeman
2005-08-19  9:53 ` Catalin Marinas
2005-08-19 18:27   ` Jan Veldeman
2005-08-19 22:15     ` Catalin Marinas
2005-08-19 19:48   ` Jan Veldeman
2005-08-20 21:12     ` Catalin Marinas
2005-08-21  9:40       ` Jan Veldeman
2005-08-22 22:10         ` Daniel Barkalow
2005-08-23 16:55           ` Catalin Marinas
2005-08-23 18:05             ` Daniel Barkalow
2005-08-23 21:23               ` Jan Veldeman
2005-08-23 22:23                 ` Daniel Barkalow
2005-08-25  7:09                   ` Jan Veldeman
2005-08-25 19:41                     ` Daniel Barkalow
2005-08-31  9:27                   ` Catalin Marinas
2005-08-31  9:12                 ` Catalin Marinas
2005-08-30 21:41               ` Catalin Marinas
2005-08-31  8:59                 ` Jan Veldeman
2005-08-31 17:17                 ` Daniel Barkalow
2005-08-24  0:23             ` Junio C Hamano
2005-08-24  2:26               ` Linus Torvalds
2005-08-23  1:06         ` Junio C Hamano

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).