Mercurial > hgsubversion
annotate tests/test_fetch_command.py @ 15:db32dee803a8
Add some basic tests of branching.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Tue, 07 Oct 2008 20:43:44 -0500 |
parents | d78dbf88c13d |
children | 48a44546c12f |
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 |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
11 import util |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
12 |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
13 class TestBasicRepoLayout(unittest.TestCase): |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
14 def setUp(self): |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
15 self.oldwd = os.getcwd() |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
16 self.tmpdir = tempfile.mkdtemp('svnwrap_test') |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
17 self.repo_path = '%s/testrepo' % self.tmpdir |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
18 self.wc_path = '%s/testrepo_wc' % self.tmpdir |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
19 |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
20 def tearDown(self): |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
21 shutil.rmtree(self.tmpdir) |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
22 os.chdir(self.oldwd) |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
23 |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
24 def test_fresh_fetch_single_rev(self): |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
25 util.load_svndump_fixture(self.repo_path, 'single_rev.svndump') |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
26 fetch_command.fetch_revisions(ui.ui(), |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
27 svn_url='file://%s' % self.repo_path, |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
28 hg_repo_path=self.wc_path) |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
29 repo = hg.repository(ui.ui(), self.wc_path) |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
30 self.assertEqual(node.hex(repo['tip'].node()), |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
31 'a47d0ce778660a91c31bf2c21c448e9ee296ac90') |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
32 self.assertEqual(repo['tip'], repo[0]) |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
33 |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
34 def test_fresh_fetch_two_revs(self): |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
35 util.load_svndump_fixture(self.repo_path, 'two_revs.svndump') |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
36 fetch_command.fetch_revisions(ui.ui(), |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
37 svn_url='file://%s' % self.repo_path, |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
38 hg_repo_path=self.wc_path) |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
39 repo = hg.repository(ui.ui(), self.wc_path) |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
40 # 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
|
41 self.assertEqual(node.hex(repo[0].node()), |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
42 'a47d0ce778660a91c31bf2c21c448e9ee296ac90') |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
43 self.assertEqual(node.hex(repo['tip'].node()), |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
44 'bf3767835b3b32ecc775a298c2fa27134dd91c11') |
d78dbf88c13d
Started a meaningful test suite.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
45 self.assertEqual(repo['tip'], repo[1]) |
15
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
46 |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
47 def test_branches(self): |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
48 util.load_svndump_fixture(self.repo_path, 'simple_branch.svndump') |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
49 fetch_command.fetch_revisions(ui.ui(), |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
50 svn_url='file://%s' % self.repo_path, |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
51 hg_repo_path=self.wc_path) |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
52 repo = hg.repository(ui.ui(), self.wc_path) |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
53 # 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
|
54 self.assertEqual(node.hex(repo[0].node()), |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
55 'a47d0ce778660a91c31bf2c21c448e9ee296ac90') |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
56 self.assertEqual(node.hex(repo['tip'].node()), |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
57 '9dfb0a19494f45c36e22f3c6d1b21d80638a7f6e') |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
58 self.assertEqual(len(repo['tip'].parents()), 1) |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
59 self.assertEqual(repo['tip'].parents()[0], repo['default']) |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
60 self.assertEqual(len(repo.heads()), 1) |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
61 |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
62 def test_two_branches_with_heads(self): |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
63 util.load_svndump_fixture(self.repo_path, 'two_heads.svndump') |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
64 fetch_command.fetch_revisions(ui.ui(), |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
65 svn_url='file://%s' % self.repo_path, |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
66 hg_repo_path=self.wc_path) |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
67 repo = hg.repository(ui.ui(), self.wc_path) |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
68 # 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
|
69 self.assertEqual(node.hex(repo[0].node()), |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
70 'a47d0ce778660a91c31bf2c21c448e9ee296ac90') |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
71 self.assertEqual(node.hex(repo['tip'].node()), |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
72 'a595c77cfcaa3d1ba9e04b2c55c68bc6bf2b0fbf') |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
73 self.assertEqual(node.hex(repo['the_branch'].node()), |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
74 '8ccaba5f0eae124487e413abd904a013f7f6fdeb') |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
75 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
|
76 '9dfb0a19494f45c36e22f3c6d1b21d80638a7f6e') |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
77 self.assertEqual(len(repo['tip'].parents()), 1) |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
78 self.assertEqual(repo['tip'], repo['default']) |
db32dee803a8
Add some basic tests of branching.
Augie Fackler <durin42@gmail.com>
parents:
14
diff
changeset
|
79 self.assertEqual(len(repo.heads()), 2) |