Mercurial > hgsubversion
annotate tests/test_fetch_command.py @ 20:2953c867ca99
Minor fixes to the push command to make it more robust.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Wed, 08 Oct 2008 16:44:40 -0500 |
parents | f4c751037a4a |
children | 8626f3d2e50b |
rev | line source |
---|---|
14
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1 import os |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
2 import shutil |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
3 import tempfile |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
4 import unittest |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
5 |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
6 from mercurial import hg |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
7 from mercurial import ui |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
8 from mercurial import node |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
9 |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
10 import fetch_command |
16
48a44546c12f
Add a basic system for running the hgsubversion tests (although not the svnwrap ones) without requiring Nose. Nose is still the recommended way to run the tests.
Augie Fackler <durin42@gmail.com>
parents:
15
diff
changeset
|
11 import test_util |
14
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
12 |
18
f4c751037a4a
Add a quick test for diff-based pull.
Augie Fackler <durin42@gmail.com>
parents:
16
diff
changeset
|
13 |
14
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
14 class TestBasicRepoLayout(unittest.TestCase): |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
15 def setUp(self): |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
16 self.oldwd = os.getcwd() |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
17 self.tmpdir = tempfile.mkdtemp('svnwrap_test') |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
18 self.repo_path = '%s/testrepo' % self.tmpdir |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
19 self.wc_path = '%s/testrepo_wc' % self.tmpdir |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
20 |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
21 def tearDown(self): |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
22 shutil.rmtree(self.tmpdir) |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
23 os.chdir(self.oldwd) |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
24 |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
25 def test_fresh_fetch_single_rev(self): |
16
48a44546c12f
Add a basic system for running the hgsubversion tests (although not the svnwrap ones) without requiring Nose. Nose is still the recommended way to run the tests.
Augie Fackler <durin42@gmail.com>
parents:
15
diff
changeset
|
26 test_util.load_svndump_fixture(self.repo_path, 'single_rev.svndump') |
14
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
27 fetch_command.fetch_revisions(ui.ui(), |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
28 svn_url='file://%s' % self.repo_path, |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
29 hg_repo_path=self.wc_path) |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
30 repo = hg.repository(ui.ui(), self.wc_path) |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
31 self.assertEqual(node.hex(repo['tip'].node()), |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
32 'a47d0ce778660a91c31bf2c21c448e9ee296ac90') |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
33 self.assertEqual(repo['tip'], repo[0]) |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
34 |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
35 def test_fresh_fetch_two_revs(self): |
16
48a44546c12f
Add a basic system for running the hgsubversion tests (although not the svnwrap ones) without requiring Nose. Nose is still the recommended way to run the tests.
Augie Fackler <durin42@gmail.com>
parents:
15
diff
changeset
|
36 test_util.load_svndump_fixture(self.repo_path, 'two_revs.svndump') |
14
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
37 fetch_command.fetch_revisions(ui.ui(), |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
38 svn_url='file://%s' % self.repo_path, |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
39 hg_repo_path=self.wc_path) |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
40 repo = hg.repository(ui.ui(), self.wc_path) |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
41 # TODO there must be a better way than repo[0] for this check |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
42 self.assertEqual(node.hex(repo[0].node()), |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
43 'a47d0ce778660a91c31bf2c21c448e9ee296ac90') |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
44 self.assertEqual(node.hex(repo['tip'].node()), |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
45 'bf3767835b3b32ecc775a298c2fa27134dd91c11') |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
46 self.assertEqual(repo['tip'], repo[1]) |
15
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
47 |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
48 def test_branches(self): |
16
48a44546c12f
Add a basic system for running the hgsubversion tests (although not the svnwrap ones) without requiring Nose. Nose is still the recommended way to run the tests.
Augie Fackler <durin42@gmail.com>
parents:
15
diff
changeset
|
49 test_util.load_svndump_fixture(self.repo_path, 'simple_branch.svndump') |
15
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
50 fetch_command.fetch_revisions(ui.ui(), |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
51 svn_url='file://%s' % self.repo_path, |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
52 hg_repo_path=self.wc_path) |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
53 repo = hg.repository(ui.ui(), self.wc_path) |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
54 # TODO there must be a better way than repo[0] for this check |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
55 self.assertEqual(node.hex(repo[0].node()), |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
56 'a47d0ce778660a91c31bf2c21c448e9ee296ac90') |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
57 self.assertEqual(node.hex(repo['tip'].node()), |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
58 '9dfb0a19494f45c36e22f3c6d1b21d80638a7f6e') |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
59 self.assertEqual(len(repo['tip'].parents()), 1) |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
60 self.assertEqual(repo['tip'].parents()[0], repo['default']) |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
61 self.assertEqual(len(repo.heads()), 1) |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
62 |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
63 def test_two_branches_with_heads(self): |
16
48a44546c12f
Add a basic system for running the hgsubversion tests (although not the svnwrap ones) without requiring Nose. Nose is still the recommended way to run the tests.
Augie Fackler <durin42@gmail.com>
parents:
15
diff
changeset
|
64 test_util.load_svndump_fixture(self.repo_path, 'two_heads.svndump') |
15
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
65 fetch_command.fetch_revisions(ui.ui(), |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
66 svn_url='file://%s' % self.repo_path, |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
67 hg_repo_path=self.wc_path) |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
68 repo = hg.repository(ui.ui(), self.wc_path) |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
69 # TODO there must be a better way than repo[0] for this check |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
70 self.assertEqual(node.hex(repo[0].node()), |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
71 'a47d0ce778660a91c31bf2c21c448e9ee296ac90') |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
72 self.assertEqual(node.hex(repo['tip'].node()), |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
73 'a595c77cfcaa3d1ba9e04b2c55c68bc6bf2b0fbf') |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
74 self.assertEqual(node.hex(repo['the_branch'].node()), |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
75 '8ccaba5f0eae124487e413abd904a013f7f6fdeb') |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
76 self.assertEqual(node.hex(repo['the_branch'].parents()[0].node()), |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
77 '9dfb0a19494f45c36e22f3c6d1b21d80638a7f6e') |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
78 self.assertEqual(len(repo['tip'].parents()), 1) |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
79 self.assertEqual(repo['tip'], repo['default']) |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
80 self.assertEqual(len(repo.heads()), 2) |
16
48a44546c12f
Add a basic system for running the hgsubversion tests (although not the svnwrap ones) without requiring Nose. Nose is still the recommended way to run the tests.
Augie Fackler <durin42@gmail.com>
parents:
15
diff
changeset
|
81 |
18
f4c751037a4a
Add a quick test for diff-based pull.
Augie Fackler <durin42@gmail.com>
parents:
16
diff
changeset
|
82 |
f4c751037a4a
Add a quick test for diff-based pull.
Augie Fackler <durin42@gmail.com>
parents:
16
diff
changeset
|
83 class TestStupidPull(unittest.TestCase): |
f4c751037a4a
Add a quick test for diff-based pull.
Augie Fackler <durin42@gmail.com>
parents:
16
diff
changeset
|
84 def setUp(self): |
f4c751037a4a
Add a quick test for diff-based pull.
Augie Fackler <durin42@gmail.com>
parents:
16
diff
changeset
|
85 self.oldwd = os.getcwd() |
f4c751037a4a
Add a quick test for diff-based pull.
Augie Fackler <durin42@gmail.com>
parents:
16
diff
changeset
|
86 self.tmpdir = tempfile.mkdtemp('svnwrap_test') |
f4c751037a4a
Add a quick test for diff-based pull.
Augie Fackler <durin42@gmail.com>
parents:
16
diff
changeset
|
87 self.repo_path = '%s/testrepo' % self.tmpdir |
f4c751037a4a
Add a quick test for diff-based pull.
Augie Fackler <durin42@gmail.com>
parents:
16
diff
changeset
|
88 self.wc_path = '%s/testrepo_wc' % self.tmpdir |
f4c751037a4a
Add a quick test for diff-based pull.
Augie Fackler <durin42@gmail.com>
parents:
16
diff
changeset
|
89 |
f4c751037a4a
Add a quick test for diff-based pull.
Augie Fackler <durin42@gmail.com>
parents:
16
diff
changeset
|
90 def tearDown(self): |
f4c751037a4a
Add a quick test for diff-based pull.
Augie Fackler <durin42@gmail.com>
parents:
16
diff
changeset
|
91 shutil.rmtree(self.tmpdir) |
f4c751037a4a
Add a quick test for diff-based pull.
Augie Fackler <durin42@gmail.com>
parents:
16
diff
changeset
|
92 os.chdir(self.oldwd) |
f4c751037a4a
Add a quick test for diff-based pull.
Augie Fackler <durin42@gmail.com>
parents:
16
diff
changeset
|
93 |
f4c751037a4a
Add a quick test for diff-based pull.
Augie Fackler <durin42@gmail.com>
parents:
16
diff
changeset
|
94 def test_stupid(self): |
f4c751037a4a
Add a quick test for diff-based pull.
Augie Fackler <durin42@gmail.com>
parents:
16
diff
changeset
|
95 test_util.load_svndump_fixture(self.repo_path, 'two_heads.svndump') |
f4c751037a4a
Add a quick test for diff-based pull.
Augie Fackler <durin42@gmail.com>
parents:
16
diff
changeset
|
96 fetch_command.fetch_revisions(ui.ui(), |
f4c751037a4a
Add a quick test for diff-based pull.
Augie Fackler <durin42@gmail.com>
parents:
16
diff
changeset
|
97 svn_url='file://%s' % self.repo_path, |
f4c751037a4a
Add a quick test for diff-based pull.
Augie Fackler <durin42@gmail.com>
parents:
16
diff
changeset
|
98 hg_repo_path=self.wc_path, |
f4c751037a4a
Add a quick test for diff-based pull.
Augie Fackler <durin42@gmail.com>
parents:
16
diff
changeset
|
99 stupid=True) |
f4c751037a4a
Add a quick test for diff-based pull.
Augie Fackler <durin42@gmail.com>
parents:
16
diff
changeset
|
100 repo = hg.repository(ui.ui(), self.wc_path) |
f4c751037a4a
Add a quick test for diff-based pull.
Augie Fackler <durin42@gmail.com>
parents:
16
diff
changeset
|
101 # TODO there must be a better way than repo[0] for this check |
f4c751037a4a
Add a quick test for diff-based pull.
Augie Fackler <durin42@gmail.com>
parents:
16
diff
changeset
|
102 self.assertEqual(node.hex(repo[0].node()), |
f4c751037a4a
Add a quick test for diff-based pull.
Augie Fackler <durin42@gmail.com>
parents:
16
diff
changeset
|
103 'a47d0ce778660a91c31bf2c21c448e9ee296ac90') |
f4c751037a4a
Add a quick test for diff-based pull.
Augie Fackler <durin42@gmail.com>
parents:
16
diff
changeset
|
104 self.assertEqual(node.hex(repo['tip'].node()), |
f4c751037a4a
Add a quick test for diff-based pull.
Augie Fackler <durin42@gmail.com>
parents:
16
diff
changeset
|
105 'a595c77cfcaa3d1ba9e04b2c55c68bc6bf2b0fbf') |
f4c751037a4a
Add a quick test for diff-based pull.
Augie Fackler <durin42@gmail.com>
parents:
16
diff
changeset
|
106 self.assertEqual(node.hex(repo['the_branch'].node()), |
f4c751037a4a
Add a quick test for diff-based pull.
Augie Fackler <durin42@gmail.com>
parents:
16
diff
changeset
|
107 '8ccaba5f0eae124487e413abd904a013f7f6fdeb') |
f4c751037a4a
Add a quick test for diff-based pull.
Augie Fackler <durin42@gmail.com>
parents:
16
diff
changeset
|
108 self.assertEqual(node.hex(repo['the_branch'].parents()[0].node()), |
f4c751037a4a
Add a quick test for diff-based pull.
Augie Fackler <durin42@gmail.com>
parents:
16
diff
changeset
|
109 '9dfb0a19494f45c36e22f3c6d1b21d80638a7f6e') |
f4c751037a4a
Add a quick test for diff-based pull.
Augie Fackler <durin42@gmail.com>
parents:
16
diff
changeset
|
110 self.assertEqual(len(repo['tip'].parents()), 1) |
f4c751037a4a
Add a quick test for diff-based pull.
Augie Fackler <durin42@gmail.com>
parents:
16
diff
changeset
|
111 self.assertEqual(repo['tip'], repo['default']) |
f4c751037a4a
Add a quick test for diff-based pull.
Augie Fackler <durin42@gmail.com>
parents:
16
diff
changeset
|
112 self.assertEqual(len(repo.heads()), 2) |
f4c751037a4a
Add a quick test for diff-based pull.
Augie Fackler <durin42@gmail.com>
parents:
16
diff
changeset
|
113 |
16
48a44546c12f
Add a basic system for running the hgsubversion tests (although not the svnwrap ones) without requiring Nose. Nose is still the recommended way to run the tests.
Augie Fackler <durin42@gmail.com>
parents:
15
diff
changeset
|
114 def suite(): |
18
f4c751037a4a
Add a quick test for diff-based pull.
Augie Fackler <durin42@gmail.com>
parents:
16
diff
changeset
|
115 all = [unittest.TestLoader().loadTestsFromTestCase(TestBasicRepoLayout), |
f4c751037a4a
Add a quick test for diff-based pull.
Augie Fackler <durin42@gmail.com>
parents:
16
diff
changeset
|
116 unittest.TestLoader().loadTestsFromTestCase(TestStupidPull), |
f4c751037a4a
Add a quick test for diff-based pull.
Augie Fackler <durin42@gmail.com>
parents:
16
diff
changeset
|
117 ] |
f4c751037a4a
Add a quick test for diff-based pull.
Augie Fackler <durin42@gmail.com>
parents:
16
diff
changeset
|
118 return unittest.TestSuite(all) |