Mercurial > hgsubversion
annotate tests/test_utility_commands.py @ 155:ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
hg_delta_editor: Fixed some longstanding branch_info bugs detected while
rebuilding meta.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Tue, 23 Dec 2008 22:19:26 -0600 |
parents | 46f6b872c988 |
children | 91541523ea5c |
rev | line source |
---|---|
149
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
1 import os |
153
46f6b872c988
tests: Fix some missing suite definitions so that running the full testsuite
Augie Fackler <durin42@gmail.com>
parents:
149
diff
changeset
|
2 import unittest |
139
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
3 import urllib # for url quoting |
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
4 |
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
5 from mercurial import ui |
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
6 from mercurial import hg |
149
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
7 from mercurial import revlog |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
8 from mercurial import context |
139
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
9 |
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
10 import utility_commands |
140
9ffde8662967
util: Add a command to normalize svn urls and use it in a couple of places. Test that it works and prevents failed assertions.
Augie Fackler <durin42@gmail.com>
parents:
139
diff
changeset
|
11 import fetch_command |
139
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
12 import test_util |
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
13 |
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
14 expected_info_output = '''URL: file://%(repo)s/%(branch)s |
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
15 Repository Root: None |
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
16 Repository UUID: df2126f7-00ab-4d49-b42c-7e981dde0bcf |
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
17 Revision: %(rev)s |
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
18 Node Kind: directory |
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
19 Last Changed Author: durin |
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
20 Last Changed Rev: %(rev)s |
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
21 Last Changed Date: %(date)s |
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
22 ''' |
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
23 |
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
24 class UtilityTests(test_util.TestBase): |
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
25 def test_info_output(self): |
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
26 self._load_fixture_and_fetch('two_heads.svndump') |
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
27 hg.update(self.repo, 'the_branch') |
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
28 u = ui.ui() |
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
29 utility_commands.run_svn_info(u, self.repo, self.wc_path) |
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
30 expected = (expected_info_output % |
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
31 {'date': '2008-10-08 01:39:05 +0000 (Wed, 08 Oct 2008)', |
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
32 'repo': urllib.quote(self.repo_path), |
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
33 'branch': 'branches/the_branch', |
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
34 'rev': 5, |
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
35 }) |
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
36 self.assertEqual(u.stream.getvalue(), expected) |
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
37 hg.update(self.repo, 'default') |
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
38 u = ui.ui() |
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
39 utility_commands.run_svn_info(u, self.repo, self.wc_path) |
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
40 expected = (expected_info_output % |
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
41 {'date': '2008-10-08 01:39:29 +0000 (Wed, 08 Oct 2008)', |
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
42 'repo': urllib.quote(self.repo_path), |
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
43 'branch': 'trunk', |
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
44 'rev': 6, |
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
45 }) |
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
46 self.assertEqual(u.stream.getvalue(), expected) |
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
47 |
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
48 def test_url_output(self): |
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
49 self._load_fixture_and_fetch('two_revs.svndump') |
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
50 hg.update(self.repo, 'tip') |
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
51 u = ui.ui() |
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
52 utility_commands.print_wc_url(u, self.repo, self.wc_path) |
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
53 expected = 'file://%s\n' % urllib.quote(self.repo_path) |
89a737852d33
utility_commands: Add tests for url and info. Fix a bad mock in the process.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
54 self.assertEqual(u.stream.getvalue(), expected) |
140
9ffde8662967
util: Add a command to normalize svn urls and use it in a couple of places. Test that it works and prevents failed assertions.
Augie Fackler <durin42@gmail.com>
parents:
139
diff
changeset
|
55 |
149
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
56 def test_rebase(self): |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
57 self._load_fixture_and_fetch('two_revs.svndump') |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
58 parents = (self.repo[0].node(), revlog.nullid, ) |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
59 def filectxfn(repo, memctx, path): |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
60 return context.memfilectx(path=path, |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
61 data='added', |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
62 islink=False, |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
63 isexec=False, |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
64 copied=False) |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
65 ctx = context.memctx(self.repo, |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
66 parents, |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
67 'automated test', |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
68 ['added_bogus_file', 'other_added_file', ], |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
69 filectxfn, |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
70 'testy', |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
71 '2008-12-21 16:32:00 -0500', |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
72 {'branch': 'localbranch', }) |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
73 self.repo.commitctx(ctx) |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
74 self.assertEqual(self.repo['tip'].branch(), 'localbranch') |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
75 beforerebasehash = self.repo['tip'].node() |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
76 hg.update(self.repo, 'tip') |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
77 utility_commands.rebase_commits(ui.ui(), self.repo, os.path.dirname(self.repo.path)) |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
78 self.assertEqual(self.repo['tip'].branch(), 'localbranch') |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
79 self.assertEqual(self.repo['tip'].parents()[0].parents()[0], self.repo[0]) |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
80 self.assertNotEqual(beforerebasehash, self.repo['tip'].node()) |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
81 |
140
9ffde8662967
util: Add a command to normalize svn urls and use it in a couple of places. Test that it works and prevents failed assertions.
Augie Fackler <durin42@gmail.com>
parents:
139
diff
changeset
|
82 def test_url_is_normalized(self): |
9ffde8662967
util: Add a command to normalize svn urls and use it in a couple of places. Test that it works and prevents failed assertions.
Augie Fackler <durin42@gmail.com>
parents:
139
diff
changeset
|
83 """Verify url gets normalized on initial clone. |
9ffde8662967
util: Add a command to normalize svn urls and use it in a couple of places. Test that it works and prevents failed assertions.
Augie Fackler <durin42@gmail.com>
parents:
139
diff
changeset
|
84 """ |
9ffde8662967
util: Add a command to normalize svn urls and use it in a couple of places. Test that it works and prevents failed assertions.
Augie Fackler <durin42@gmail.com>
parents:
139
diff
changeset
|
85 test_util.load_svndump_fixture(self.repo_path, 'two_revs.svndump') |
9ffde8662967
util: Add a command to normalize svn urls and use it in a couple of places. Test that it works and prevents failed assertions.
Augie Fackler <durin42@gmail.com>
parents:
139
diff
changeset
|
86 fetch_command.fetch_revisions(ui.ui(), |
9ffde8662967
util: Add a command to normalize svn urls and use it in a couple of places. Test that it works and prevents failed assertions.
Augie Fackler <durin42@gmail.com>
parents:
139
diff
changeset
|
87 svn_url=test_util.fileurl(self.repo_path)+'/', |
9ffde8662967
util: Add a command to normalize svn urls and use it in a couple of places. Test that it works and prevents failed assertions.
Augie Fackler <durin42@gmail.com>
parents:
139
diff
changeset
|
88 hg_repo_path=self.wc_path, |
9ffde8662967
util: Add a command to normalize svn urls and use it in a couple of places. Test that it works and prevents failed assertions.
Augie Fackler <durin42@gmail.com>
parents:
139
diff
changeset
|
89 stupid=False) |
9ffde8662967
util: Add a command to normalize svn urls and use it in a couple of places. Test that it works and prevents failed assertions.
Augie Fackler <durin42@gmail.com>
parents:
139
diff
changeset
|
90 hg.update(self.repo, 'tip') |
9ffde8662967
util: Add a command to normalize svn urls and use it in a couple of places. Test that it works and prevents failed assertions.
Augie Fackler <durin42@gmail.com>
parents:
139
diff
changeset
|
91 u = ui.ui() |
9ffde8662967
util: Add a command to normalize svn urls and use it in a couple of places. Test that it works and prevents failed assertions.
Augie Fackler <durin42@gmail.com>
parents:
139
diff
changeset
|
92 utility_commands.print_wc_url(u, self.repo, self.wc_path) |
9ffde8662967
util: Add a command to normalize svn urls and use it in a couple of places. Test that it works and prevents failed assertions.
Augie Fackler <durin42@gmail.com>
parents:
139
diff
changeset
|
93 expected = 'file://%s\n' % urllib.quote(self.repo_path) |
9ffde8662967
util: Add a command to normalize svn urls and use it in a couple of places. Test that it works and prevents failed assertions.
Augie Fackler <durin42@gmail.com>
parents:
139
diff
changeset
|
94 self.assertEqual(u.stream.getvalue(), expected) |
153
46f6b872c988
tests: Fix some missing suite definitions so that running the full testsuite
Augie Fackler <durin42@gmail.com>
parents:
149
diff
changeset
|
95 |
46f6b872c988
tests: Fix some missing suite definitions so that running the full testsuite
Augie Fackler <durin42@gmail.com>
parents:
149
diff
changeset
|
96 |
46f6b872c988
tests: Fix some missing suite definitions so that running the full testsuite
Augie Fackler <durin42@gmail.com>
parents:
149
diff
changeset
|
97 def suite(): |
46f6b872c988
tests: Fix some missing suite definitions so that running the full testsuite
Augie Fackler <durin42@gmail.com>
parents:
149
diff
changeset
|
98 all = [unittest.TestLoader().loadTestsFromTestCase(UtilityTests), |
46f6b872c988
tests: Fix some missing suite definitions so that running the full testsuite
Augie Fackler <durin42@gmail.com>
parents:
149
diff
changeset
|
99 ] |
46f6b872c988
tests: Fix some missing suite definitions so that running the full testsuite
Augie Fackler <durin42@gmail.com>
parents:
149
diff
changeset
|
100 return unittest.TestSuite(all) |