annotate tests/test_push_autoprops.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 6aad12ea6d9f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
911
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
1 import subprocess
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
2 import sys
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
3 import unittest
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
4 import os
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
5
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
6 import test_util
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
7
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
8 from hgsubversion import svnwrap
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
9
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
10 class PushAutoPropsTests(test_util.TestBase):
1055
2d7398fffd0d push: obsolete rather than rebase & strip when enabled
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents: 1044
diff changeset
11 obsolete_mode_tests = True
2d7398fffd0d push: obsolete rather than rebase & strip when enabled
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents: 1044
diff changeset
12
911
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
13 def setUp(self):
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
14 test_util.TestBase.setUp(self)
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
15 repo, self.repo_path = self.load_and_fetch('emptyrepo.svndump')
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
16
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
17 def test_push_honors_svn_autoprops(self):
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
18 self.setup_svn_config(
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
19 "[miscellany]\n"
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
20 "enable-auto-props = yes\n"
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
21 "[auto-props]\n"
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
22 "*.py = test:prop=success\n")
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
23 changes = [('test.py', 'test.py', 'echo hallo')]
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
24 self.commitchanges(changes)
1070
6aad12ea6d9f test_push_autoprops: use stupid mode metaclass
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1055
diff changeset
25 self.pushrevisions()
911
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
26 prop_val = test_util.svnpropget(
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
27 self.repo_path, "trunk/test.py", 'test:prop')
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
28 self.assertEqual('success', prop_val)
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
29
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
30
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
31 class AutoPropsConfigTest(test_util.TestBase):
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
32 def test_use_autoprops_for_matching_file_when_enabled(self):
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
33 self.setup_svn_config(
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
34 "[miscellany]\n"
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
35 "enable-auto-props = yes\n"
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
36 "[auto-props]\n"
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
37 "*.py = test:prop=success\n")
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
38 props = self.new_autoprops_config().properties('xxx/test.py')
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
39 self.assertEqual({ 'test:prop': 'success'}, props)
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
40
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
41 def new_autoprops_config(self):
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
42 return svnwrap.AutoPropsConfig(self.config_dir)
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
43
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
44 def test_ignore_nonexisting_config(self):
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
45 config_file = os.path.join(self.config_dir, 'config')
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
46 os.remove(config_file)
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
47 self.assertTrue(not os.path.exists(config_file))
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
48 props = self.new_autoprops_config().properties('xxx/test.py')
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
49 self.assertEqual({}, props)
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
50
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
51 def test_ignore_autoprops_when_file_doesnt_match(self):
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
52 self.setup_svn_config(
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
53 "[miscellany]\n"
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
54 "enable-auto-props = yes\n"
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
55 "[auto-props]\n"
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
56 "*.py = test:prop=success\n")
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
57 props = self.new_autoprops_config().properties('xxx/test.sh')
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
58 self.assertEqual({}, props)
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
59
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
60 def test_ignore_autoprops_when_disabled(self):
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
61 self.setup_svn_config(
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
62 "[miscellany]\n"
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
63 "#enable-auto-props = yes\n"
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
64 "[auto-props]\n"
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
65 "*.py = test:prop=success\n")
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
66 props = self.new_autoprops_config().properties('xxx/test.py')
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
67 self.assertEqual({}, props)
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
68
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
69 def test_combine_properties_of_multiple_matches(self):
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
70 self.setup_svn_config(
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
71 "[miscellany]\n"
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
72 "enable-auto-props = yes\n"
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
73 "[auto-props]\n"
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
74 "*.py = test:prop=success\n"
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
75 "test.* = test:prop2=success\n")
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
76 props = self.new_autoprops_config().properties('xxx/test.py')
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
77 self.assertEqual({
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
78 'test:prop': 'success', 'test:prop2': 'success'}, props)
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
79
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
80
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
81 class ParseAutoPropsTests(test_util.TestBase):
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
82 def test_property_value_is_optional(self):
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
83 props = svnwrap.parse_autoprops("svn:executable")
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
84 self.assertEqual({'svn:executable': ''}, props)
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
85 props = svnwrap.parse_autoprops("svn:executable=")
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
86 self.assertEqual({'svn:executable': ''}, props)
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
87
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
88 def test_property_value_may_be_quoted(self):
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
89 props = svnwrap.parse_autoprops("svn:eol-style=\" native \"")
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
90 self.assertEqual({'svn:eol-style': ' native '}, props)
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
91 props = svnwrap.parse_autoprops("svn:eol-style=' native '")
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
92 self.assertEqual({'svn:eol-style': ' native '}, props)
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
93
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
94 def test_surrounding_whitespaces_are_ignored(self):
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
95 props = svnwrap.parse_autoprops(" svn:eol-style = native ")
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
96 self.assertEqual({'svn:eol-style': 'native'}, props)
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
97
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
98 def test_multiple_properties_are_separated_by_semicolon(self):
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
99 props = svnwrap.parse_autoprops(
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
100 "svn:eol-style=native;svn:executable=true\n")
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
101 self.assertEqual({
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
102 'svn:eol-style': 'native',
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
103 'svn:executable': 'true'},
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff changeset
104 props)