Show More
@@ -1441,7 +1441,8 b' def unbundle(repo, cg, heads, source, ur' | |||||
1441 | If the push was raced as PushRaced exception is raised.""" |
|
1441 | If the push was raced as PushRaced exception is raised.""" | |
1442 | r = 0 |
|
1442 | r = 0 | |
1443 | # need a transaction when processing a bundle2 stream |
|
1443 | # need a transaction when processing a bundle2 stream | |
1444 | wlock = lock = tr = None |
|
1444 | # [wlock, lock, tr] - needs to be an array so nested functions can modify it | |
|
1445 | lockandtr = [None, None, None] | |||
1445 | recordout = None |
|
1446 | recordout = None | |
1446 | # quick fix for output mismatch with bundle2 in 3.4 |
|
1447 | # quick fix for output mismatch with bundle2 in 3.4 | |
1447 | captureoutput = repo.ui.configbool('experimental', 'bundle2-output-capture', |
|
1448 | captureoutput = repo.ui.configbool('experimental', 'bundle2-output-capture', | |
@@ -1454,13 +1455,22 b' def unbundle(repo, cg, heads, source, ur' | |||||
1454 | if util.safehasattr(cg, 'params'): |
|
1455 | if util.safehasattr(cg, 'params'): | |
1455 | r = None |
|
1456 | r = None | |
1456 | try: |
|
1457 | try: | |
1457 | wlock = repo.wlock() |
|
1458 | def gettransaction(): | |
1458 | lock = repo.lock() |
|
1459 | if not lockandtr[2]: | |
1459 |
tr = repo. |
|
1460 | lockandtr[0] = repo.wlock() | |
1460 | tr.hookargs['source'] = source |
|
1461 | lockandtr[1] = repo.lock() | |
1461 | tr.hookargs['url'] = url |
|
1462 | lockandtr[2] = repo.transaction(source) | |
1462 |
tr.hookargs[' |
|
1463 | lockandtr[2].hookargs['source'] = source | |
1463 | op = bundle2.bundleoperation(repo, lambda: tr, |
|
1464 | lockandtr[2].hookargs['url'] = url | |
|
1465 | lockandtr[2].hookargs['bundle2'] = '1' | |||
|
1466 | return lockandtr[2] | |||
|
1467 | ||||
|
1468 | # Do greedy locking by default until we're satisfied with lazy | |||
|
1469 | # locking. | |||
|
1470 | if not repo.ui.configbool('experimental', 'bundle2lazylocking'): | |||
|
1471 | gettransaction() | |||
|
1472 | ||||
|
1473 | op = bundle2.bundleoperation(repo, gettransaction, | |||
1464 | captureoutput=captureoutput) |
|
1474 | captureoutput=captureoutput) | |
1465 | try: |
|
1475 | try: | |
1466 | op = bundle2.processbundle(repo, cg, op=op) |
|
1476 | op = bundle2.processbundle(repo, cg, op=op) | |
@@ -1470,7 +1480,8 b' def unbundle(repo, cg, heads, source, ur' | |||||
1470 | repo.ui.pushbuffer(error=True, subproc=True) |
|
1480 | repo.ui.pushbuffer(error=True, subproc=True) | |
1471 | def recordout(output): |
|
1481 | def recordout(output): | |
1472 | r.newpart('output', data=output, mandatory=False) |
|
1482 | r.newpart('output', data=output, mandatory=False) | |
1473 | tr.close() |
|
1483 | if lockandtr[2] is not None: | |
|
1484 | lockandtr[2].close() | |||
1474 | except BaseException as exc: |
|
1485 | except BaseException as exc: | |
1475 | exc.duringunbundle2 = True |
|
1486 | exc.duringunbundle2 = True | |
1476 | if captureoutput and r is not None: |
|
1487 | if captureoutput and r is not None: | |
@@ -1481,10 +1492,10 b' def unbundle(repo, cg, heads, source, ur' | |||||
1481 | parts.append(part) |
|
1492 | parts.append(part) | |
1482 | raise |
|
1493 | raise | |
1483 | else: |
|
1494 | else: | |
1484 | lock = repo.lock() |
|
1495 | lockandtr[1] = repo.lock() | |
1485 | r = changegroup.addchangegroup(repo, cg, source, url) |
|
1496 | r = changegroup.addchangegroup(repo, cg, source, url) | |
1486 | finally: |
|
1497 | finally: | |
1487 |
lockmod.release(tr, lock, |
|
1498 | lockmod.release(lockandtr[2], lockandtr[1], lockandtr[0]) | |
1488 | if recordout is not None: |
|
1499 | if recordout is not None: | |
1489 | recordout(repo.ui.popbuffer()) |
|
1500 | recordout(repo.ui.popbuffer()) | |
1490 | return r |
|
1501 | return r |
@@ -7,6 +7,7 b' Test exchange of common information usin' | |||||
7 |
|
7 | |||
8 | enable obsolescence |
|
8 | enable obsolescence | |
9 |
|
9 | |||
|
10 | $ cp $HGRCPATH $TESTTMP/hgrc.orig | |||
10 | $ cat > $TESTTMP/bundle2-pushkey-hook.sh << EOF |
|
11 | $ cat > $TESTTMP/bundle2-pushkey-hook.sh << EOF | |
11 | > echo pushkey: lock state after \"\$HG_NAMESPACE\" |
|
12 | > echo pushkey: lock state after \"\$HG_NAMESPACE\" | |
12 | > hg debuglock |
|
13 | > hg debuglock | |
@@ -897,3 +898,47 b' Check abort from mandatory pushkey' | |||||
897 | abort: Clown phase push failed |
|
898 | abort: Clown phase push failed | |
898 | [255] |
|
899 | [255] | |
899 |
|
900 | |||
|
901 | Test lazily acquiring the lock during unbundle | |||
|
902 | $ cp $TESTTMP/hgrc.orig $HGRCPATH | |||
|
903 | $ cat >> $HGRCPATH <<EOF | |||
|
904 | > [ui] | |||
|
905 | > ssh=python "$TESTDIR/dummyssh" | |||
|
906 | > EOF | |||
|
907 | ||||
|
908 | $ cat >> $TESTTMP/locktester.py <<EOF | |||
|
909 | > import os | |||
|
910 | > from mercurial import extensions, bundle2, util | |||
|
911 | > def checklock(orig, repo, *args, **kwargs): | |||
|
912 | > if repo.svfs.lexists("lock"): | |||
|
913 | > raise util.Abort("Lock should not be taken") | |||
|
914 | > return orig(repo, *args, **kwargs) | |||
|
915 | > def extsetup(ui): | |||
|
916 | > extensions.wrapfunction(bundle2, 'processbundle', checklock) | |||
|
917 | > EOF | |||
|
918 | ||||
|
919 | $ hg init lazylock | |||
|
920 | $ cat >> lazylock/.hg/hgrc <<EOF | |||
|
921 | > [extensions] | |||
|
922 | > locktester=$TESTTMP/locktester.py | |||
|
923 | > EOF | |||
|
924 | ||||
|
925 | $ hg clone -q ssh://user@dummy/lazylock lazylockclient | |||
|
926 | $ cd lazylockclient | |||
|
927 | $ touch a && hg ci -Aqm a | |||
|
928 | $ hg push | |||
|
929 | pushing to ssh://user@dummy/lazylock | |||
|
930 | searching for changes | |||
|
931 | abort: Lock should not be taken | |||
|
932 | [255] | |||
|
933 | ||||
|
934 | $ cat >> ../lazylock/.hg/hgrc <<EOF | |||
|
935 | > [experimental] | |||
|
936 | > bundle2lazylocking=True | |||
|
937 | > EOF | |||
|
938 | $ hg push | |||
|
939 | pushing to ssh://user@dummy/lazylock | |||
|
940 | searching for changes | |||
|
941 | remote: adding changesets | |||
|
942 | remote: adding manifests | |||
|
943 | remote: adding file changes | |||
|
944 | remote: added 1 changesets with 1 changes to 1 files |
General Comments 0
You need to be logged in to leave comments.
Login now