annotate tests/test_single_dir_clone.py @ 1063:449c61eeace7

test_fetch_exec: use metaclass stupid mode tests
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Fri, 09 Aug 2013 23:45:55 +0200
parents 3092b3c109a8
children 2668785264d7
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: 577
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: 577
diff changeset
2
531
cf4fe45bf8fd Change all instantiations of IOError to set both errno and strerror.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 502
diff changeset
3 import errno
499
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
4 import shutil
577
930bb6df19a0 tests: make sure single dir clone tests get run by non-nose users
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 531
diff changeset
5 import unittest
499
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
6
500
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
7 from mercurial import commands
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
8 from mercurial import context
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
9 from mercurial import hg
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
10 from mercurial import node
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
11 from mercurial import ui
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
12
1047
3092b3c109a8 tests: split single directory tests that push & clone in two modules
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1044
diff changeset
13 class TestSingleDirClone(test_util.TestBase):
499
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
14 def test_clone_single_dir_simple(self):
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
15 repo = self._load_fixture_and_fetch('branch_from_tag.svndump',
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
16 stupid=False,
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
17 layout='single',
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
18 subdir='')
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
19 self.assertEqual(repo.branchtags().keys(), ['default'])
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
20 self.assertEqual(repo['tip'].manifest().keys(),
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
21 ['trunk/beta',
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
22 'tags/copied_tag/alpha',
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
23 'trunk/alpha',
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
24 'tags/copied_tag/beta',
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
25 'branches/branch_from_tag/alpha',
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
26 'tags/tag_r3/alpha',
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
27 'tags/tag_r3/beta',
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
28 'branches/branch_from_tag/beta'])
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
29
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
30 def test_auto_detect_single(self):
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
31 repo = self._load_fixture_and_fetch('branch_from_tag.svndump',
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
32 stupid=False,
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
33 layout='auto')
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
34 self.assertEqual(repo.branchtags().keys(), ['default',
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
35 'branch_from_tag'])
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
36 oldmanifest = test_util.filtermanifest(repo['default'].manifest().keys())
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
37 # remove standard layout
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
38 shutil.rmtree(self.wc_path)
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
39 # try again with subdir to get single dir clone
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
40 repo = self._load_fixture_and_fetch('branch_from_tag.svndump',
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
41 stupid=False,
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
42 layout='auto',
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
43 subdir='trunk')
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
44 self.assertEqual(repo.branchtags().keys(), ['default', ])
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
45 self.assertEqual(repo['default'].manifest().keys(), oldmanifest)
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
46
888
c6388ed0ec0a svnmeta: only remove directory components in normalize()
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents: 871
diff changeset
47 def test_clone_subdir_is_file_prefix(self, stupid=False):
c6388ed0ec0a svnmeta: only remove directory components in normalize()
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents: 871
diff changeset
48 FIXTURE = 'subdir_is_file_prefix.svndump'
c6388ed0ec0a svnmeta: only remove directory components in normalize()
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents: 871
diff changeset
49 repo = self._load_fixture_and_fetch(FIXTURE,
c6388ed0ec0a svnmeta: only remove directory components in normalize()
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents: 871
diff changeset
50 stupid=stupid,
c6388ed0ec0a svnmeta: only remove directory components in normalize()
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents: 871
diff changeset
51 layout='single',
c6388ed0ec0a svnmeta: only remove directory components in normalize()
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents: 871
diff changeset
52 subdir=test_util.subdir[FIXTURE])
c6388ed0ec0a svnmeta: only remove directory components in normalize()
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents: 871
diff changeset
53 self.assertEqual(repo.branchtags().keys(), ['default'])
c6388ed0ec0a svnmeta: only remove directory components in normalize()
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents: 871
diff changeset
54 self.assertEqual(repo['tip'].manifest().keys(), ['flaf.txt'])
c6388ed0ec0a svnmeta: only remove directory components in normalize()
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents: 871
diff changeset
55
499
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
56 def test_externals_single(self):
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
57 repo = self._load_fixture_and_fetch('externals.svndump',
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
58 stupid=False,
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
59 layout='single')
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
60 for rev in repo:
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
61 assert '.hgsvnexternals' not in repo[rev].manifest()
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
62 return # TODO enable test when externals in single are fixed
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
63 expect = """[.]
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
64 -r2 ^/externals/project2@2 deps/project2
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
65 [subdir]
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
66 ^/externals/project1 deps/project1
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
67 [subdir2]
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
68 ^/externals/project1 deps/project1
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
69 """
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
70 test = 2
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
71 self.assertEqual(self.repo[test]['.hgsvnexternals'].data(), expect)
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
72
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
73 def test_externals_single_whole_repo(self):
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
74 # This is the test which demonstrates the brokenness of externals
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
75 return # TODO enable test when externals in single are fixed
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
76 repo = self._load_fixture_and_fetch('externals.svndump',
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
77 stupid=False,
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
78 layout='single',
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
79 subdir='')
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
80 for rev in repo:
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
81 rc = repo[rev]
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
82 if '.hgsvnexternals' in rc:
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
83 extdata = rc['.hgsvnexternals'].data()
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
84 assert '[.]' not in extdata
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
85 print extdata
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
86 expect = '' # Not honestly sure what this should be...
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
87 test = 4
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
88 self.assertEqual(self.repo[test]['.hgsvnexternals'].data(), expect)