Mercurial > hgsubversion
annotate tests/test_utility_commands.py @ 150:58ae90a65f41
push: Improved the rebasing logic for push so that it doesn't break with
keeping branch names during rebase.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Mon, 22 Dec 2008 21:21:11 -0600 |
parents | 04800fda7af5 |
children | 46f6b872c988 |
rev | line source |
---|---|
149
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
1 import os |
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
|
2 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
|
3 |
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 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
|
5 from mercurial import hg |
149
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
6 from mercurial import revlog |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
7 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
|
8 |
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 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
|
10 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
|
11 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
|
12 |
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 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
|
14 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
|
15 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
|
16 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
|
17 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
|
18 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
|
19 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
|
20 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
|
21 ''' |
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 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
|
24 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
|
25 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
|
26 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
|
27 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
|
28 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
|
29 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
|
30 {'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
|
31 '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
|
32 '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
|
33 '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
|
34 }) |
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 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
|
36 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
|
37 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
|
38 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
|
39 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
|
40 {'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
|
41 '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
|
42 '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
|
43 '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
|
44 }) |
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 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
|
46 |
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 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
|
48 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
|
49 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
|
50 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
|
51 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
|
52 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
|
53 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
|
54 |
149
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
55 def test_rebase(self): |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
56 self._load_fixture_and_fetch('two_revs.svndump') |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
57 parents = (self.repo[0].node(), revlog.nullid, ) |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
58 def filectxfn(repo, memctx, path): |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
59 return context.memfilectx(path=path, |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
60 data='added', |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
61 islink=False, |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
62 isexec=False, |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
63 copied=False) |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
64 ctx = context.memctx(self.repo, |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
65 parents, |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
66 'automated test', |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
67 ['added_bogus_file', 'other_added_file', ], |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
68 filectxfn, |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
69 'testy', |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
70 '2008-12-21 16:32:00 -0500', |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
71 {'branch': 'localbranch', }) |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
72 self.repo.commitctx(ctx) |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
73 self.assertEqual(self.repo['tip'].branch(), 'localbranch') |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
74 beforerebasehash = self.repo['tip'].node() |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
75 hg.update(self.repo, 'tip') |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
76 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
|
77 self.assertEqual(self.repo['tip'].branch(), 'localbranch') |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
78 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
|
79 self.assertNotEqual(beforerebasehash, self.repo['tip'].node()) |
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
80 |
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
|
81 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
|
82 """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
|
83 """ |
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 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
|
85 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
|
86 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
|
87 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
|
88 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
|
89 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
|
90 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
|
91 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
|
92 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
|
93 self.assertEqual(u.stream.getvalue(), expected) |