Patchwork [evolve-ext] inhibit: add missing locking in wrapper for obsmarker creation

login
register
mail settings
Submitter Laurent Charignon
Date July 9, 2015, 7:51 p.m.
Message ID <2f02748634f72936ac6b.1436471472@dev919.prn2.facebook.com>
Download mbox | patch
Permalink /patch/9944/
State Accepted
Headers show

Comments

Laurent Charignon - July 9, 2015, 7:51 p.m.
# HG changeset patch
# User Laurent Charignon <lcharignon@fb.com>
# Date 1436470927 25200
#      Thu Jul 09 12:42:07 2015 -0700
# Node ID 2f02748634f72936ac6b13d82c079361ce6a2355
# Parent  4140d680784e2d1c9d78df76bf514014a384ee82
inhibit: add missing locking in wrapper for obsmarker creation

The develwarning for transaction without lock rightfully pointed out to this
issue. Before this patch we were not locking in the transaction for obsmarker
creation and therefore showing the warnings.
Pierre-Yves David - July 29, 2015, 7:50 p.m.
On 07/09/2015 12:51 PM, Laurent Charignon wrote:
> # HG changeset patch
> # User Laurent Charignon <lcharignon@fb.com>
> # Date 1436470927 25200
> #      Thu Jul 09 12:42:07 2015 -0700
> # Node ID 2f02748634f72936ac6b13d82c079361ce6a2355
> # Parent  4140d680784e2d1c9d78df76bf514014a384ee82
> inhibit: add missing locking in wrapper for obsmarker creation

That one was pushed as a8a4c8b8550d

Patch

diff --git a/hgext/inhibit.py b/hgext/inhibit.py
--- a/hgext/inhibit.py
+++ b/hgext/inhibit.py
@@ -155,14 +155,16 @@ 
 def _createmarkers(orig, repo, relations, flag=0, date=None, metadata=None):
     """wrap markers create to make sure we de-inhibit target nodes"""
     # wrapping transactio to unify the one in each function
-    tr = repo.transaction('add-obsolescence-marker')
+    lock = tr = None
     try:
+        lock = repo.lock()
+        tr = repo.transaction('add-obsolescence-marker')
         orig(repo, relations, flag, date, metadata)
         precs = (r[0].node() for r in relations)
         _deinhibitmarkers(repo, precs)
         tr.close()
     finally:
-        tr.release()
+        lockmod.release(tr, lock)
 
 def transactioncallback(orig, repo, *args, **kwargs):
     """ Wrap localrepo.transaction to inhibit new obsolete changes """