annotate tests/test_fetch_branches.py @ 1570:d55c9d0ba350

tests: use scmutils.revsymbol instead of repo.__getitem__ for non-integers
author Paul Morelle <paul.morelle@octobus.net>
date Fri, 25 May 2018 11:52:03 +0200
parents 253b2ab253a1
children 7bb6562feb85
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
643
d2ef7220a079 tests: import test_util as the first module in all relevant tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 588
diff changeset
1 import test_util
d2ef7220a079 tests: import test_util as the first module in all relevant tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 588
diff changeset
2
117
3afe404042a3 Add a disabled test for unrelated branches
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
3 import unittest
3afe404042a3 Add a disabled test for unrelated branches
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
4
1039
3df6ed4e7561 drop support for pre-2.0 versions of Mercurial
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 950
diff changeset
5 from mercurial import error
284
f8f9a2993705 Implement parseurl support (#revision in repository urls)
Martijn Pieters <mj@zopatista.com>
parents: 278
diff changeset
6 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
7 from mercurial import node
2242dd1163c6 hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents: 131
diff changeset
8
1103
6e1dbf6cbc92 compathacks: new module to collect hacks to work around hg internals changing
Augie Fackler <raf@durin42.com>
parents: 1094
diff changeset
9 from hgsubversion import compathacks
6e1dbf6cbc92 compathacks: new module to collect hacks to work around hg internals changing
Augie Fackler <raf@durin42.com>
parents: 1094
diff changeset
10
1570
d55c9d0ba350 tests: use scmutils.revsymbol instead of repo.__getitem__ for non-integers
Paul Morelle <paul.morelle@octobus.net>
parents: 1482
diff changeset
11 revsymbol = test_util.revsymbol
d55c9d0ba350 tests: use scmutils.revsymbol instead of repo.__getitem__ for non-integers
Paul Morelle <paul.morelle@octobus.net>
parents: 1482
diff changeset
12
117
3afe404042a3 Add a disabled test for unrelated branches
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
13 class TestFetchBranches(test_util.TestBase):
1061
b8142bbf6656 test_fetch_branches: use stupid mode metaclass
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1048
diff changeset
14 stupid_mode_tests = True
b8142bbf6656 test_fetch_branches: use stupid mode metaclass
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1048
diff changeset
15
284
f8f9a2993705 Implement parseurl support (#revision in repository urls)
Martijn Pieters <mj@zopatista.com>
parents: 278
diff changeset
16 def _load_fixture_and_fetch_with_anchor(self, fixture_name, anchor):
866
20e73b5ab6f7 test_util: merge load_svndump_fixture() into TestBase
Patrick Mezard <patrick@mezard.eu>
parents: 865
diff changeset
17 repo_path = self.load_svndump(fixture_name)
20e73b5ab6f7 test_util: merge load_svndump_fixture() into TestBase
Patrick Mezard <patrick@mezard.eu>
parents: 865
diff changeset
18 source = '%s#%s' % (test_util.fileurl(repo_path), anchor)
816
86d124a8768e Fix hg.clone() calls changed by d976542986d2
Patrick Mezard <pmezard@gmail.com>
parents: 815
diff changeset
19 test_util.hgclone(self.ui(), source, self.wc_path)
576
d96aa92d9ad9 tests: silence test suite by using quiet UIs everywhere
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 551
diff changeset
20 return hg.repository(self.ui(), self.wc_path)
284
f8f9a2993705 Implement parseurl support (#revision in repository urls)
Martijn Pieters <mj@zopatista.com>
parents: 278
diff changeset
21
815
e62e84a9464b test_fetch_branches: stop comparing converted nodeids
Patrick Mezard <pmezard@gmail.com>
parents: 643
diff changeset
22 def branches(self, repo):
425
f5222d021665 tests: fix for new branch heads change in upstream hg.
Augie Fackler <durin42@gmail.com>
parents: 397
diff changeset
23 hctxs = [repo[hn] for hn in repo.heads()]
815
e62e84a9464b test_fetch_branches: stop comparing converted nodeids
Patrick Mezard <pmezard@gmail.com>
parents: 643
diff changeset
24 openbranches = set(ctx.branch() for ctx in hctxs if
e62e84a9464b test_fetch_branches: stop comparing converted nodeids
Patrick Mezard <pmezard@gmail.com>
parents: 643
diff changeset
25 ctx.extra().get('close', None) != '1')
e62e84a9464b test_fetch_branches: stop comparing converted nodeids
Patrick Mezard <pmezard@gmail.com>
parents: 643
diff changeset
26 closedbranches = set(ctx.branch() for ctx in hctxs if
e62e84a9464b test_fetch_branches: stop comparing converted nodeids
Patrick Mezard <pmezard@gmail.com>
parents: 643
diff changeset
27 ctx.extra().get('close', None) == '1')
e62e84a9464b test_fetch_branches: stop comparing converted nodeids
Patrick Mezard <pmezard@gmail.com>
parents: 643
diff changeset
28 return sorted(openbranches), sorted(closedbranches)
e62e84a9464b test_fetch_branches: stop comparing converted nodeids
Patrick Mezard <pmezard@gmail.com>
parents: 643
diff changeset
29
e62e84a9464b test_fetch_branches: stop comparing converted nodeids
Patrick Mezard <pmezard@gmail.com>
parents: 643
diff changeset
30 def openbranches(self, repo):
e62e84a9464b test_fetch_branches: stop comparing converted nodeids
Patrick Mezard <pmezard@gmail.com>
parents: 643
diff changeset
31 return self.branches(repo)[0]
372
a62965b179c1 Test for open branches in the pull result.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 344
diff changeset
32
1061
b8142bbf6656 test_fetch_branches: use stupid mode metaclass
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1048
diff changeset
33 def test_rename_branch_parent(self):
b8142bbf6656 test_fetch_branches: use stupid mode metaclass
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1048
diff changeset
34 repo = self._load_fixture_and_fetch('rename_branch_parent_dir.svndump')
551
d17cec76e769 replay: correctly handle renaming the parent dir of a branch
Augie Fackler <durin42@gmail.com>
parents: 473
diff changeset
35 heads = [repo[n] for n in repo.heads()]
d17cec76e769 replay: correctly handle renaming the parent dir of a branch
Augie Fackler <durin42@gmail.com>
parents: 473
diff changeset
36 heads = dict([(ctx.branch(), ctx) for ctx in heads])
d17cec76e769 replay: correctly handle renaming the parent dir of a branch
Augie Fackler <durin42@gmail.com>
parents: 473
diff changeset
37 # Let these tests disabled yet as the fix is not obvious
d17cec76e769 replay: correctly handle renaming the parent dir of a branch
Augie Fackler <durin42@gmail.com>
parents: 473
diff changeset
38 self.assertEqual(['dev_branch'], self.openbranches(repo))
d17cec76e769 replay: correctly handle renaming the parent dir of a branch
Augie Fackler <durin42@gmail.com>
parents: 473
diff changeset
39
1061
b8142bbf6656 test_fetch_branches: use stupid mode metaclass
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1048
diff changeset
40 def test_unrelatedbranch(self):
b8142bbf6656 test_fetch_branches: use stupid mode metaclass
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1048
diff changeset
41 repo = self._load_fixture_and_fetch('unrelatedbranch.svndump')
117
3afe404042a3 Add a disabled test for unrelated branches
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
42 heads = [repo[n] for n in repo.heads()]
3afe404042a3 Add a disabled test for unrelated branches
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
43 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
44 # 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
45 self.assertEqual(heads['branch1'].manifest().keys(), ['b'])
1482
253b2ab253a1 tests: add some sorted() calls on unsorted sets
Augie Fackler <raf@durin42.com>
parents: 1321
diff changeset
46 self.assertEqual(sorted(heads['branch2'].manifest().keys()),
253b2ab253a1 tests: add some sorted() calls on unsorted sets
Augie Fackler <raf@durin42.com>
parents: 1321
diff changeset
47 ['a', 'b'])
117
3afe404042a3 Add a disabled test for unrelated branches
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
48
1061
b8142bbf6656 test_fetch_branches: use stupid mode metaclass
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1048
diff changeset
49 def test_unorderedbranch(self):
b8142bbf6656 test_fetch_branches: use stupid mode metaclass
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1048
diff changeset
50 repo = self._load_fixture_and_fetch('unorderedbranch.svndump')
1570
d55c9d0ba350 tests: use scmutils.revsymbol instead of repo.__getitem__ for non-integers
Paul Morelle <paul.morelle@octobus.net>
parents: 1482
diff changeset
51 r = revsymbol(repo, 'branch')
131
4d42dbbb5127 hg_delta_editor: fix parent revision detection on branch copy
Patrick Mezard <pmezard@gmail.com>
parents: 120
diff changeset
52 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
53 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
54
1061
b8142bbf6656 test_fetch_branches: use stupid mode metaclass
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1048
diff changeset
55 def test_renamed_branch_to_trunk(self):
1232
ba8485b9fee0 editor: correctly import copies of directories from non-tracked or closed branches
David Schleimer <dschleimer@fb.com>
parents: 1103
diff changeset
56 repo = self._load_fixture_and_fetch('branch_rename_to_trunk.svndump')
1570
d55c9d0ba350 tests: use scmutils.revsymbol instead of repo.__getitem__ for non-integers
Paul Morelle <paul.morelle@octobus.net>
parents: 1482
diff changeset
57 self.assertEqual(revsymbol(repo, 'default').parents()[0].branch(), 'dev_branch')
d55c9d0ba350 tests: use scmutils.revsymbol instead of repo.__getitem__ for non-integers
Paul Morelle <paul.morelle@octobus.net>
parents: 1482
diff changeset
58 self.assert_('iota' in revsymbol(repo, 'default'))
d55c9d0ba350 tests: use scmutils.revsymbol instead of repo.__getitem__ for non-integers
Paul Morelle <paul.morelle@octobus.net>
parents: 1482
diff changeset
59 self.assertEqual(revsymbol(repo, 'old_trunk').parents()[0].branch(), 'default')
d55c9d0ba350 tests: use scmutils.revsymbol instead of repo.__getitem__ for non-integers
Paul Morelle <paul.morelle@octobus.net>
parents: 1482
diff changeset
60 self.assert_('iota' not in revsymbol(repo, 'old_trunk'))
372
a62965b179c1 Test for open branches in the pull result.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 344
diff changeset
61 expected = ['default', 'old_trunk']
a62965b179c1 Test for open branches in the pull result.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 344
diff changeset
62 self.assertEqual(self.openbranches(repo), expected)
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
63
1061
b8142bbf6656 test_fetch_branches: use stupid mode metaclass
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1048
diff changeset
64 def test_replace_trunk_with_branch(self):
b8142bbf6656 test_fetch_branches: use stupid mode metaclass
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1048
diff changeset
65 repo = self._load_fixture_and_fetch('replace_trunk_with_branch.svndump')
1570
d55c9d0ba350 tests: use scmutils.revsymbol instead of repo.__getitem__ for non-integers
Paul Morelle <paul.morelle@octobus.net>
parents: 1482
diff changeset
66 self.assertEqual(revsymbol(repo, 'default').parents()[0].branch(), 'test')
d55c9d0ba350 tests: use scmutils.revsymbol instead of repo.__getitem__ for non-integers
Paul Morelle <paul.morelle@octobus.net>
parents: 1482
diff changeset
67 self.assertEqual(revsymbol(repo, 'tip').branch(), 'default')
d55c9d0ba350 tests: use scmutils.revsymbol instead of repo.__getitem__ for non-integers
Paul Morelle <paul.morelle@octobus.net>
parents: 1482
diff changeset
68 self.assertEqual(revsymbol(repo, 'tip').extra().get('close'), '1')
372
a62965b179c1 Test for open branches in the pull result.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 344
diff changeset
69 self.assertEqual(self.openbranches(repo), ['default'])
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
70
1061
b8142bbf6656 test_fetch_branches: use stupid mode metaclass
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1048
diff changeset
71 def test_copybeforeclose(self):
b8142bbf6656 test_fetch_branches: use stupid mode metaclass
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1048
diff changeset
72 repo = self._load_fixture_and_fetch('copybeforeclose.svndump')
1570
d55c9d0ba350 tests: use scmutils.revsymbol instead of repo.__getitem__ for non-integers
Paul Morelle <paul.morelle@octobus.net>
parents: 1482
diff changeset
73 self.assertEqual(revsymbol(repo, 'tip').branch(), 'test')
d55c9d0ba350 tests: use scmutils.revsymbol instead of repo.__getitem__ for non-integers
Paul Morelle <paul.morelle@octobus.net>
parents: 1482
diff changeset
74 self.assertEqual(revsymbol(repo, 'test').extra().get('close'), '1')
d55c9d0ba350 tests: use scmutils.revsymbol instead of repo.__getitem__ for non-integers
Paul Morelle <paul.morelle@octobus.net>
parents: 1482
diff changeset
75 self.assertEqual(revsymbol(repo, 'test')['b'].data(), 'a\n')
397
1b9d004a8c0a branches: correctly deal with branch closing directly after copy/rename
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
76
1232
ba8485b9fee0 editor: correctly import copies of directories from non-tracked or closed branches
David Schleimer <dschleimer@fb.com>
parents: 1103
diff changeset
77 def test_copyafterclose(self):
ba8485b9fee0 editor: correctly import copies of directories from non-tracked or closed branches
David Schleimer <dschleimer@fb.com>
parents: 1103
diff changeset
78 repo = self._load_fixture_and_fetch('copyafterclose.svndump')
1570
d55c9d0ba350 tests: use scmutils.revsymbol instead of repo.__getitem__ for non-integers
Paul Morelle <paul.morelle@octobus.net>
parents: 1482
diff changeset
79 self.assertEqual(revsymbol(repo, 'tip').branch(), 'test')
d55c9d0ba350 tests: use scmutils.revsymbol instead of repo.__getitem__ for non-integers
Paul Morelle <paul.morelle@octobus.net>
parents: 1482
diff changeset
80 self.assert_('file' in revsymbol(repo, 'test'))
d55c9d0ba350 tests: use scmutils.revsymbol instead of repo.__getitem__ for non-integers
Paul Morelle <paul.morelle@octobus.net>
parents: 1482
diff changeset
81 self.assertEqual(revsymbol(repo, 'test')['file'].data(), 'trunk2\n')
d55c9d0ba350 tests: use scmutils.revsymbol instead of repo.__getitem__ for non-integers
Paul Morelle <paul.morelle@octobus.net>
parents: 1482
diff changeset
82 self.assert_('dir/file' in revsymbol(repo, 'test'))
d55c9d0ba350 tests: use scmutils.revsymbol instead of repo.__getitem__ for non-integers
Paul Morelle <paul.morelle@octobus.net>
parents: 1482
diff changeset
83 self.assertEqual(revsymbol(repo, 'test')['dir/file'].data(), 'trunk2\n')
1232
ba8485b9fee0 editor: correctly import copies of directories from non-tracked or closed branches
David Schleimer <dschleimer@fb.com>
parents: 1103
diff changeset
84
ba8485b9fee0 editor: correctly import copies of directories from non-tracked or closed branches
David Schleimer <dschleimer@fb.com>
parents: 1103
diff changeset
85
1061
b8142bbf6656 test_fetch_branches: use stupid mode metaclass
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1048
diff changeset
86 def test_branch_create_with_dir_delete_works(self):
b8142bbf6656 test_fetch_branches: use stupid mode metaclass
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1048
diff changeset
87 repo = self._load_fixture_and_fetch('branch_create_with_dir_delete.svndump')
1570
d55c9d0ba350 tests: use scmutils.revsymbol instead of repo.__getitem__ for non-integers
Paul Morelle <paul.morelle@octobus.net>
parents: 1482
diff changeset
88 self.assertEqual(sorted(revsymbol(repo, 'tip').manifest().keys()),
1321
a36e87ae2380 tests: always compare manifest keys in sorted order
Siddharth Agarwal <sid0@fb.com>
parents: 1232
diff changeset
89 ['alpha', 'beta', 'gamma', 'iota', ])
232
c0063328587f Fix and test for directory deletes during branch creation.
Augie Fackler <durin42@gmail.com>
parents: 201
diff changeset
90
1061
b8142bbf6656 test_fetch_branches: use stupid mode metaclass
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1048
diff changeset
91 def test_branch_tip_update_to_default(self):
278
60acc38eac96 clone: prefer tip of default to overall tip when updating
Martijn Pieters <mj@zopatista.com>
parents: 232
diff changeset
92 repo = self._load_fixture_and_fetch('unorderedbranch.svndump',
1061
b8142bbf6656 test_fetch_branches: use stupid mode metaclass
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1048
diff changeset
93 noupdate=False)
278
60acc38eac96 clone: prefer tip of default to overall tip when updating
Martijn Pieters <mj@zopatista.com>
parents: 232
diff changeset
94 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
95 self.assertTrue('tip' not in repo[None].tags())
337
46e69be8e2c8 Reorganize to have a more conventional module structure.
Augie Fackler <durin42@gmail.com>
parents: 326
diff changeset
96
344
4dfab1b8b7be Mention what failed when given a non-numeric revision to clone/pull.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 337
diff changeset
97 def test_branch_pull_anchor(self):
1039
3df6ed4e7561 drop support for pre-2.0 versions of Mercurial
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 950
diff changeset
98 self.assertRaises(error.RepoLookupError,
344
4dfab1b8b7be Mention what failed when given a non-numeric revision to clone/pull.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 337
diff changeset
99 self._load_fixture_and_fetch_with_anchor,
4dfab1b8b7be Mention what failed when given a non-numeric revision to clone/pull.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 337
diff changeset
100 'unorderedbranch.svndump', 'NaN')
284
f8f9a2993705 Implement parseurl support (#revision in repository urls)
Martijn Pieters <mj@zopatista.com>
parents: 278
diff changeset
101 repo = self._load_fixture_and_fetch_with_anchor(
344
4dfab1b8b7be Mention what failed when given a non-numeric revision to clone/pull.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 337
diff changeset
102 'unorderedbranch.svndump', '4')
1103
6e1dbf6cbc92 compathacks: new module to collect hacks to work around hg internals changing
Augie Fackler <raf@durin42.com>
parents: 1094
diff changeset
103 self.assertTrue('c' not in compathacks.branchset(repo))
278
60acc38eac96 clone: prefer tip of default to overall tip when updating
Martijn Pieters <mj@zopatista.com>
parents: 232
diff changeset
104
1061
b8142bbf6656 test_fetch_branches: use stupid mode metaclass
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1048
diff changeset
105 def test_branches_weird_moves(self):
865
04729f3a3d17 test_util: merge load_fixture_and_fetch() into TestBase method
Patrick Mezard <patrick@mezard.eu>
parents: 833
diff changeset
106 repo = self._load_fixture_and_fetch('renamedproject.svndump',
313
942f198b8ff5 hg_delta_editor: detect new branches issued from non-branch directories
Patrick Mezard <pmezard@gmail.com>
parents: 284
diff changeset
107 subdir='project')
942f198b8ff5 hg_delta_editor: detect new branches issued from non-branch directories
Patrick Mezard <pmezard@gmail.com>
parents: 284
diff changeset
108 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
109 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
110 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
111 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
112 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
113 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
114
1061
b8142bbf6656 test_fetch_branches: use stupid mode metaclass
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1048
diff changeset
115 def test_branch_delete_parent_dir(self):
b8142bbf6656 test_fetch_branches: use stupid mode metaclass
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1048
diff changeset
116 repo = self._load_fixture_and_fetch('branch_delete_parent_dir.svndump')
815
e62e84a9464b test_fetch_branches: stop comparing converted nodeids
Patrick Mezard <pmezard@gmail.com>
parents: 643
diff changeset
117 openb, closedb = self.branches(repo)
e62e84a9464b test_fetch_branches: stop comparing converted nodeids
Patrick Mezard <pmezard@gmail.com>
parents: 643
diff changeset
118 self.assertEqual(openb, [])
e62e84a9464b test_fetch_branches: stop comparing converted nodeids
Patrick Mezard <pmezard@gmail.com>
parents: 643
diff changeset
119 self.assertEqual(closedb, ['dev_branch'])
1570
d55c9d0ba350 tests: use scmutils.revsymbol instead of repo.__getitem__ for non-integers
Paul Morelle <paul.morelle@octobus.net>
parents: 1482
diff changeset
120 self.assertEqual(list(revsymbol(repo, 'dev_branch')), ['foo'])
473
45df4d9320fa Fix 'parent dir of a branch is deleted' refactoring from 343da84.
Max Bowsher <maxb@f2s.com>
parents: 425
diff changeset
121
1061
b8142bbf6656 test_fetch_branches: use stupid mode metaclass
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1048
diff changeset
122 def test_replace_branch_with_branch(self):
b8142bbf6656 test_fetch_branches: use stupid mode metaclass
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1048
diff changeset
123 repo = self._load_fixture_and_fetch('replace_branch_with_branch.svndump')
1048
903c9c9dfe6a tests: count revisions explicitly
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1044
diff changeset
124 self.assertEqual(7, test_util.repolen(repo))
582
44c56a7727c4 editor: fix issamefile() and copy detection in replay mode
Patrick Mezard <pmezard@gmail.com>
parents: 576
diff changeset
125 # tip is former topological branch1 being closed
1570
d55c9d0ba350 tests: use scmutils.revsymbol instead of repo.__getitem__ for non-integers
Paul Morelle <paul.morelle@octobus.net>
parents: 1482
diff changeset
126 ctx = revsymbol(repo, 'tip')
582
44c56a7727c4 editor: fix issamefile() and copy detection in replay mode
Patrick Mezard <pmezard@gmail.com>
parents: 576
diff changeset
127 self.assertEqual('1', ctx.extra().get('close', '0'))
44c56a7727c4 editor: fix issamefile() and copy detection in replay mode
Patrick Mezard <pmezard@gmail.com>
parents: 576
diff changeset
128 self.assertEqual('branch1', ctx.branch())
44c56a7727c4 editor: fix issamefile() and copy detection in replay mode
Patrick Mezard <pmezard@gmail.com>
parents: 576
diff changeset
129 # r5 is where the replacement takes place
44c56a7727c4 editor: fix issamefile() and copy detection in replay mode
Patrick Mezard <pmezard@gmail.com>
parents: 576
diff changeset
130 ctx = repo[5]
588
2723152c8111 stupid: fix getcopies() logic
Patrick Mezard <pmezard@gmail.com>
parents: 587
diff changeset
131 self.assertEqual(set(['a', 'c', 'dir/e', 'dir2/e', 'f', 'g']), set(ctx))
582
44c56a7727c4 editor: fix issamefile() and copy detection in replay mode
Patrick Mezard <pmezard@gmail.com>
parents: 576
diff changeset
132 self.assertEqual('0', ctx.extra().get('close', '0'))
44c56a7727c4 editor: fix issamefile() and copy detection in replay mode
Patrick Mezard <pmezard@gmail.com>
parents: 576
diff changeset
133 self.assertEqual('branch1', ctx.branch())
44c56a7727c4 editor: fix issamefile() and copy detection in replay mode
Patrick Mezard <pmezard@gmail.com>
parents: 576
diff changeset
134 self.assertEqual('c\n', ctx['c'].data())
585
c3ba4ca81d16 editor: fix replaced files content in replay mode
Patrick Mezard <pmezard@gmail.com>
parents: 582
diff changeset
135 self.assertEqual('d\n', ctx['a'].data())
587
c06f59441f8e editor: fix replaced directory copies
Patrick Mezard <pmezard@gmail.com>
parents: 585
diff changeset
136 self.assertEqual('e\n', ctx['dir/e'].data())
c06f59441f8e editor: fix replaced directory copies
Patrick Mezard <pmezard@gmail.com>
parents: 585
diff changeset
137 self.assertEqual('e\n', ctx['dir2/e'].data())
588
2723152c8111 stupid: fix getcopies() logic
Patrick Mezard <pmezard@gmail.com>
parents: 587
diff changeset
138 self.assertEqual('f\n', ctx['f'].data())
2723152c8111 stupid: fix getcopies() logic
Patrick Mezard <pmezard@gmail.com>
parents: 587
diff changeset
139 self.assertEqual('g\n', ctx['g'].data())
2723152c8111 stupid: fix getcopies() logic
Patrick Mezard <pmezard@gmail.com>
parents: 587
diff changeset
140 for f in ctx:
2723152c8111 stupid: fix getcopies() logic
Patrick Mezard <pmezard@gmail.com>
parents: 587
diff changeset
141 self.assertTrue(not ctx[f].renamed())
582
44c56a7727c4 editor: fix issamefile() and copy detection in replay mode
Patrick Mezard <pmezard@gmail.com>
parents: 576
diff changeset
142
1093
791382a21cc4 layouts: add support for configuring branches directory
David Schleimer <dschleimer@fb.com>
parents: 1061
diff changeset
143 def test_misspelled_branches_tags(self):
791382a21cc4 layouts: add support for configuring branches directory
David Schleimer <dschleimer@fb.com>
parents: 1061
diff changeset
144 config = {
791382a21cc4 layouts: add support for configuring branches directory
David Schleimer <dschleimer@fb.com>
parents: 1061
diff changeset
145 'hgsubversion.branchdir': 'branchez',
791382a21cc4 layouts: add support for configuring branches directory
David Schleimer <dschleimer@fb.com>
parents: 1061
diff changeset
146 'hgsubversion.tagpaths': 'tagz',
791382a21cc4 layouts: add support for configuring branches directory
David Schleimer <dschleimer@fb.com>
parents: 1061
diff changeset
147 }
791382a21cc4 layouts: add support for configuring branches directory
David Schleimer <dschleimer@fb.com>
parents: 1061
diff changeset
148 '''Tests using the tags dir for branches and the branches dir for tags'''
791382a21cc4 layouts: add support for configuring branches directory
David Schleimer <dschleimer@fb.com>
parents: 1061
diff changeset
149 repo = self._load_fixture_and_fetch('misspelled_branches_tags.svndump',
791382a21cc4 layouts: add support for configuring branches directory
David Schleimer <dschleimer@fb.com>
parents: 1061
diff changeset
150 layout='standard',
791382a21cc4 layouts: add support for configuring branches directory
David Schleimer <dschleimer@fb.com>
parents: 1061
diff changeset
151 config=config)
791382a21cc4 layouts: add support for configuring branches directory
David Schleimer <dschleimer@fb.com>
parents: 1061
diff changeset
152
791382a21cc4 layouts: add support for configuring branches directory
David Schleimer <dschleimer@fb.com>
parents: 1061
diff changeset
153 heads = set([repo[n].branch() for n in repo.heads()])
791382a21cc4 layouts: add support for configuring branches directory
David Schleimer <dschleimer@fb.com>
parents: 1061
diff changeset
154 expected_heads = set(['default', 'branch'])
791382a21cc4 layouts: add support for configuring branches directory
David Schleimer <dschleimer@fb.com>
parents: 1061
diff changeset
155
791382a21cc4 layouts: add support for configuring branches directory
David Schleimer <dschleimer@fb.com>
parents: 1061
diff changeset
156 self.assertEqual(heads, expected_heads)
791382a21cc4 layouts: add support for configuring branches directory
David Schleimer <dschleimer@fb.com>
parents: 1061
diff changeset
157
791382a21cc4 layouts: add support for configuring branches directory
David Schleimer <dschleimer@fb.com>
parents: 1061
diff changeset
158 tags = set(repo.tags())
791382a21cc4 layouts: add support for configuring branches directory
David Schleimer <dschleimer@fb.com>
parents: 1061
diff changeset
159 expected_tags = set(['tip', 'tag_from_trunk', 'tag_from_branch'])
791382a21cc4 layouts: add support for configuring branches directory
David Schleimer <dschleimer@fb.com>
parents: 1061
diff changeset
160 self.assertEqual(tags, expected_tags)
791382a21cc4 layouts: add support for configuring branches directory
David Schleimer <dschleimer@fb.com>
parents: 1061
diff changeset
161
791382a21cc4 layouts: add support for configuring branches directory
David Schleimer <dschleimer@fb.com>
parents: 1061
diff changeset
162 def test_subdir_branches_tags(self):
791382a21cc4 layouts: add support for configuring branches directory
David Schleimer <dschleimer@fb.com>
parents: 1061
diff changeset
163 '''Tests using the tags dir for branches and the branches dir for tags'''
791382a21cc4 layouts: add support for configuring branches directory
David Schleimer <dschleimer@fb.com>
parents: 1061
diff changeset
164 config = {
791382a21cc4 layouts: add support for configuring branches directory
David Schleimer <dschleimer@fb.com>
parents: 1061
diff changeset
165 'hgsubversion.branchdir': 'bran/ches',
791382a21cc4 layouts: add support for configuring branches directory
David Schleimer <dschleimer@fb.com>
parents: 1061
diff changeset
166 'hgsubversion.tagpaths': 'ta/gs',
791382a21cc4 layouts: add support for configuring branches directory
David Schleimer <dschleimer@fb.com>
parents: 1061
diff changeset
167 }
791382a21cc4 layouts: add support for configuring branches directory
David Schleimer <dschleimer@fb.com>
parents: 1061
diff changeset
168 repo = self._load_fixture_and_fetch('subdir_branches_tags.svndump',
791382a21cc4 layouts: add support for configuring branches directory
David Schleimer <dschleimer@fb.com>
parents: 1061
diff changeset
169 layout='standard',
791382a21cc4 layouts: add support for configuring branches directory
David Schleimer <dschleimer@fb.com>
parents: 1061
diff changeset
170 config=config)
791382a21cc4 layouts: add support for configuring branches directory
David Schleimer <dschleimer@fb.com>
parents: 1061
diff changeset
171
791382a21cc4 layouts: add support for configuring branches directory
David Schleimer <dschleimer@fb.com>
parents: 1061
diff changeset
172 heads = set([repo[n].branch() for n in repo.heads()])
791382a21cc4 layouts: add support for configuring branches directory
David Schleimer <dschleimer@fb.com>
parents: 1061
diff changeset
173 expected_heads = set(['default', 'branch'])
791382a21cc4 layouts: add support for configuring branches directory
David Schleimer <dschleimer@fb.com>
parents: 1061
diff changeset
174
791382a21cc4 layouts: add support for configuring branches directory
David Schleimer <dschleimer@fb.com>
parents: 1061
diff changeset
175 self.assertEqual(heads, expected_heads)
791382a21cc4 layouts: add support for configuring branches directory
David Schleimer <dschleimer@fb.com>
parents: 1061
diff changeset
176
791382a21cc4 layouts: add support for configuring branches directory
David Schleimer <dschleimer@fb.com>
parents: 1061
diff changeset
177 tags = set(repo.tags())
791382a21cc4 layouts: add support for configuring branches directory
David Schleimer <dschleimer@fb.com>
parents: 1061
diff changeset
178 expected_tags = set(['tip', 'tag_from_trunk', 'tag_from_branch'])
791382a21cc4 layouts: add support for configuring branches directory
David Schleimer <dschleimer@fb.com>
parents: 1061
diff changeset
179 self.assertEqual(tags, expected_tags)
791382a21cc4 layouts: add support for configuring branches directory
David Schleimer <dschleimer@fb.com>
parents: 1061
diff changeset
180
1094
9a7e3dbd0f6e layouts: add support for an infix between tbt and the hg root
David Schleimer <dschleimer@fb.com>
parents: 1093
diff changeset
181 def test_subproject_fetch(self):
9a7e3dbd0f6e layouts: add support for an infix between tbt and the hg root
David Schleimer <dschleimer@fb.com>
parents: 1093
diff changeset
182 config = {
9a7e3dbd0f6e layouts: add support for an infix between tbt and the hg root
David Schleimer <dschleimer@fb.com>
parents: 1093
diff changeset
183 'hgsubversion.infix': 'project',
9a7e3dbd0f6e layouts: add support for an infix between tbt and the hg root
David Schleimer <dschleimer@fb.com>
parents: 1093
diff changeset
184 }
9a7e3dbd0f6e layouts: add support for an infix between tbt and the hg root
David Schleimer <dschleimer@fb.com>
parents: 1093
diff changeset
185 repo = self._load_fixture_and_fetch('subprojects.svndump',
9a7e3dbd0f6e layouts: add support for an infix between tbt and the hg root
David Schleimer <dschleimer@fb.com>
parents: 1093
diff changeset
186 layout='standard',
9a7e3dbd0f6e layouts: add support for an infix between tbt and the hg root
David Schleimer <dschleimer@fb.com>
parents: 1093
diff changeset
187 config=config)
9a7e3dbd0f6e layouts: add support for an infix between tbt and the hg root
David Schleimer <dschleimer@fb.com>
parents: 1093
diff changeset
188
9a7e3dbd0f6e layouts: add support for an infix between tbt and the hg root
David Schleimer <dschleimer@fb.com>
parents: 1093
diff changeset
189 heads = set([repo[n].branch() for n in repo.heads()])
9a7e3dbd0f6e layouts: add support for an infix between tbt and the hg root
David Schleimer <dschleimer@fb.com>
parents: 1093
diff changeset
190 expected_heads = set(['default', 'branch'])
9a7e3dbd0f6e layouts: add support for an infix between tbt and the hg root
David Schleimer <dschleimer@fb.com>
parents: 1093
diff changeset
191 self.assertEqual(heads, expected_heads)
9a7e3dbd0f6e layouts: add support for an infix between tbt and the hg root
David Schleimer <dschleimer@fb.com>
parents: 1093
diff changeset
192
9a7e3dbd0f6e layouts: add support for an infix between tbt and the hg root
David Schleimer <dschleimer@fb.com>
parents: 1093
diff changeset
193 tags = set(repo.tags())
9a7e3dbd0f6e layouts: add support for an infix between tbt and the hg root
David Schleimer <dschleimer@fb.com>
parents: 1093
diff changeset
194 expected_tags = set(['tip', 'tag_from_trunk', 'tag_from_branch'])
9a7e3dbd0f6e layouts: add support for an infix between tbt and the hg root
David Schleimer <dschleimer@fb.com>
parents: 1093
diff changeset
195 self.assertEqual(tags, expected_tags)
9a7e3dbd0f6e layouts: add support for an infix between tbt and the hg root
David Schleimer <dschleimer@fb.com>
parents: 1093
diff changeset
196
9a7e3dbd0f6e layouts: add support for an infix between tbt and the hg root
David Schleimer <dschleimer@fb.com>
parents: 1093
diff changeset
197 for head in repo.heads():
9a7e3dbd0f6e layouts: add support for an infix between tbt and the hg root
David Schleimer <dschleimer@fb.com>
parents: 1093
diff changeset
198 ctx = repo[head]
9a7e3dbd0f6e layouts: add support for an infix between tbt and the hg root
David Schleimer <dschleimer@fb.com>
parents: 1093
diff changeset
199 self.assertFalse('project/file' in ctx, 'failed to strip infix')
9a7e3dbd0f6e layouts: add support for an infix between tbt and the hg root
David Schleimer <dschleimer@fb.com>
parents: 1093
diff changeset
200 self.assertTrue('file' in ctx, 'failed to track a simple file')
9a7e3dbd0f6e layouts: add support for an infix between tbt and the hg root
David Schleimer <dschleimer@fb.com>
parents: 1093
diff changeset
201 self.assertFalse('other/phile' in ctx, 'pulled in other project')
9a7e3dbd0f6e layouts: add support for an infix between tbt and the hg root
David Schleimer <dschleimer@fb.com>
parents: 1093
diff changeset
202 self.assertFalse('phile' in ctx, 'merged other project in repo')
9a7e3dbd0f6e layouts: add support for an infix between tbt and the hg root
David Schleimer <dschleimer@fb.com>
parents: 1093
diff changeset
203
9a7e3dbd0f6e layouts: add support for an infix between tbt and the hg root
David Schleimer <dschleimer@fb.com>
parents: 1093
diff changeset
204
1093
791382a21cc4 layouts: add support for configuring branches directory
David Schleimer <dschleimer@fb.com>
parents: 1061
diff changeset
205 def suite():
791382a21cc4 layouts: add support for configuring branches directory
David Schleimer <dschleimer@fb.com>
parents: 1061
diff changeset
206 all_tests = [unittest.TestLoader().loadTestsFromTestCase(TestFetchBranches),
791382a21cc4 layouts: add support for configuring branches directory
David Schleimer <dschleimer@fb.com>
parents: 1061
diff changeset
207 ]
791382a21cc4 layouts: add support for configuring branches directory
David Schleimer <dschleimer@fb.com>
parents: 1061
diff changeset
208 return unittest.TestSuite(all_tests)