Mercurial > hgsubversion
annotate tests/test_fetch_branches.py @ 318:0291afdd7555
Style nit in setup.py
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Sun, 03 May 2009 21:57:48 -0500 |
parents | 942f198b8ff5 |
children | 33736e2e25f0 |
rev | line source |
---|---|
117
3afe404042a3
Add a disabled test for unrelated branches
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
1 import unittest |
3afe404042a3
Add a disabled test for unrelated branches
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
2 |
284
f8f9a2993705
Implement parseurl support (#revision in repository urls)
Martijn Pieters <mj@zopatista.com>
parents:
278
diff
changeset
|
3 from mercurial import hg |
133
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
131
diff
changeset
|
4 from mercurial import node |
284
f8f9a2993705
Implement parseurl support (#revision in repository urls)
Martijn Pieters <mj@zopatista.com>
parents:
278
diff
changeset
|
5 from mercurial import ui |
133
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
131
diff
changeset
|
6 |
117
3afe404042a3
Add a disabled test for unrelated branches
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
7 import test_util |
284
f8f9a2993705
Implement parseurl support (#revision in repository urls)
Martijn Pieters <mj@zopatista.com>
parents:
278
diff
changeset
|
8 import wrappers |
117
3afe404042a3
Add a disabled test for unrelated branches
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
9 |
3afe404042a3
Add a disabled test for unrelated branches
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
10 |
3afe404042a3
Add a disabled test for unrelated branches
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
11 class TestFetchBranches(test_util.TestBase): |
313
942f198b8ff5
hg_delta_editor: detect new branches issued from non-branch directories
Patrick Mezard <pmezard@gmail.com>
parents:
284
diff
changeset
|
12 def _load_fixture_and_fetch(self, fixture_name, stupid, noupdate=True, |
942f198b8ff5
hg_delta_editor: detect new branches issued from non-branch directories
Patrick Mezard <pmezard@gmail.com>
parents:
284
diff
changeset
|
13 subdir=''): |
117
3afe404042a3
Add a disabled test for unrelated branches
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
14 return test_util.load_fixture_and_fetch(fixture_name, self.repo_path, |
278
60acc38eac96
clone: prefer tip of default to overall tip when updating
Martijn Pieters <mj@zopatista.com>
parents:
232
diff
changeset
|
15 self.wc_path, stupid=stupid, |
313
942f198b8ff5
hg_delta_editor: detect new branches issued from non-branch directories
Patrick Mezard <pmezard@gmail.com>
parents:
284
diff
changeset
|
16 noupdate=noupdate, subdir=subdir) |
117
3afe404042a3
Add a disabled test for unrelated branches
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
17 |
284
f8f9a2993705
Implement parseurl support (#revision in repository urls)
Martijn Pieters <mj@zopatista.com>
parents:
278
diff
changeset
|
18 def _load_fixture_and_fetch_with_anchor(self, fixture_name, anchor): |
f8f9a2993705
Implement parseurl support (#revision in repository urls)
Martijn Pieters <mj@zopatista.com>
parents:
278
diff
changeset
|
19 test_util.load_svndump_fixture(self.repo_path, fixture_name) |
f8f9a2993705
Implement parseurl support (#revision in repository urls)
Martijn Pieters <mj@zopatista.com>
parents:
278
diff
changeset
|
20 source = '%s#%s' % (test_util.fileurl(self.repo_path), anchor) |
f8f9a2993705
Implement parseurl support (#revision in repository urls)
Martijn Pieters <mj@zopatista.com>
parents:
278
diff
changeset
|
21 wrappers.clone(None, ui.ui(), source=source, dest=self.wc_path) |
f8f9a2993705
Implement parseurl support (#revision in repository urls)
Martijn Pieters <mj@zopatista.com>
parents:
278
diff
changeset
|
22 return hg.repository(ui.ui(), self.wc_path) |
f8f9a2993705
Implement parseurl support (#revision in repository urls)
Martijn Pieters <mj@zopatista.com>
parents:
278
diff
changeset
|
23 |
117
3afe404042a3
Add a disabled test for unrelated branches
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
24 def test_unrelatedbranch(self, stupid=False): |
3afe404042a3
Add a disabled test for unrelated branches
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
25 repo = self._load_fixture_and_fetch('unrelatedbranch.svndump', stupid) |
3afe404042a3
Add a disabled test for unrelated branches
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
26 heads = [repo[n] for n in repo.heads()] |
3afe404042a3
Add a disabled test for unrelated branches
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
27 heads = dict([(ctx.branch(), ctx) for ctx in heads]) |
3afe404042a3
Add a disabled test for unrelated branches
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
28 # Let these tests disabled yet as the fix is not obvious |
120
f508c1fa19a5
hg_delta_editor: do not assume branches are copied from trunk by default
Patrick Mezard <pmezard@gmail.com>
parents:
117
diff
changeset
|
29 self.assertEqual(heads['branch1'].manifest().keys(), ['b']) |
f508c1fa19a5
hg_delta_editor: do not assume branches are copied from trunk by default
Patrick Mezard <pmezard@gmail.com>
parents:
117
diff
changeset
|
30 self.assertEqual(heads['branch2'].manifest().keys(), ['a', 'b']) |
117
3afe404042a3
Add a disabled test for unrelated branches
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
31 |
3afe404042a3
Add a disabled test for unrelated branches
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
32 def test_unrelatedbranch_stupid(self): |
3afe404042a3
Add a disabled test for unrelated branches
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
33 self.test_unrelatedbranch(True) |
3afe404042a3
Add a disabled test for unrelated branches
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
34 |
131
4d42dbbb5127
hg_delta_editor: fix parent revision detection on branch copy
Patrick Mezard <pmezard@gmail.com>
parents:
120
diff
changeset
|
35 def test_unorderedbranch(self, stupid=False): |
4d42dbbb5127
hg_delta_editor: fix parent revision detection on branch copy
Patrick Mezard <pmezard@gmail.com>
parents:
120
diff
changeset
|
36 repo = self._load_fixture_and_fetch('unorderedbranch.svndump', stupid) |
4d42dbbb5127
hg_delta_editor: fix parent revision detection on branch copy
Patrick Mezard <pmezard@gmail.com>
parents:
120
diff
changeset
|
37 r = repo['branch'] |
4d42dbbb5127
hg_delta_editor: fix parent revision detection on branch copy
Patrick Mezard <pmezard@gmail.com>
parents:
120
diff
changeset
|
38 self.assertEqual(0, r.parents()[0].rev()) |
4d42dbbb5127
hg_delta_editor: fix parent revision detection on branch copy
Patrick Mezard <pmezard@gmail.com>
parents:
120
diff
changeset
|
39 self.assertEqual(['a', 'c', 'z'], sorted(r.manifest())) |
4d42dbbb5127
hg_delta_editor: fix parent revision detection on branch copy
Patrick Mezard <pmezard@gmail.com>
parents:
120
diff
changeset
|
40 |
4d42dbbb5127
hg_delta_editor: fix parent revision detection on branch copy
Patrick Mezard <pmezard@gmail.com>
parents:
120
diff
changeset
|
41 def test_unorderedbranch_stupid(self): |
4d42dbbb5127
hg_delta_editor: fix parent revision detection on branch copy
Patrick Mezard <pmezard@gmail.com>
parents:
120
diff
changeset
|
42 self.test_unorderedbranch(True) |
147
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
133
diff
changeset
|
43 |
133
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
131
diff
changeset
|
44 def test_renamed_branch_to_trunk(self, stupid=False): |
147
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
133
diff
changeset
|
45 repo = self._load_fixture_and_fetch('branch_rename_to_trunk.svndump', |
133
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
131
diff
changeset
|
46 stupid) |
147
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
133
diff
changeset
|
47 self.assertEqual(node.hex(repo['default'].node()), |
154
6fa97cfbf62f
fetch: Refactor extra creation to be shared by real and diff replay.
Augie Fackler <durin42@gmail.com>
parents:
147
diff
changeset
|
48 '14d252aef315857df241dd3fa4bc7833b09bd2f5') |
201
883976b654b6
Be more explicit about which branch I'm checking.
Augie Fackler <durin42@gmail.com>
parents:
158
diff
changeset
|
49 self.assertEqual(repo['default'].parents()[0].branch(), 'dev_branch') |
133
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
131
diff
changeset
|
50 self.assertEqual(repo['old_trunk'].parents()[0].branch(), 'default') |
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
131
diff
changeset
|
51 |
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
131
diff
changeset
|
52 def test_renamed_branch_to_trunk_stupid(self): |
2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents:
131
diff
changeset
|
53 self.test_renamed_branch_to_trunk(stupid=True) |
131
4d42dbbb5127
hg_delta_editor: fix parent revision detection on branch copy
Patrick Mezard <pmezard@gmail.com>
parents:
120
diff
changeset
|
54 |
147
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
133
diff
changeset
|
55 def test_replace_trunk_with_branch(self, stupid=False): |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
133
diff
changeset
|
56 repo = self._load_fixture_and_fetch('replace_trunk_with_branch.svndump', |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
133
diff
changeset
|
57 stupid) |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
133
diff
changeset
|
58 self.assertEqual(repo['default'].parents()[0].branch(), 'test') |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
133
diff
changeset
|
59 self.assertEqual(node.hex(repo['closed-branches'].parents()[0].node()), |
154
6fa97cfbf62f
fetch: Refactor extra creation to be shared by real and diff replay.
Augie Fackler <durin42@gmail.com>
parents:
147
diff
changeset
|
60 '2cd09772e0f6ddf2d13c60ef3c1be11ad5a7dfae') |
147
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
133
diff
changeset
|
61 self.assertEqual(node.hex(repo['default'].node()), |
154
6fa97cfbf62f
fetch: Refactor extra creation to be shared by real and diff replay.
Augie Fackler <durin42@gmail.com>
parents:
147
diff
changeset
|
62 '8a525ca0671f456e6b1417187bf86c6115d2cb78') |
147
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
133
diff
changeset
|
63 |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
133
diff
changeset
|
64 def test_replace_trunk_with_branch_stupid(self): |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
133
diff
changeset
|
65 self.test_replace_trunk_with_branch(stupid=True) |
22162380c4b9
Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents:
133
diff
changeset
|
66 |
232
c0063328587f
Fix and test for directory deletes during branch creation.
Augie Fackler <durin42@gmail.com>
parents:
201
diff
changeset
|
67 def test_branch_create_with_dir_delete_works(self, stupid=False): |
c0063328587f
Fix and test for directory deletes during branch creation.
Augie Fackler <durin42@gmail.com>
parents:
201
diff
changeset
|
68 repo = self._load_fixture_and_fetch('branch_create_with_dir_delete.svndump', |
c0063328587f
Fix and test for directory deletes during branch creation.
Augie Fackler <durin42@gmail.com>
parents:
201
diff
changeset
|
69 stupid) |
c0063328587f
Fix and test for directory deletes during branch creation.
Augie Fackler <durin42@gmail.com>
parents:
201
diff
changeset
|
70 self.assertEqual(repo['tip'].manifest().keys(), |
c0063328587f
Fix and test for directory deletes during branch creation.
Augie Fackler <durin42@gmail.com>
parents:
201
diff
changeset
|
71 ['alpha', 'beta', 'iota', 'gamma', ]) |
c0063328587f
Fix and test for directory deletes during branch creation.
Augie Fackler <durin42@gmail.com>
parents:
201
diff
changeset
|
72 |
278
60acc38eac96
clone: prefer tip of default to overall tip when updating
Martijn Pieters <mj@zopatista.com>
parents:
232
diff
changeset
|
73 def test_branch_tip_update_to_default(self, stupid=False): |
60acc38eac96
clone: prefer tip of default to overall tip when updating
Martijn Pieters <mj@zopatista.com>
parents:
232
diff
changeset
|
74 repo = self._load_fixture_and_fetch('unorderedbranch.svndump', |
60acc38eac96
clone: prefer tip of default to overall tip when updating
Martijn Pieters <mj@zopatista.com>
parents:
232
diff
changeset
|
75 stupid, noupdate=False) |
60acc38eac96
clone: prefer tip of default to overall tip when updating
Martijn Pieters <mj@zopatista.com>
parents:
232
diff
changeset
|
76 self.assertEqual(repo[None].branch(), 'default') |
60acc38eac96
clone: prefer tip of default to overall tip when updating
Martijn Pieters <mj@zopatista.com>
parents:
232
diff
changeset
|
77 self.assertTrue('tip' not in repo[None].tags()) |
60acc38eac96
clone: prefer tip of default to overall tip when updating
Martijn Pieters <mj@zopatista.com>
parents:
232
diff
changeset
|
78 |
60acc38eac96
clone: prefer tip of default to overall tip when updating
Martijn Pieters <mj@zopatista.com>
parents:
232
diff
changeset
|
79 def test_branch_tip_update_to_default_stupid(self): |
60acc38eac96
clone: prefer tip of default to overall tip when updating
Martijn Pieters <mj@zopatista.com>
parents:
232
diff
changeset
|
80 self.test_branch_tip_update_to_default(True) |
284
f8f9a2993705
Implement parseurl support (#revision in repository urls)
Martijn Pieters <mj@zopatista.com>
parents:
278
diff
changeset
|
81 |
f8f9a2993705
Implement parseurl support (#revision in repository urls)
Martijn Pieters <mj@zopatista.com>
parents:
278
diff
changeset
|
82 def test_branch_tip_update_to_branch_anchor(self): |
f8f9a2993705
Implement parseurl support (#revision in repository urls)
Martijn Pieters <mj@zopatista.com>
parents:
278
diff
changeset
|
83 repo = self._load_fixture_and_fetch_with_anchor( |
f8f9a2993705
Implement parseurl support (#revision in repository urls)
Martijn Pieters <mj@zopatista.com>
parents:
278
diff
changeset
|
84 'unorderedbranch.svndump', 'branch') |
f8f9a2993705
Implement parseurl support (#revision in repository urls)
Martijn Pieters <mj@zopatista.com>
parents:
278
diff
changeset
|
85 self.assertEqual(repo[None].branch(), 'branch') |
f8f9a2993705
Implement parseurl support (#revision in repository urls)
Martijn Pieters <mj@zopatista.com>
parents:
278
diff
changeset
|
86 self.assertEqual(repo[None].parents()[0], repo[repo.branchheads()[0]]) |
278
60acc38eac96
clone: prefer tip of default to overall tip when updating
Martijn Pieters <mj@zopatista.com>
parents:
232
diff
changeset
|
87 |
313
942f198b8ff5
hg_delta_editor: detect new branches issued from non-branch directories
Patrick Mezard <pmezard@gmail.com>
parents:
284
diff
changeset
|
88 def test_branches_weird_moves(self, stupid=False): |
942f198b8ff5
hg_delta_editor: detect new branches issued from non-branch directories
Patrick Mezard <pmezard@gmail.com>
parents:
284
diff
changeset
|
89 repo = self._load_fixture_and_fetch('renamedproject.svndump', stupid, |
942f198b8ff5
hg_delta_editor: detect new branches issued from non-branch directories
Patrick Mezard <pmezard@gmail.com>
parents:
284
diff
changeset
|
90 subdir='project') |
942f198b8ff5
hg_delta_editor: detect new branches issued from non-branch directories
Patrick Mezard <pmezard@gmail.com>
parents:
284
diff
changeset
|
91 heads = [repo[n] for n in repo.heads()] |
942f198b8ff5
hg_delta_editor: detect new branches issued from non-branch directories
Patrick Mezard <pmezard@gmail.com>
parents:
284
diff
changeset
|
92 heads = dict((ctx.branch(), ctx) for ctx in heads) |
942f198b8ff5
hg_delta_editor: detect new branches issued from non-branch directories
Patrick Mezard <pmezard@gmail.com>
parents:
284
diff
changeset
|
93 mdefault = sorted(heads['default'].manifest().keys()) |
942f198b8ff5
hg_delta_editor: detect new branches issued from non-branch directories
Patrick Mezard <pmezard@gmail.com>
parents:
284
diff
changeset
|
94 mbranch = sorted(heads['branch'].manifest().keys()) |
942f198b8ff5
hg_delta_editor: detect new branches issued from non-branch directories
Patrick Mezard <pmezard@gmail.com>
parents:
284
diff
changeset
|
95 self.assertEqual(mdefault, ['a', 'b', 'd/a']) |
942f198b8ff5
hg_delta_editor: detect new branches issued from non-branch directories
Patrick Mezard <pmezard@gmail.com>
parents:
284
diff
changeset
|
96 self.assertEqual(mbranch, ['a']) |
942f198b8ff5
hg_delta_editor: detect new branches issued from non-branch directories
Patrick Mezard <pmezard@gmail.com>
parents:
284
diff
changeset
|
97 |
942f198b8ff5
hg_delta_editor: detect new branches issued from non-branch directories
Patrick Mezard <pmezard@gmail.com>
parents:
284
diff
changeset
|
98 def test_branches_weird_moves_stupid(self): |
942f198b8ff5
hg_delta_editor: detect new branches issued from non-branch directories
Patrick Mezard <pmezard@gmail.com>
parents:
284
diff
changeset
|
99 self.test_branches_weird_moves(True) |
942f198b8ff5
hg_delta_editor: detect new branches issued from non-branch directories
Patrick Mezard <pmezard@gmail.com>
parents:
284
diff
changeset
|
100 |
117
3afe404042a3
Add a disabled test for unrelated branches
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
101 def suite(): |
3afe404042a3
Add a disabled test for unrelated branches
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
102 all = [unittest.TestLoader().loadTestsFromTestCase(TestFetchBranches), |
3afe404042a3
Add a disabled test for unrelated branches
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
103 ] |
3afe404042a3
Add a disabled test for unrelated branches
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
104 return unittest.TestSuite(all) |