{"thread":{"id":"15506","subject":"[StGit PATCH] Do not crash if a patch log ref is missing","startedAt":"2008-09-12T21:54:58Z","lastAt":"2008-09-14T21:01:55Z","messageCount":3,"participants":["Catalin Marinas","Karl Hasselström"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"90605","messageId":"20080912215449.10270.38860.stgit@localhost.localdomain","threadId":"15506","inReplyTo":null,"subject":"[StGit PATCH] Do not crash if a patch log ref is missing","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@gmail.com","sentAt":"2008-09-12T21:54:58Z","receivedAt":"2008-09-12T21:54:58Z","isPatch":true,"sender":{"key":"catalin.marinas@gmail.com","avatar":null},"body":"Since we'll get rid of the individual patch logs, StGit should ignore if\nsuch a ref is missing when deleting the compatibility patch files.\n\nSigned-off-by: Catalin Marinas <catalin.marinas@gmail.com>\n---\n stgit/lib/stack.py |    6 +++++-\n 1 files changed, 5 insertions(+), 1 deletions(-)\n\ndiff --git a/stgit/lib/stack.py b/stgit/lib/stack.py\nindex 9cb3967..1059955 100644\n--- a/stgit/lib/stack.py\n+++ b/stgit/lib/stack.py\n@@ -68,7 +68,11 @@ class Patch(object):\n             for f in os.listdir(self.__compat_dir):\n                 os.remove(os.path.join(self.__compat_dir, f))\n             os.rmdir(self.__compat_dir)\n-        self.__stack.repository.refs.delete(self.__log_ref)\n+        try:\n+            # this compatibility log ref might not exist\n+            self.__stack.repository.refs.delete(self.__log_ref)\n+        except KeyError:\n+            pass\n     def set_commit(self, commit, msg):\n         self.__write_compat_files(commit, msg)\n         self.__stack.repository.refs.set(self.__ref, commit, msg)\n"},{"id":"90652","messageId":"20080914080839.GA30664@diana.vm.bytemark.co.uk","threadId":"15506","inReplyTo":"20080912215449.10270.38860.stgit@localhost.localdomain","subject":"Re: [StGit PATCH] Do not crash if a patch log ref is missing","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2008-09-14T08:08:39Z","receivedAt":"2008-09-14T08:08:39Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"On 2008-09-12 22:54:58 +0100, Catalin Marinas wrote:\n\n> Since we'll get rid of the individual patch logs, StGit should\n> ignore if such a ref is missing when deleting the compatibility\n> patch files.\n\nI agree this is a good idea from a robustness perspective. Did you\nencounter a case where the deletion actually failed?\n\n-- \nKarl Hasselström, kha@treskal.com\n      www.treskal.com/kalle\n"},{"id":"90690","messageId":"b0943d9e0809141401o36b1347ctf6444a695b74a8b7@mail.gmail.com","threadId":"15506","inReplyTo":"20080914080839.GA30664@diana.vm.bytemark.co.uk","subject":"Re: [StGit PATCH] Do not crash if a patch log ref is missing","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@gmail.com","sentAt":"2008-09-14T21:01:55Z","receivedAt":"2008-09-14T21:01:55Z","isPatch":true,"sender":{"key":"catalin.marinas@gmail.com","avatar":null},"body":"On 14/09/2008, Karl Hasselström <kha@treskal.com> wrote:\n> On 2008-09-12 22:54:58 +0100, Catalin Marinas wrote:\n>\n>  > Since we'll get rid of the individual patch logs, StGit should\n>  > ignore if such a ref is missing when deleting the compatibility\n>  > patch files.\n>\n>\n> I agree this is a good idea from a robustness perspective. Did you\n>  encounter a case where the deletion actually failed?\n\nYes, I was deleting some older patches and it happened for one of them\nnot to have a log reference. It left the stack in a pretty undefined\nstate (and used the stable StGit to delete the rest of the patches as\nit is more tolerant :-)).\n\n-- \nCatalin\n"}]}