Skip to contentSkip to conversation

Catch more exceptions in compat_log_entry()

PATCH In review Pavel Roskin 2 participants 2 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Catch more exceptions in compat_log_entry()

Catch exceptions in default_repo(). Catch git.RepositoryException. This suppresses stack trace in "stg pull" on detached head and outside the repository.

---
 stgit/lib/log.py |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
stgit/lib/log.py +2 -2
index dfadd51..d876ff6 100644
@@ -359,10 +359,10 @@ class Fakestack(object):
 def compat_log_entry(msg):
     """Write a new log entry. (Convenience function intended for use by
     code not yet converted to the new infrastructure.)"""
-    repo = default_repo()
     try:
+        repo = default_repo()
         stack = repo.get_stack(repo.current_branch_name)
-    except libstack.StackException, e:
+    except (libstack.StackException, git.RepositoryException), e:
         out.warn(str(e), 'Could not write to stack log')
     else:
         if repo.default_index.conflicts() and stack.patchorder.applied:
#1 lore raw
Quoted 5 lines · Pavel Roskin

Catch exceptions in default_repo(). Catch git.RepositoryException. This suppresses stack trace in "stg pull" on detached head and outside the repository.

Thanks. Applied.

Catalin