annotate tests/test_utility_commands.py @ 323:067914ecb4eb

push: Fix a bug in deletion of an entire tree. This bug meant that if an entire subtree of the repo was deleted and there were files at varying levels of the hierarchy, then some of the files at higher levels might escape deletion when the revision was pushed to svn.
author Augie Fackler <durin42@gmail.com>
date Fri, 08 May 2009 16:26:33 -0500
parents 112d57bb736e
children 75f082b5897e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
264
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 257
diff changeset
4 from hgext import rebase
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
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
157
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
9 from mercurial import node
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
10
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 utility_commands
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
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents: 256
diff changeset
13 import wrappers
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
14
178
33ebdcb75bcd test_utility_commands: fix normalized URL references under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 160
diff changeset
15 expected_info_output = '''URL: %(repourl)s/%(branch)s
33ebdcb75bcd test_utility_commands: fix normalized URL references under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 160
diff changeset
16 Repository Root: %(repourl)s
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
17 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
18 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
19 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
20 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
21 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
22 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
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
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 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
26 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
27 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
28 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
29 u = ui.ui()
253
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 241
diff changeset
30 utility_commands.info(u, self.repo, self.wc_path)
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
31 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
32 {'date': '2008-10-08 01:39:05 +0000 (Wed, 08 Oct 2008)',
178
33ebdcb75bcd test_utility_commands: fix normalized URL references under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 160
diff changeset
33 'repourl': test_util.fileurl(self.repo_path),
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
34 '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
35 '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
36 })
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 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
38 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
39 u = ui.ui()
253
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 241
diff changeset
40 utility_commands.info(u, self.repo, self.wc_path)
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
41 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
42 {'date': '2008-10-08 01:39:29 +0000 (Wed, 08 Oct 2008)',
178
33ebdcb75bcd test_utility_commands: fix normalized URL references under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 160
diff changeset
43 'repourl': test_util.fileurl(self.repo_path),
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
44 '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
45 '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
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 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
48
157
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
49 def test_parent_output(self):
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
50 self._load_fixture_and_fetch('two_heads.svndump')
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
51 u = ui.ui()
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
52 parents = (self.repo['the_branch'].node(), revlog.nullid, )
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
53 def filectxfn(repo, memctx, path):
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
54 return context.memfilectx(path=path,
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
55 data='added',
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
56 islink=False,
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
57 isexec=False,
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
58 copied=False)
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
59 ctx = context.memctx(self.repo,
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
60 parents,
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
61 'automated test',
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
62 ['added_bogus_file', 'other_added_file', ],
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
63 filectxfn,
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
64 'testy',
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
65 '2008-12-21 16:32:00 -0500',
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
66 {'branch': 'localbranch', })
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
67 new = self.repo.commitctx(ctx)
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
68 hg.update(self.repo, new)
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents: 256
diff changeset
69 wrappers.parent(lambda x, y: None, u, self.repo, svn=True)
256
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
70 self.assertEqual(u.stream.getvalue(),
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
71 'changeset: 3:4e256962fc5d\n'
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
72 'branch: the_branch\n'
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
73 'user: durin@df2126f7-00ab-4d49-b42c-7e981dde0bcf\n'
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
74 'date: Wed Oct 08 01:39:05 2008 +0000\n'
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
75 'summary: add delta on the branch\n\n')
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
76
157
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
77 hg.update(self.repo, 'default')
256
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
78 # Make sure styles work
157
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
79 u = ui.ui()
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents: 256
diff changeset
80 wrappers.parent(lambda x, y: None, u, self.repo, svn=True, style='compact')
256
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
81 self.assertEqual(u.stream.getvalue(),
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
82 '4:1 1083037b18d8 2008-10-08 01:39 +0000 durin\n'
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
83 ' Add gamma on trunk.\n\n')
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
84 # custom templates too
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
85 u = ui.ui()
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents: 256
diff changeset
86 wrappers.parent(lambda x, y: None, u, self.repo, svn=True, template='{node}\n')
256
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
87 self.assertEqual(u.stream.getvalue(), '1083037b18d85cd84fa211c5adbaeff0fea2cd9f\n')
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
88
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
89 u = ui.ui()
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents: 256
diff changeset
90 wrappers.parent(lambda x, y: None, u, self.repo, svn=True)
256
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
91 self.assertEqual(u.stream.getvalue(),
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
92 'changeset: 4:1083037b18d8\n'
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
93 'parent: 1:c95251e0dd04\n'
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
94 'user: durin@df2126f7-00ab-4d49-b42c-7e981dde0bcf\n'
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
95 'date: Wed Oct 08 01:39:29 2008 +0000\n'
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
96 'summary: Add gamma on trunk.\n\n')
157
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
97
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
98 def test_outgoing_output(self):
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
99 self._load_fixture_and_fetch('two_heads.svndump')
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
100 u = ui.ui()
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
101 parents = (self.repo['the_branch'].node(), revlog.nullid, )
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
102 def filectxfn(repo, memctx, path):
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
103 return context.memfilectx(path=path,
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
104 data='added',
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
105 islink=False,
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
106 isexec=False,
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
107 copied=False)
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
108 ctx = context.memctx(self.repo,
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
109 parents,
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
110 'automated test',
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
111 ['added_bogus_file', 'other_added_file', ],
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
112 filectxfn,
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
113 'testy',
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
114 '2008-12-21 16:32:00 -0500',
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
115 {'branch': 'localbranch', })
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
116 new = self.repo.commitctx(ctx)
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
117 hg.update(self.repo, new)
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents: 256
diff changeset
118 wrappers.outgoing(lambda x,y,z: None, u, self.repo, svn=True)
157
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
119 self.assert_(node.hex(self.repo['localbranch'].node())[:8] in
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
120 u.stream.getvalue())
256
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
121 self.assertEqual(u.stream.getvalue(), ('changeset: 5:6de15430fa20\n'
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
122 'branch: localbranch\n'
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
123 'tag: tip\n'
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
124 'parent: 3:4e256962fc5d\n'
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
125 'user: testy\n'
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
126 'date: Sun Dec 21 16:32:00 2008 -0500\n'
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
127 'summary: automated test\n'
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
128 '\n'))
157
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
129 hg.update(self.repo, 'default')
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
130 u = ui.ui()
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents: 256
diff changeset
131 wrappers.outgoing(lambda x,y,z: None, u, self.repo, svn=True)
256
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
132 self.assertEqual(u.stream.getvalue(), 'no changes found\n')
157
91541523ea5c utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents: 153
diff changeset
133
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
134 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
135 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
136 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
137 u = ui.ui()
253
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 241
diff changeset
138 utility_commands.url(u, self.repo, self.wc_path)
178
33ebdcb75bcd test_utility_commands: fix normalized URL references under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 160
diff changeset
139 expected = test_util.fileurl(self.repo_path) + '\n'
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
140 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
141
149
04800fda7af5 rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
142 def test_rebase(self):
04800fda7af5 rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
143 self._load_fixture_and_fetch('two_revs.svndump')
04800fda7af5 rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
144 parents = (self.repo[0].node(), revlog.nullid, )
04800fda7af5 rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
145 def filectxfn(repo, memctx, path):
04800fda7af5 rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
146 return context.memfilectx(path=path,
04800fda7af5 rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
147 data='added',
04800fda7af5 rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
148 islink=False,
04800fda7af5 rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
149 isexec=False,
04800fda7af5 rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
150 copied=False)
04800fda7af5 rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
151 ctx = context.memctx(self.repo,
04800fda7af5 rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
152 parents,
04800fda7af5 rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
153 'automated test',
04800fda7af5 rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
154 ['added_bogus_file', 'other_added_file', ],
04800fda7af5 rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
155 filectxfn,
04800fda7af5 rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
156 'testy',
04800fda7af5 rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
157 '2008-12-21 16:32:00 -0500',
04800fda7af5 rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
158 {'branch': 'localbranch', })
04800fda7af5 rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
159 self.repo.commitctx(ctx)
04800fda7af5 rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
160 self.assertEqual(self.repo['tip'].branch(), 'localbranch')
04800fda7af5 rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
161 beforerebasehash = self.repo['tip'].node()
04800fda7af5 rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
162 hg.update(self.repo, 'tip')
264
112d57bb736e rebase: moved to wrappers, now a wrapper around rebase triggered with --svn.
Augie Fackler <durin42@gmail.com>
parents: 257
diff changeset
163 wrappers.rebase(rebase.rebase, ui.ui(), self.repo, svn=True)
149
04800fda7af5 rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
164 self.assertEqual(self.repo['tip'].branch(), 'localbranch')
04800fda7af5 rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
165 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
166 self.assertNotEqual(beforerebasehash, self.repo['tip'].node())
04800fda7af5 rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
167
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
168 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
169 """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
170 """
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
171 test_util.load_svndump_fixture(self.repo_path, 'two_revs.svndump')
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents: 256
diff changeset
172 wrappers.clone(None, ui.ui(),
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents: 256
diff changeset
173 source=test_util.fileurl(self.repo_path) + '/',
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents: 256
diff changeset
174 dest=self.wc_path, stupid=False)
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
175 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
176 u = ui.ui()
253
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 241
diff changeset
177 utility_commands.url(u, self.repo, self.wc_path)
178
33ebdcb75bcd test_utility_commands: fix normalized URL references under Windows
Patrick Mezard <pmezard@gmail.com>
parents: 160
diff changeset
178 expected = test_util.fileurl(self.repo_path) + '\n'
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
179 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
180
199
91db8fc049b0 Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents: 195
diff changeset
181 def test_genignore(self):
91db8fc049b0 Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents: 195
diff changeset
182 """Verify url gets normalized on initial clone.
91db8fc049b0 Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents: 195
diff changeset
183 """
91db8fc049b0 Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents: 195
diff changeset
184 test_util.load_svndump_fixture(self.repo_path, 'ignores.svndump')
257
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents: 256
diff changeset
185 wrappers.clone(None, ui.ui(),
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents: 256
diff changeset
186 source=test_util.fileurl(self.repo_path) + '/',
ffccf0080e54 Move wrappers for hg commands to their own module.
Augie Fackler <durin42@gmail.com>
parents: 256
diff changeset
187 dest=self.wc_path, stupid=False)
199
91db8fc049b0 Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents: 195
diff changeset
188 hg.update(self.repo, 'tip')
91db8fc049b0 Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents: 195
diff changeset
189 u = ui.ui()
253
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 241
diff changeset
190 utility_commands.genignore(u, self.repo, self.wc_path)
199
91db8fc049b0 Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents: 195
diff changeset
191 self.assertEqual(open(os.path.join(self.wc_path, '.hgignore')).read(),
91db8fc049b0 Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents: 195
diff changeset
192 '.hgignore\nsyntax:glob\nblah\notherblah\nbaz/magic\n')
91db8fc049b0 Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents: 195
diff changeset
193
236
c34abd2448b7 Issue #60: Add a svn sub-command to list all authors in a Subversion repository
Daniel Tang <dytang@cs.purdue.edu>
parents: 230
diff changeset
194 def test_list_authors(self):
c34abd2448b7 Issue #60: Add a svn sub-command to list all authors in a Subversion repository
Daniel Tang <dytang@cs.purdue.edu>
parents: 230
diff changeset
195 test_util.load_svndump_fixture(self.repo_path,
c34abd2448b7 Issue #60: Add a svn sub-command to list all authors in a Subversion repository
Daniel Tang <dytang@cs.purdue.edu>
parents: 230
diff changeset
196 'replace_trunk_with_branch.svndump')
c34abd2448b7 Issue #60: Add a svn sub-command to list all authors in a Subversion repository
Daniel Tang <dytang@cs.purdue.edu>
parents: 230
diff changeset
197 u = ui.ui()
253
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 241
diff changeset
198 utility_commands.listauthors(u,
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 241
diff changeset
199 args=[test_util.fileurl(self.repo_path)],
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 241
diff changeset
200 authors=None)
236
c34abd2448b7 Issue #60: Add a svn sub-command to list all authors in a Subversion repository
Daniel Tang <dytang@cs.purdue.edu>
parents: 230
diff changeset
201 self.assertEqual(u.stream.getvalue(), 'Augie\nevil\n')
c34abd2448b7 Issue #60: Add a svn sub-command to list all authors in a Subversion repository
Daniel Tang <dytang@cs.purdue.edu>
parents: 230
diff changeset
202
c34abd2448b7 Issue #60: Add a svn sub-command to list all authors in a Subversion repository
Daniel Tang <dytang@cs.purdue.edu>
parents: 230
diff changeset
203
c34abd2448b7 Issue #60: Add a svn sub-command to list all authors in a Subversion repository
Daniel Tang <dytang@cs.purdue.edu>
parents: 230
diff changeset
204 def test_list_authors_map(self):
c34abd2448b7 Issue #60: Add a svn sub-command to list all authors in a Subversion repository
Daniel Tang <dytang@cs.purdue.edu>
parents: 230
diff changeset
205 test_util.load_svndump_fixture(self.repo_path,
c34abd2448b7 Issue #60: Add a svn sub-command to list all authors in a Subversion repository
Daniel Tang <dytang@cs.purdue.edu>
parents: 230
diff changeset
206 'replace_trunk_with_branch.svndump')
c34abd2448b7 Issue #60: Add a svn sub-command to list all authors in a Subversion repository
Daniel Tang <dytang@cs.purdue.edu>
parents: 230
diff changeset
207 author_path = os.path.join(self.repo_path, 'authors')
253
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 241
diff changeset
208 utility_commands.listauthors(ui.ui(),
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 241
diff changeset
209 args=[test_util.fileurl(self.repo_path)],
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 241
diff changeset
210 authors=author_path)
236
c34abd2448b7 Issue #60: Add a svn sub-command to list all authors in a Subversion repository
Daniel Tang <dytang@cs.purdue.edu>
parents: 230
diff changeset
211 self.assertEqual(open(author_path).read(), 'Augie=\nevil=\n')
256
7932d098cb5f Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
Augie Fackler <durin42@gmail.com>
parents: 253
diff changeset
212
153
46f6b872c988 tests: Fix some missing suite definitions so that running the full testsuite
Augie Fackler <durin42@gmail.com>
parents: 149
diff changeset
213
46f6b872c988 tests: Fix some missing suite definitions so that running the full testsuite
Augie Fackler <durin42@gmail.com>
parents: 149
diff changeset
214 def suite():
46f6b872c988 tests: Fix some missing suite definitions so that running the full testsuite
Augie Fackler <durin42@gmail.com>
parents: 149
diff changeset
215 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
216 ]
46f6b872c988 tests: Fix some missing suite definitions so that running the full testsuite
Augie Fackler <durin42@gmail.com>
parents: 149
diff changeset
217 return unittest.TestSuite(all)