diff mercurial/hook.py @ 27228:10695f8f3323 stable

dirstate: don't write repo.currenttransaction to repo.dirstate if repo is None (issue4983) Some hooks, such as post-init and post-clone, do not get a repo parameter in their environment. If there is no repo, there is no repo.currenttransaction(); attempting to retrieve it anyway was causing crashes. Now currenttransaction is only retrieved and written if the repo is not None.
author Sietse Brouwer <sbbrouwer@gmail.com>
date Thu, 03 Dec 2015 01:38:21 +0100
parents 10a1a4b3e775
children 2058e1a894f2
line wrap: on
line diff
--- a/mercurial/hook.py	Wed Dec 02 14:20:13 2015 -0800
+++ b/mercurial/hook.py	Thu Dec 03 01:38:21 2015 +0100
@@ -120,10 +120,11 @@
     env = {}
 
     # make in-memory changes visible to external process
-    tr = repo.currenttransaction()
-    repo.dirstate.write(tr)
-    if tr and tr.writepending():
-        env['HG_PENDING'] = repo.root
+    if repo is not None:
+        tr = repo.currenttransaction()
+        repo.dirstate.write(tr)
+        if tr and tr.writepending():
+            env['HG_PENDING'] = repo.root
 
     for k, v in args.iteritems():
         if callable(v):