From c26ca1b2e0ec33d9dfef664970f7cf7b329606a7 Mon Sep 17 00:00:00 2001 Message-Id: From: Mark Wooding Date: Tue, 27 Nov 2007 10:32:12 +0000 Subject: [PATCH] Keep the patch log when import --replace deletes patches Organization: Straylight/Edgeware From: Catalin Marinas This is a fix for bug #10123. Signed-off-by: Catalin Marinas --- stgit/commands/imprt.py | 2 +- stgit/stack.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/stgit/commands/imprt.py b/stgit/commands/imprt.py index d6e950c..ec3ca93 100644 --- a/stgit/commands/imprt.py +++ b/stgit/commands/imprt.py @@ -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 diff --git a/stgit/stack.py b/stgit/stack.py index 1130210..7f16711 100644 --- a/stgit/stack.py +++ b/stgit/stack.py @@ -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) -- [mdw]