Mercurial > hgsubversion
annotate tests/comprehensive/test_stupid_pull.py @ 1233:0d0132cba155
editor: fix edge case with in memory file-store size limit
There are a few cases where we will set a single file into to the
editor's FileStore object more than once. Notably, for copied and
then modified files, we will set it at least twice. Three times if
editing fails (which it can for symlinks).
If we pass the in-memory storage limit in between the first (or second
if editing fails) time we set the file and the last time we set the
file, we will write the data to the in memory store the first time and
the file store the last time. We didn't remove it form the in-memory
store though, and we always prefer reading from the in-memory store.
This means we can sometimes end up with the wrong version of a file.
This is fairly unlikely to happen in normal use since you need to hit
the memory limit between two writes to the store for the same file.
We only write a file multiple times if a) the file (and not one of
it's parent directories) is copied and then modified or b) editing
fails. From what I can tell, it's only common for editing to fail for
symlinks, and they ten to be relatively small data that is unlikely to
push over the limit. Finally, the default limit is 100MB which I
would expect to be most often either well over (source code) or well
under (binaries or automated changes) the size of the changes files in
a single commit.
The easiest way to reproduce this is to set the in-memory cache size
to 0 and then commit a copied and modified symlink. The empty-string
version from the failed editing will be the one that persists. I
happened to stumble upon this while trying (and failing) to test a
bug-fix for a related bug with identical symptoms (empty simlink). I
have seen this in the wild, once, but couldn't reproduce it at the
time. The repo in question is quite large and quite active, so I am
quite confident in my estimation that this is a real, but very rare,
problem.
The test changes attached to this was mneant to test a related bug,
but turned out not to actually cover the bug in question. They did
trigger this bug though, and are worthwhile to test, so I kept them.
author | David Schleimer <dschleimer@fb.com> |
---|---|
date | Mon, 07 Apr 2014 17:51:59 -0700 |
parents | ff4e102932ed |
children | c6b01fd34694 |
rev | line source |
---|---|
194
13ae1bded5e7
Add some comprehensive tests that can be run with nose in order to make it easier to verify stupid and real replay do the same thing.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1 import os |
766
124cd25de4ef
tests: fix running the comprehensive tests using nose.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
613
diff
changeset
|
2 import sys |
194
13ae1bded5e7
Add some comprehensive tests that can be run with nose in order to make it easier to verify stupid and real replay do the same thing.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
3 import unittest |
13ae1bded5e7
Add some comprehensive tests that can be run with nose in order to make it easier to verify stupid and real replay do the same thing.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
4 |
13ae1bded5e7
Add some comprehensive tests that can be run with nose in order to make it easier to verify stupid and real replay do the same thing.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
5 from mercurial import hg |
13ae1bded5e7
Add some comprehensive tests that can be run with nose in order to make it easier to verify stupid and real replay do the same thing.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
6 from mercurial import ui |
13ae1bded5e7
Add some comprehensive tests that can be run with nose in order to make it easier to verify stupid and real replay do the same thing.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
7 |
613
58f397523604
testrunner: delay and `simplify' importing of tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
499
diff
changeset
|
8 # wrapped in a try/except because of weirdness in how |
58f397523604
testrunner: delay and `simplify' importing of tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
499
diff
changeset
|
9 # run.py works as compared to nose. |
58f397523604
testrunner: delay and `simplify' importing of tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
499
diff
changeset
|
10 try: |
58f397523604
testrunner: delay and `simplify' importing of tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
499
diff
changeset
|
11 import test_util |
58f397523604
testrunner: delay and `simplify' importing of tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
499
diff
changeset
|
12 except ImportError: |
766
124cd25de4ef
tests: fix running the comprehensive tests using nose.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
613
diff
changeset
|
13 sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) |
124cd25de4ef
tests: fix running the comprehensive tests using nose.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
613
diff
changeset
|
14 import test_util |
613
58f397523604
testrunner: delay and `simplify' importing of tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
499
diff
changeset
|
15 |
354
36d26e158748
comprehensive: fix for new repo layout.
Augie Fackler <durin42@gmail.com>
parents:
347
diff
changeset
|
16 from hgsubversion import wrappers |
194
13ae1bded5e7
Add some comprehensive tests that can be run with nose in order to make it easier to verify stupid and real replay do the same thing.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
17 |
13ae1bded5e7
Add some comprehensive tests that can be run with nose in order to make it easier to verify stupid and real replay do the same thing.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
18 |
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
445
diff
changeset
|
19 def _do_case(self, name, layout): |
194
13ae1bded5e7
Add some comprehensive tests that can be run with nose in order to make it easier to verify stupid and real replay do the same thing.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
20 subdir = test_util.subdir.get(name, '') |
1092
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1057
diff
changeset
|
21 config = {} |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1057
diff
changeset
|
22 u = ui.ui() |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1057
diff
changeset
|
23 for branch, path in test_util.custom.get(name, {}).iteritems(): |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1057
diff
changeset
|
24 config['hgsubversionbranch.%s' % branch] = path |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1057
diff
changeset
|
25 u.setconfig('hgsubversionbranch', branch, path) |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1057
diff
changeset
|
26 repo, repo_path = self.load_and_fetch(name, |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1057
diff
changeset
|
27 subdir=subdir, |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1057
diff
changeset
|
28 layout=layout, |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1057
diff
changeset
|
29 config=config) |
1048
903c9c9dfe6a
tests: count revisions explicitly
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1044
diff
changeset
|
30 assert test_util.repolen(self.repo) > 0, \ |
903c9c9dfe6a
tests: count revisions explicitly
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1044
diff
changeset
|
31 'Repo had no changes, maybe you need to add a subdir entry in test_util?' |
194
13ae1bded5e7
Add some comprehensive tests that can be run with nose in order to make it easier to verify stupid and real replay do the same thing.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
32 wc2_path = self.wc_path + '_stupid' |
867
50c13e01c7e3
test_util: add a load_and_fetch() returning the repo_path
Patrick Mezard <patrick@mezard.eu>
parents:
833
diff
changeset
|
33 checkout_path = repo_path |
194
13ae1bded5e7
Add some comprehensive tests that can be run with nose in order to make it easier to verify stupid and real replay do the same thing.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
34 if subdir: |
13ae1bded5e7
Add some comprehensive tests that can be run with nose in order to make it easier to verify stupid and real replay do the same thing.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
35 checkout_path += '/' + subdir |
347
537de0300510
Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
257
diff
changeset
|
36 u.setconfig('hgsubversion', 'stupid', '1') |
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
445
diff
changeset
|
37 u.setconfig('hgsubversion', 'layout', layout) |
816
86d124a8768e
Fix hg.clone() calls changed by d976542986d2
Patrick Mezard <pmezard@gmail.com>
parents:
766
diff
changeset
|
38 test_util.hgclone(u, test_util.fileurl(checkout_path), wc2_path, update=False) |
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
445
diff
changeset
|
39 if layout == 'single': |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
445
diff
changeset
|
40 self.assertEqual(len(self.repo.heads()), 1) |
194
13ae1bded5e7
Add some comprehensive tests that can be run with nose in order to make it easier to verify stupid and real replay do the same thing.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
41 self.repo2 = hg.repository(ui.ui(), wc2_path) |
445
24a8471069c0
tests: test for heads equality instead of branchtags
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
383
diff
changeset
|
42 self.assertEqual(self.repo.heads(), self.repo2.heads()) |
194
13ae1bded5e7
Add some comprehensive tests that can be run with nose in order to make it easier to verify stupid and real replay do the same thing.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
43 |
13ae1bded5e7
Add some comprehensive tests that can be run with nose in order to make it easier to verify stupid and real replay do the same thing.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
44 |
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
445
diff
changeset
|
45 def buildmethod(case, name, layout): |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
445
diff
changeset
|
46 m = lambda self: self._do_case(case, layout) |
194
13ae1bded5e7
Add some comprehensive tests that can be run with nose in order to make it easier to verify stupid and real replay do the same thing.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
47 m.__name__ = name |
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
445
diff
changeset
|
48 m.__doc__ = 'Test stupid produces same as real on %s. (%s)' % (case, layout) |
194
13ae1bded5e7
Add some comprehensive tests that can be run with nose in order to make it easier to verify stupid and real replay do the same thing.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
49 return m |
13ae1bded5e7
Add some comprehensive tests that can be run with nose in order to make it easier to verify stupid and real replay do the same thing.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
50 |
13ae1bded5e7
Add some comprehensive tests that can be run with nose in order to make it easier to verify stupid and real replay do the same thing.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
51 attrs = {'_do_case': _do_case, |
13ae1bded5e7
Add some comprehensive tests that can be run with nose in order to make it easier to verify stupid and real replay do the same thing.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
52 } |
13ae1bded5e7
Add some comprehensive tests that can be run with nose in order to make it easier to verify stupid and real replay do the same thing.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
53 for case in (f for f in os.listdir(test_util.FIXTURES) if f.endswith('.svndump')): |
892
3bfb7e985c47
svn verify: add a test for corrupt repositories.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
867
diff
changeset
|
54 if case == 'corrupt.svndump': |
3bfb7e985c47
svn verify: add a test for corrupt repositories.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
867
diff
changeset
|
55 continue |
902
7d9cd708f412
tests: fix automatically generated test names
Bryan O'Sullivan <bryano@fb.com>
parents:
892
diff
changeset
|
56 name = 'test_' + case[:-len('.svndump')].replace('-', '_') |
821
f28e0f54a6ef
svnmeta: store youngest revision pulled from subversion
Augie Fackler <durin42@gmail.com>
parents:
816
diff
changeset
|
57 # Automatic layout branchtag collision exposes a minor defect |
f28e0f54a6ef
svnmeta: store youngest revision pulled from subversion
Augie Fackler <durin42@gmail.com>
parents:
816
diff
changeset
|
58 # here, but since it isn't a regression we suppress the test case. |
f28e0f54a6ef
svnmeta: store youngest revision pulled from subversion
Augie Fackler <durin42@gmail.com>
parents:
816
diff
changeset
|
59 if case != 'branchtagcollision.svndump': |
f28e0f54a6ef
svnmeta: store youngest revision pulled from subversion
Augie Fackler <durin42@gmail.com>
parents:
816
diff
changeset
|
60 attrs[name] = buildmethod(case, name, 'auto') |
1092
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1057
diff
changeset
|
61 attrs[name + '_single'] = buildmethod(case, name + '_single', 'single') |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1057
diff
changeset
|
62 if case in test_util.custom: |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1057
diff
changeset
|
63 attrs[name + '_custom'] = buildmethod(case, name + '_custom', 'custom') |
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
445
diff
changeset
|
64 |
832
e9af7eba88db
globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents:
821
diff
changeset
|
65 StupidPullTests = type('StupidPullTests', (test_util.TestBase,), attrs) |