annotate tests/test_unaffected_core.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 69c0e7c4faf9
children f07bfd66db13
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
713
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
1 import test_util
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
2
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
3 import os
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
4 import unittest
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
5
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
6 from mercurial import commands
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
7 from mercurial import dispatch
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
8 from mercurial import error
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
9 from mercurial import hg
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
10 from mercurial import node
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
11 from mercurial import ui
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
12
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
13 class TestMercurialCore(test_util.TestBase):
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
14 '''
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
15 Test that the core Mercurial operations aren't broken by hgsubversion.
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
16 '''
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
17
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
18 @test_util.requiresoption('updaterev')
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
19 def test_update(self):
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
20 ''' Test 'clone --updaterev' '''
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
21 ui = self.ui()
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
22 dispatch._dispatch(ui, ['init', self.wc_path])
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
23 repo = self.repo
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
24 repo.ui.setconfig('ui', 'username', 'anonymous')
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
25
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
26 fpath = os.path.join(self.wc_path, 'it')
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
27 f = file(fpath, 'w')
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
28 f.write('C1')
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
29 f.flush()
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
30 commands.add(ui, repo)
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
31 commands.commit(ui, repo, message="C1")
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
32 f.write('C2')
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
33 f.flush()
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
34 commands.commit(ui, repo, message="C2")
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
35 f.write('C3')
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
36 f.flush()
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
37 commands.commit(ui, repo, message="C3")
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
38
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
39 self.assertEqual(len(repo), 3)
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
40
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
41 updaterev = 1
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
42 dispatch._dispatch(ui, ['clone', self.wc_path, self.wc_path + '2',
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
43 '--updaterev=%s' % updaterev])
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
44
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
45 repo2 = hg.repository(ui, self.wc_path + '2')
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
46
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
47 self.assertEqual(str(repo[updaterev]), str(repo2['.']))
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
48
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
49 @test_util.requiresoption('branch')
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
50 def test_branch(self):
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
51 ''' Test 'clone --branch' '''
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
52 ui = self.ui()
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
53 dispatch._dispatch(ui, ['init', self.wc_path])
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
54 repo = self.repo
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
55 repo.ui.setconfig('ui', 'username', 'anonymous')
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
56
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
57 fpath = os.path.join(self.wc_path, 'it')
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
58 f = file(fpath, 'w')
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
59 f.write('C1')
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
60 f.flush()
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
61 commands.add(ui, repo)
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
62 commands.branch(ui, repo, label="B1")
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
63 commands.commit(ui, repo, message="C1")
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
64 f.write('C2')
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
65 f.flush()
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
66 commands.branch(ui, repo, label="default")
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
67 commands.commit(ui, repo, message="C2")
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
68 f.write('C3')
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
69 f.flush()
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
70 commands.branch(ui, repo, label="B2")
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
71 commands.commit(ui, repo, message="C3")
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
72
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
73 self.assertEqual(len(repo), 3)
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
74
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
75 branch = 'B1'
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
76 dispatch._dispatch(ui, ['clone', self.wc_path, self.wc_path + '2',
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
77 '--branch', branch])
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
78
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
79 repo2 = hg.repository(ui, self.wc_path + '2')
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
80
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
81 self.assertEqual(repo[branch].hex(), repo2['.'].hex())
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
82
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
83 def suite():
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
84 all = [unittest.TestLoader().loadTestsFromTestCase(TestMercurialCore)]
69c0e7c4faf9 clone: call the wrapped function (fixes #181)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
diff changeset
85 return unittest.TestSuite(all)