threads / patch / 15506

patchDo not crash if a patch log ref is missing

Subject: [StGit PATCH] Do not crash if a patch log ref is missing

## tl;dr

3 messages between Sep 12, 2008 and Sep 14, 2008. Diffs are folded; open one to read it.

replies: 2people: 2as markdown or json

Catalin Marinas· Sep 12, 2008, 21:54 UTC · lore

Since we'll get rid of the individual patch logs, StGit should ignore if such a ref is missing when deleting the compatibility patch files.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
---
 stgit/lib/stack.py |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
Show changes to stgit/lib/stack.py +5 −1
diff --git a/stgit/lib/stack.py b/stgit/lib/stack.py
index 9cb3967..1059955 100644
--- a/stgit/lib/stack.py
+++ b/stgit/lib/stack.py
@@ -68,7 +68,11 @@ class Patch(object):
             for f in os.listdir(self.__compat_dir):
                 os.remove(os.path.join(self.__compat_dir, f))
             os.rmdir(self.__compat_dir)
-        self.__stack.repository.refs.delete(self.__log_ref)
+        try:
+            # this compatibility log ref might not exist
+            self.__stack.repository.refs.delete(self.__log_ref)
+        except KeyError:
+            pass
     def set_commit(self, commit, msg):
         self.__write_compat_files(commit, msg)
         self.__stack.repository.refs.set(self.__ref, commit, msg)
Karl Hasselström· Sep 14, 2008, 08:08 UTC · re: Catalin Marinas · lore

Re: [StGit PATCH] Do not crash if a patch log ref is missing

On 2008-09-12 22:54:58 +0100, Catalin Marinas wrote:
> Since we'll get rid of the individual patch logs, StGit should
> ignore if such a ref is missing when deleting the compatibility
> patch files.

I agree this is a good idea from a robustness perspective. Did you encounter a case where the deletion actually failed?

-- 
Karl Hasselström, kha@treskal.com
      www.treskal.com/kalle
Catalin Marinas· Sep 14, 2008, 21:01 UTC · re: Karl Hasselström · lore

Re: [StGit PATCH] Do not crash if a patch log ref is missing

On 14/09/2008, Karl Hasselström <kha@treskal.com> wrote:
Show 9 quoted lines
> On 2008-09-12 22:54:58 +0100, Catalin Marinas wrote:
>
>  > Since we'll get rid of the individual patch logs, StGit should
>  > ignore if such a ref is missing when deleting the compatibility
>  > patch files.
>
>
> I agree this is a good idea from a robustness perspective. Did you
>  encounter a case where the deletion actually failed?

Yes, I was deleting some older patches and it happened for one of them not to have a log reference. It left the stack in a pretty undefined state (and used the stable StGit to delete the rest of the patches as it is more tolerant :-)).

-- 
Catalin

← back to recent threads