Mercurial > hgsubversion
annotate tests/test_push_autoprops.py @ 991:26e9fd21f3bf
push: avoid rebasing when we know there are no conflicts
When pushing multiple commits, push would do one rebase
per commit. This changes it track the files that have been
changed as part of the push and only perform a rebase if
the commit touches a file that has been changed previously.
On our repo, push used to take 25 seconds per commit. With
this change it takes closer to 10 seconds per commit (if
there are no conflicts).
author | Durham Goode <durham@fb.com> |
---|---|
date | Wed, 02 Jan 2013 17:54:30 -0800 |
parents | 772280aed751 |
children | d741f536f23a |
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): |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
11 def setUp(self): |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
12 test_util.TestBase.setUp(self) |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
13 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
|
14 |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
15 def test_push_honors_svn_autoprops(self): |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
16 self.setup_svn_config( |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
17 "[miscellany]\n" |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
18 "enable-auto-props = yes\n" |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
19 "[auto-props]\n" |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
20 "*.py = test:prop=success\n") |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
21 changes = [('test.py', 'test.py', 'echo hallo')] |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
22 self.commitchanges(changes) |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
23 self.pushrevisions(True) |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
24 prop_val = test_util.svnpropget( |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
25 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
|
26 self.assertEqual('success', prop_val) |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
27 |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
28 |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
29 class AutoPropsConfigTest(test_util.TestBase): |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
30 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
|
31 self.setup_svn_config( |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
32 "[miscellany]\n" |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
33 "enable-auto-props = yes\n" |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
34 "[auto-props]\n" |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
35 "*.py = test:prop=success\n") |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
36 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
|
37 self.assertEqual({ 'test:prop': 'success'}, props) |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
38 |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
39 def new_autoprops_config(self): |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
40 return svnwrap.AutoPropsConfig(self.config_dir) |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
41 |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
42 def test_ignore_nonexisting_config(self): |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
43 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
|
44 os.remove(config_file) |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
45 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
|
46 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
|
47 self.assertEqual({}, props) |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
48 |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
49 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
|
50 self.setup_svn_config( |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
51 "[miscellany]\n" |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
52 "enable-auto-props = yes\n" |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
53 "[auto-props]\n" |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
54 "*.py = test:prop=success\n") |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
55 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
|
56 self.assertEqual({}, props) |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
57 |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
58 def test_ignore_autoprops_when_disabled(self): |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
59 self.setup_svn_config( |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
60 "[miscellany]\n" |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
61 "#enable-auto-props = yes\n" |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
62 "[auto-props]\n" |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
63 "*.py = test:prop=success\n") |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
64 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
|
65 self.assertEqual({}, props) |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
66 |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
67 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
|
68 self.setup_svn_config( |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
69 "[miscellany]\n" |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
70 "enable-auto-props = yes\n" |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
71 "[auto-props]\n" |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
72 "*.py = test:prop=success\n" |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
73 "test.* = test:prop2=success\n") |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
74 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
|
75 self.assertEqual({ |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
76 'test:prop': 'success', 'test:prop2': 'success'}, props) |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
77 |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
78 |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
79 class ParseAutoPropsTests(test_util.TestBase): |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
80 def test_property_value_is_optional(self): |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
81 props = svnwrap.parse_autoprops("svn:executable") |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
82 self.assertEqual({'svn:executable': ''}, props) |
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 |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
86 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
|
87 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
|
88 self.assertEqual({'svn:eol-style': ' native '}, props) |
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 |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
92 def test_surrounding_whitespaces_are_ignored(self): |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
93 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
|
94 self.assertEqual({'svn:eol-style': 'native'}, props) |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
95 |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
96 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
|
97 props = svnwrap.parse_autoprops( |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
98 "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
|
99 self.assertEqual({ |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
100 'svn:eol-style': 'native', |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
101 'svn:executable': 'true'}, |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
102 props) |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
103 |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
104 |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
105 def suite(): |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
106 return unittest.findTestCases(sys.modules[__name__]) |
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
diff
changeset
|
107 |