Do not crash if a patch log ref is missing
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
@@ -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)
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
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