Skip to contentSkip to conversation

Do not crash if a patch log ref is missing

PATCH In review Catalin Marinas 2 participants 3 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Do not crash if a patch log ref is missing

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.

---
 stgit/lib/stack.py |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
stgit/lib/stack.py +5 -1
index 9cb3967..1059955 100644
@@ -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)
#1 lore raw
Quoted 3 lines · Catalin Marinas

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?

Signature · 2 lines
Karl Hasselström, [email protected]
      www.treskal.com/kalle
#2 lore raw
Quoted 9 lines · Karl Hasselström
Quoted 3 lines · Catalin Marinas

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

Signature · 1 line
Catalin