changeset 1533:0212c3a84ccd

wrappers: add some missing lock/wlock grabbing Caught with a hack to turn develwarns into crashes. Unfortunately, I can't check that in because a couple of commitctx() calls in tests turn into deadlocks when I try and fix them.
author Augie Fackler <raf@durin42.com>
date Wed, 25 Oct 2017 20:46:54 -0400
parents ae01b360320b
children 7917abf6b456
files hgsubversion/wrappers.py
diffstat 1 files changed, 22 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/hgsubversion/wrappers.py
+++ b/hgsubversion/wrappers.py
@@ -354,18 +354,19 @@ def push(repo, dest, force, revs):
         finally:
             util.swap_out_encoding()
 
-        with repo.lock():
-            if hasobsolete:
-                for marker in obsmarkers:
-                    obsolete.createmarkers(repo, marker)
-                    beforepush = marker[0][0]
-                    afterpush = marker[0][1][0]
-                    ui.note('marking %s as obsoleted by %s\n' %
-                            (beforepush.hex(), afterpush.hex()))
-            else:
-                # strip the original changesets since the push was
-                # successful and changeset obsolescence is unavailable
-                util.strip(ui, repo, outgoing, "all")
+        with repo.wlock():
+            with repo.lock():
+                if hasobsolete:
+                    for marker in obsmarkers:
+                        obsolete.createmarkers(repo, marker)
+                        beforepush = marker[0][0]
+                        afterpush = marker[0][1][0]
+                        ui.note('marking %s as obsoleted by %s\n' %
+                                (beforepush.hex(), afterpush.hex()))
+                else:
+                    # strip the original changesets since the push was
+                    # successful and changeset obsolescence is unavailable
+                    util.strip(ui, repo, outgoing, "all")
     finally:
         try:
             # It's always safe to delete the temporary commits.
@@ -377,12 +378,15 @@ def push(repo, dest, force, revs):
                 parent = repo[None].p1()
                 if parent.node() in temporary_commits:
                     hg.update(repo, parent.p1().node())
-                with repo.lock():
-                    if hasobsolete:
-                        relations = ((repo[n], ()) for n in temporary_commits)
-                        obsolete.createmarkers(repo, relations)
-                    else:
-                        util.strip(ui, repo, temporary_commits, backup=None)
+                with repo.wlock():
+                    with repo.lock():
+                        if hasobsolete:
+                            relations = (
+                                (repo[n], ()) for n in temporary_commits)
+                            obsolete.createmarkers(repo, relations)
+                        else:
+                            util.strip(
+                                ui, repo, temporary_commits, backup=None)
 
         finally:
             util.swap_out_encoding(old_encoding)