Mercurial > hgsubversion
annotate tests/test_single_dir_clone.py @ 542:bb00f7ca5b8c
Rewrite simple_branch.sh fixture from svn dump
I needed it to reproduce the space in branch issue, but failed to do so. At
least I recreated the fixture, so here it is.
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Tue, 02 Feb 2010 23:20:42 +0100 |
parents | cf4fe45bf8fd |
children | 930bb6df19a0 |
rev | line source |
---|---|
531
cf4fe45bf8fd
Change all instantiations of IOError to set both errno and strerror.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
502
diff
changeset
|
1 import errno |
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
2 import shutil |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
3 |
500
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
4 from mercurial import commands |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
5 from mercurial import context |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
6 from mercurial import hg |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
7 from mercurial import node |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
8 from mercurial import ui |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
9 |
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
10 import test_util |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
11 |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
12 |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
13 class TestSingleDir(test_util.TestBase): |
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 |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
47 def test_externals_single(self): |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
48 repo = self._load_fixture_and_fetch('externals.svndump', |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
49 stupid=False, |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
50 layout='single') |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
51 for rev in repo: |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
52 assert '.hgsvnexternals' not in repo[rev].manifest() |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
53 return # TODO enable test when externals in single are fixed |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
54 expect = """[.] |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
55 -r2 ^/externals/project2@2 deps/project2 |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
56 [subdir] |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
57 ^/externals/project1 deps/project1 |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
58 [subdir2] |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
59 ^/externals/project1 deps/project1 |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
60 """ |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
61 test = 2 |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
62 self.assertEqual(self.repo[test]['.hgsvnexternals'].data(), expect) |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
63 |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
64 def test_externals_single_whole_repo(self): |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
65 # This is the test which demonstrates the brokenness of externals |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
66 return # TODO enable test when externals in single are fixed |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
67 repo = self._load_fixture_and_fetch('externals.svndump', |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
68 stupid=False, |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
69 layout='single', |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
70 subdir='') |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
71 for rev in repo: |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
72 rc = repo[rev] |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
73 if '.hgsvnexternals' in rc: |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
74 extdata = rc['.hgsvnexternals'].data() |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
75 assert '[.]' not in extdata |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
76 print extdata |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
77 expect = '' # Not honestly sure what this should be... |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
78 test = 4 |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
79 self.assertEqual(self.repo[test]['.hgsvnexternals'].data(), expect) |
500
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
80 |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
81 def test_push_single_dir(self): |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
82 # Tests simple pushing from default branch to a single dir repo |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
83 repo = self._load_fixture_and_fetch('branch_from_tag.svndump', |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
84 stupid=False, |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
85 layout='single', |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
86 subdir='') |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
87 def file_callback(repo, memctx, path): |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
88 if path == 'adding_file': |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
89 return context.memfilectx(path=path, |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
90 data='foo', |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
91 islink=False, |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
92 isexec=False, |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
93 copied=False) |
531
cf4fe45bf8fd
Change all instantiations of IOError to set both errno and strerror.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
502
diff
changeset
|
94 raise IOError(errno.EINVAL, 'Invalid operation: ' + path) |
500
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
95 ctx = context.memctx(repo, |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
96 (repo['tip'].node(), node.nullid), |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
97 'automated test', |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
98 ['adding_file'], |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
99 file_callback, |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
100 'an_author', |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
101 '2009-10-19 18:49:30 -0500', |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
102 {'branch': 'default',}) |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
103 repo.commitctx(ctx) |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
104 hg.update(repo, repo['tip'].node()) |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
105 self.pushrevisions() |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
106 self.assertTrue('adding_file' in self.svnls('')) |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
107 |
502
89eda60c90b3
single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents:
500
diff
changeset
|
108 def test_push_single_dir_at_subdir(self): |
89eda60c90b3
single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents:
500
diff
changeset
|
109 repo = self._load_fixture_and_fetch('branch_from_tag.svndump', |
89eda60c90b3
single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents:
500
diff
changeset
|
110 stupid=False, |
89eda60c90b3
single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents:
500
diff
changeset
|
111 layout='single', |
89eda60c90b3
single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents:
500
diff
changeset
|
112 subdir='trunk') |
89eda60c90b3
single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents:
500
diff
changeset
|
113 def filectxfn(repo, memctx, path): |
89eda60c90b3
single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents:
500
diff
changeset
|
114 return context.memfilectx(path=path, |
89eda60c90b3
single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents:
500
diff
changeset
|
115 data='contents of %s' % path, |
89eda60c90b3
single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents:
500
diff
changeset
|
116 islink=False, |
89eda60c90b3
single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents:
500
diff
changeset
|
117 isexec=False, |
89eda60c90b3
single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents:
500
diff
changeset
|
118 copied=False) |
89eda60c90b3
single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents:
500
diff
changeset
|
119 ctx = context.memctx(repo, |
89eda60c90b3
single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents:
500
diff
changeset
|
120 (repo['tip'].node(), node.nullid), |
89eda60c90b3
single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents:
500
diff
changeset
|
121 'automated test', |
89eda60c90b3
single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents:
500
diff
changeset
|
122 ['bogus'], |
89eda60c90b3
single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents:
500
diff
changeset
|
123 filectxfn, |
89eda60c90b3
single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents:
500
diff
changeset
|
124 'an_author', |
89eda60c90b3
single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents:
500
diff
changeset
|
125 '2009-10-19 18:49:30 -0500', |
89eda60c90b3
single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents:
500
diff
changeset
|
126 {'branch': 'localhacking',}) |
89eda60c90b3
single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents:
500
diff
changeset
|
127 n = repo.commitctx(ctx) |
89eda60c90b3
single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents:
500
diff
changeset
|
128 self.assertEqual(self.repo['tip']['bogus'].data(), |
89eda60c90b3
single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents:
500
diff
changeset
|
129 'contents of bogus') |
89eda60c90b3
single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents:
500
diff
changeset
|
130 before = repo['tip'].hex() |
89eda60c90b3
single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents:
500
diff
changeset
|
131 hg.update(repo, self.repo['tip'].hex()) |
89eda60c90b3
single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents:
500
diff
changeset
|
132 self.pushrevisions() |
89eda60c90b3
single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents:
500
diff
changeset
|
133 self.assertNotEqual(before, self.repo['tip'].hex()) |
89eda60c90b3
single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents:
500
diff
changeset
|
134 self.assertEqual(self.repo['tip']['bogus'].data(), |
89eda60c90b3
single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents:
500
diff
changeset
|
135 'contents of bogus') |
89eda60c90b3
single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents:
500
diff
changeset
|
136 |
500
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
137 def test_push_single_dir_branch(self): |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
138 # Tests local branches pushing to a single dir repo. Creates a fork at |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
139 # tip. The default branch adds a file called default, while branch foo |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
140 # adds a file called foo, then tries to push the foo branch and default |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
141 # branch in that order. |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
142 repo = self._load_fixture_and_fetch('branch_from_tag.svndump', |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
143 stupid=False, |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
144 layout='single', |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
145 subdir='') |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
146 def file_callback(data): |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
147 def cb(repo, memctx, path): |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
148 if path == data: |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
149 return context.memfilectx(path=path, |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
150 data=data, |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
151 islink=False, |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
152 isexec=False, |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
153 copied=False) |
531
cf4fe45bf8fd
Change all instantiations of IOError to set both errno and strerror.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
502
diff
changeset
|
154 raise IOError(errno.EINVAL, 'Invalid operation: ' + path) |
500
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
155 return cb |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
156 |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
157 def commit_to_branch(name, parent): |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
158 repo.commitctx(context.memctx(repo, |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
159 (parent, node.nullid), |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
160 'automated test (%s)' % name, |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
161 [name], |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
162 file_callback(name), |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
163 'an_author', |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
164 '2009-10-19 18:49:30 -0500', |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
165 {'branch': name,})) |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
166 |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
167 parent = repo['tip'].node() |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
168 commit_to_branch('default', parent) |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
169 commit_to_branch('foo', parent) |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
170 hg.update(repo, repo['foo'].node()) |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
171 self.pushrevisions() |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
172 repo = self.repo # repo is outdated after the rebase happens, refresh |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
173 self.assertTrue('foo' in self.svnls('')) |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
174 self.assertEqual(repo.branchtags().keys(), ['default']) |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
175 # Have to cross to another branch head, so hg.update doesn't work |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
176 commands.update(ui.ui(), |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
177 self.repo, |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
178 self.repo.branchheads('default')[1], |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
179 clean=True) |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
180 self.pushrevisions() |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
181 self.assertTrue('default' in self.svnls('')) |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
182 self.assertEquals(len(self.repo.branchheads('default')), 1) |