chiark / gitweb /
Keep the patch log when import --replace deletes patches
authorCatalin Marinas <catalin.marinas@gmail.com>
Tue, 27 Nov 2007 10:32:12 +0000 (10:32 +0000)
committerCatalin Marinas <catalin.marinas@gmail.com>
Tue, 27 Nov 2007 10:32:12 +0000 (10:32 +0000)
This is a fix for bug #10123.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
stgit/commands/imprt.py
stgit/stack.py

index d6e950cdd53750d5589d0bb00cd29330ef4f4f67..ec3ca9378e4ef2a5f269daf7ee11db0e27b45ad5 100644 (file)
@@ -129,7 +129,7 @@ def __create_patch(filename, message, author_name, author_email,
         out.info('Ignoring already applied patch "%s"' % patch)
         return
     if options.replace and patch in crt_series.get_unapplied():
-        crt_series.delete_patch(patch)
+        crt_series.delete_patch(patch, keep_log = True)
 
     # refresh_patch() will invoke the editor in this case, with correct
     # patch content
index 1130210de3f8d5052c4f34e84ab7b6203054eb53..7f167111a5061448839240d1e334c639ea7339ab 100644 (file)
@@ -165,7 +165,7 @@ class Patch(StgitObject):
         self.create_empty_field('bottom')
         self.create_empty_field('top')
 
-    def delete(self):
+    def delete(self, keep_log = False):
         if os.path.isdir(self._dir()):
             for f in os.listdir(self._dir()):
                 os.remove(os.path.join(self._dir(), f))
@@ -177,7 +177,7 @@ class Patch(StgitObject):
             git.delete_ref(self.__top_ref)
         except git.GitException, e:
             out.warn(str(e))
-        if git.ref_exists(self.__log_ref):
+        if not keep_log and git.ref_exists(self.__log_ref):
             git.delete_ref(self.__log_ref)
 
     def get_name(self):
@@ -940,7 +940,7 @@ class Series(PatchSet):
 
         return patch
 
-    def delete_patch(self, name):
+    def delete_patch(self, name, keep_log = False):
         """Deletes a patch
         """
         self.__patch_name_valid(name)
@@ -957,7 +957,7 @@ class Series(PatchSet):
         # save the commit id to a trash file
         write_string(os.path.join(self.__trash_dir, name), patch.get_top())
 
-        patch.delete()
+        patch.delete(keep_log = keep_log)
 
         unapplied = self.get_unapplied()
         unapplied.remove(name)