Add --keep option to pop
[stgit] / stgit / stack.py
index 0217a7f..c1071b5 100644 (file)
@@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 import sys, os
 
 from stgit.utils import *
-from stgit import git, basedir
+from stgit import git, basedir, templates
 from stgit.config import config
 
 
@@ -65,14 +65,14 @@ def __clean_comments(f):
     f.writelines(lines)
 
 def edit_file(series, line, comment, show_patch = True):
-    fname = '.stgit.msg'
-    tmpl = os.path.join(basedir.get(), 'patchdescr.tmpl')
+    fname = '.stgitmsg.txt'
+    tmpl = templates.get_template('patchdescr.tmpl')
 
     f = file(fname, 'w+')
     if line:
         print >> f, line
-    elif os.path.isfile(tmpl):
-        print >> f, file(tmpl).read().rstrip()
+    elif tmpl:
+        print >> f, tmpl,
     else:
         print >> f
     print >> f, __comment_prefix, comment
@@ -925,7 +925,7 @@ class Series:
         self.pop_patch(name)
         return patch.restore_old_boundaries()
 
-    def pop_patch(self, name):
+    def pop_patch(self, name, keep = False):
         """Pops the top patch from the stack
         """
         applied = self.get_applied()
@@ -934,7 +934,7 @@ class Series:
 
         patch = Patch(name, self.__patch_dir, self.__refs_dir)
 
-        git.switch(patch.get_bottom())
+        git.switch(patch.get_bottom(), keep)
 
         # save the new applied list
         idx = applied.index(name) + 1