Mercurial > hgsubversion
changeset 1516:fbc22592f4fa
push: lock repo before calling createmarkers
Previously, when devel.all-warnings is set to True, hg subversion will crash
when pushing with the error:
ProgrammingError: transaction requires locking
Tracking that down, that is because "createmarkers" was called without
locking.
A comprehensive test was added to run test_push_command with obsstore turned
on to cover the code paths.
author | Jun Wu <quark@fb.com> |
---|---|
date | Mon, 07 Aug 2017 18:12:16 -0700 |
parents | 106716ed2ed0 |
children | b3e41b0d50a2 |
files | hgsubversion/wrappers.py tests/comprehensive/test_obsstore_on.py |
diffstat | 2 files changed, 58 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/hgsubversion/wrappers.py +++ b/hgsubversion/wrappers.py @@ -351,17 +351,18 @@ def push(repo, dest, force, revs): finally: util.swap_out_encoding() - 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.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. @@ -373,11 +374,12 @@ def push(repo, dest, force, revs): parent = repo[None].p1() if parent.node() in temporary_commits: hg.update(repo, parent.p1().node()) - 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.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)
new file mode 100644 --- /dev/null +++ b/tests/comprehensive/test_obsstore_on.py @@ -0,0 +1,40 @@ +import os +import sys + +# wrapped in a try/except because of weirdness in how +# run.py works as compared to nose. +try: + import test_util +except ImportError: + sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) + import test_util + +import test_push_command + + +class ObsstoreOnMixIn(object): + # do not double the test size by being wrapped again + obsolete_mode_tests = False + stupid_mode_tests = False + + def setUp(self): + super(ObsstoreOnMixIn, self).setUp() + hgrcpath = os.environ.get('HGRCPATH') + assert hgrcpath + with open(hgrcpath, 'a') as f: + f.write('\n[experimental]\nevolution=createmarkers\n') + + def shortDescription(self): + text = super(ObsstoreOnMixIn, self).shortDescription() + if text: + text += ' (obsstore on)' + return text + + +def buildtestclass(cls): + name = 'ObsstoreOn%s' % cls.__name__ + newcls = type(name, (ObsstoreOnMixIn, cls,), {}) + globals()[name] = newcls + + +buildtestclass(test_push_command.PushTests)