annotate tests/test_fetch_symlinks.py @ 717:ae5968ffe6fe

svnwrap: fix handling of quotable URLs (fixes #197, refs #132) The way hgsubversion handles URLs that may or may not be quoted is somewhat fragile. As part of fixing issue 132 in 925ff8c5989c, the path component of URLs was always quoted. The URL has been attempted encoded since the initial check-in. The fix from 925ff8c5989c was incomplete; reverting it allows us to clone a URL with a '~' in it.[1] Encoding the URL as UTF-8 seldom works as expected, as the default string encoding is ASCII, causing Python to be unable to decode any URL containing an 8-bit character. The core problem here is that we don't know whether the URL specified by the user is quoted or not. Rather than trying to deal with this ourselves, we pass the problem on to Subversion. Then, we obtain the URL from the RA instance, where it is always quoted. (It's worth noting that the editor interface, on the other hand, always deals with unquoted paths...) Thus, the following invariants should apply to SubversionRepo attributes: - svn_url and root will always be quoted. - subdir will always be unquoted. Tests are added that verify that it won't affect the conversion whether a URL is specified in quoted or unquoted form. Furthermore, a test fixture for this is added *twice*, so that we can thoroughly test both quoted and unquoted URLs. I'm not adding a test dedicated to tildes in URLs; it doesn't seem necessary. [1] Such as <https://svn.kenai.com/svn/winsw~subversion>.
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Mon, 04 Oct 2010 21:00:36 -0500
parents d2ef7220a079
children b3128fec5d54
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
97
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
1 import test_util
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
2
643
d2ef7220a079 tests: import test_util as the first module in all relevant tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 145
diff changeset
3 import unittest
97
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
4
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
5 class TestFetchSymlinks(test_util.TestBase):
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
6 def _load_fixture_and_fetch(self, fixture_name, stupid):
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
7 return test_util.load_fixture_and_fetch(fixture_name, self.repo_path,
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
8 self.wc_path, stupid=stupid)
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
9
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
10 def test_symlinks(self, stupid=False):
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
11 repo = self._load_fixture_and_fetch('symlinks.svndump', stupid)
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
12 # Check no symlink contains the 'link ' prefix
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
13 for rev in repo:
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
14 r = repo[rev]
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
15 for f in r.manifest():
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
16 if 'l' not in r[f].flags():
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
17 continue
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
18 self.assertFalse(r[f].data().startswith('link '))
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
19 # Check symlinks in tip
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
20 links = {
126
24a64fb0e74b run.py: register and develop test_fetch_symlinks
Patrick Mezard <pmezard@gmail.com>
parents: 101
diff changeset
21 0: {
24a64fb0e74b run.py: register and develop test_fetch_symlinks
Patrick Mezard <pmezard@gmail.com>
parents: 101
diff changeset
22 'linka': 'a',
145
b37c401b7f92 hg_delta_editor: reset properties of deleted entries
Patrick Mezard <pmezard@gmail.com>
parents: 126
diff changeset
23 'linka2': 'a',
126
24a64fb0e74b run.py: register and develop test_fetch_symlinks
Patrick Mezard <pmezard@gmail.com>
parents: 101
diff changeset
24 'd/linka': 'a',
24a64fb0e74b run.py: register and develop test_fetch_symlinks
Patrick Mezard <pmezard@gmail.com>
parents: 101
diff changeset
25 },
24a64fb0e74b run.py: register and develop test_fetch_symlinks
Patrick Mezard <pmezard@gmail.com>
parents: 101
diff changeset
26 1: {
24a64fb0e74b run.py: register and develop test_fetch_symlinks
Patrick Mezard <pmezard@gmail.com>
parents: 101
diff changeset
27 'linkaa': 'a',
145
b37c401b7f92 hg_delta_editor: reset properties of deleted entries
Patrick Mezard <pmezard@gmail.com>
parents: 126
diff changeset
28 'linka2': 'a',
126
24a64fb0e74b run.py: register and develop test_fetch_symlinks
Patrick Mezard <pmezard@gmail.com>
parents: 101
diff changeset
29 'd2/linka': 'a',
24a64fb0e74b run.py: register and develop test_fetch_symlinks
Patrick Mezard <pmezard@gmail.com>
parents: 101
diff changeset
30 },
24a64fb0e74b run.py: register and develop test_fetch_symlinks
Patrick Mezard <pmezard@gmail.com>
parents: 101
diff changeset
31 2: {
24a64fb0e74b run.py: register and develop test_fetch_symlinks
Patrick Mezard <pmezard@gmail.com>
parents: 101
diff changeset
32 'linkaa': 'b',
145
b37c401b7f92 hg_delta_editor: reset properties of deleted entries
Patrick Mezard <pmezard@gmail.com>
parents: 126
diff changeset
33 'linka2': 'a',
126
24a64fb0e74b run.py: register and develop test_fetch_symlinks
Patrick Mezard <pmezard@gmail.com>
parents: 101
diff changeset
34 'd2/linka': 'b',
24a64fb0e74b run.py: register and develop test_fetch_symlinks
Patrick Mezard <pmezard@gmail.com>
parents: 101
diff changeset
35 },
24a64fb0e74b run.py: register and develop test_fetch_symlinks
Patrick Mezard <pmezard@gmail.com>
parents: 101
diff changeset
36 3: {
24a64fb0e74b run.py: register and develop test_fetch_symlinks
Patrick Mezard <pmezard@gmail.com>
parents: 101
diff changeset
37 },
97
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
38 }
126
24a64fb0e74b run.py: register and develop test_fetch_symlinks
Patrick Mezard <pmezard@gmail.com>
parents: 101
diff changeset
39
24a64fb0e74b run.py: register and develop test_fetch_symlinks
Patrick Mezard <pmezard@gmail.com>
parents: 101
diff changeset
40 for rev in repo:
24a64fb0e74b run.py: register and develop test_fetch_symlinks
Patrick Mezard <pmezard@gmail.com>
parents: 101
diff changeset
41 ctx = repo[rev]
24a64fb0e74b run.py: register and develop test_fetch_symlinks
Patrick Mezard <pmezard@gmail.com>
parents: 101
diff changeset
42 for f in ctx.manifest():
24a64fb0e74b run.py: register and develop test_fetch_symlinks
Patrick Mezard <pmezard@gmail.com>
parents: 101
diff changeset
43 self.assertEqual(f in links[rev], 'l' in ctx[f].flags())
24a64fb0e74b run.py: register and develop test_fetch_symlinks
Patrick Mezard <pmezard@gmail.com>
parents: 101
diff changeset
44 if f in links[rev]:
24a64fb0e74b run.py: register and develop test_fetch_symlinks
Patrick Mezard <pmezard@gmail.com>
parents: 101
diff changeset
45 self.assertEqual(links[rev][f], ctx[f].data())
24a64fb0e74b run.py: register and develop test_fetch_symlinks
Patrick Mezard <pmezard@gmail.com>
parents: 101
diff changeset
46 for f in links[rev]:
24a64fb0e74b run.py: register and develop test_fetch_symlinks
Patrick Mezard <pmezard@gmail.com>
parents: 101
diff changeset
47 self.assertTrue(f in ctx)
97
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
48
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
49 def test_symlinks_stupid(self):
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
50 self.test_symlinks(True)
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
51
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
52 def suite():
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
53 all = [unittest.TestLoader().loadTestsFromTestCase(TestFetchSymlinks),
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
54 ]
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
55 return unittest.TestSuite(all)