annotate tests/test_single_dir_clone.py @ 751:5e54e333ec3d

wrappers: pass on subdir when creating obtaining svnmeta The incoming, outgoing and push commands are updated. Running any of parents, diff and rebase as the first command will fail, suggesting an 'hg svn rebuildmeta'.
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Wed, 17 Nov 2010 11:48:58 +0100
parents 1041fb1bec8c
children e698be84c22d
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
701
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 691
diff changeset
7 from mercurial import dispatch
500
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
8 from mercurial import commands
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
9 from mercurial import context
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
10 from mercurial import hg
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
11 from mercurial import node
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
12 from mercurial import ui
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
13
499
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
14 class TestSingleDir(test_util.TestBase):
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
15 def test_clone_single_dir_simple(self):
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
16 repo = self._load_fixture_and_fetch('branch_from_tag.svndump',
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
17 stupid=False,
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
18 layout='single',
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
19 subdir='')
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
20 self.assertEqual(repo.branchtags().keys(), ['default'])
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
21 self.assertEqual(repo['tip'].manifest().keys(),
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
22 ['trunk/beta',
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
23 'tags/copied_tag/alpha',
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
24 'trunk/alpha',
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
25 'tags/copied_tag/beta',
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
26 'branches/branch_from_tag/alpha',
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
27 'tags/tag_r3/alpha',
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
28 'tags/tag_r3/beta',
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
29 'branches/branch_from_tag/beta'])
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
30
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
31 def test_auto_detect_single(self):
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
32 repo = self._load_fixture_and_fetch('branch_from_tag.svndump',
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
33 stupid=False,
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
34 layout='auto')
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
35 self.assertEqual(repo.branchtags().keys(), ['default',
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
36 'branch_from_tag'])
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
37 oldmanifest = test_util.filtermanifest(repo['default'].manifest().keys())
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
38 # remove standard layout
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
39 shutil.rmtree(self.wc_path)
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
40 # try again with subdir to get single dir clone
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
41 repo = self._load_fixture_and_fetch('branch_from_tag.svndump',
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
42 stupid=False,
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
43 layout='auto',
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
44 subdir='trunk')
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
45 self.assertEqual(repo.branchtags().keys(), ['default', ])
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
46 self.assertEqual(repo['default'].manifest().keys(), oldmanifest)
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
47
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
48 def test_externals_single(self):
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
49 repo = self._load_fixture_and_fetch('externals.svndump',
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
50 stupid=False,
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
51 layout='single')
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
52 for rev in repo:
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
53 assert '.hgsvnexternals' not in repo[rev].manifest()
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
54 return # TODO enable test when externals in single are fixed
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
55 expect = """[.]
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
56 -r2 ^/externals/project2@2 deps/project2
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
57 [subdir]
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
58 ^/externals/project1 deps/project1
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
59 [subdir2]
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
60 ^/externals/project1 deps/project1
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
61 """
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
62 test = 2
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
63 self.assertEqual(self.repo[test]['.hgsvnexternals'].data(), expect)
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
64
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
65 def test_externals_single_whole_repo(self):
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
66 # This is the test which demonstrates the brokenness of externals
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
67 return # TODO enable test when externals in single are fixed
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
68 repo = self._load_fixture_and_fetch('externals.svndump',
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
69 stupid=False,
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
70 layout='single',
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
71 subdir='')
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
72 for rev in repo:
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
73 rc = repo[rev]
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
74 if '.hgsvnexternals' in rc:
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
75 extdata = rc['.hgsvnexternals'].data()
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
76 assert '[.]' not in extdata
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
77 print extdata
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
78 expect = '' # Not honestly sure what this should be...
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
79 test = 4
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
80 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
81
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
82 def test_push_single_dir(self):
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
83 # 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
84 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
85 stupid=False,
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
86 layout='single',
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
87 subdir='')
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
88 def file_callback(repo, memctx, path):
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
89 if path == 'adding_file':
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
90 return context.memfilectx(path=path,
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
91 data='foo',
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
92 islink=False,
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
93 isexec=False,
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
94 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
95 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
96 ctx = context.memctx(repo,
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
97 (repo['tip'].node(), node.nullid),
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
98 'automated test',
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
99 ['adding_file'],
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
100 file_callback,
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
101 'an_author',
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
102 '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
103 {'branch': 'default',})
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
104 repo.commitctx(ctx)
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
105 hg.update(repo, repo['tip'].node())
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
106 self.pushrevisions()
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
107 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
108
502
89eda60c90b3 single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents: 500
diff changeset
109 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
110 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
111 stupid=False,
89eda60c90b3 single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents: 500
diff changeset
112 layout='single',
89eda60c90b3 single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents: 500
diff changeset
113 subdir='trunk')
89eda60c90b3 single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents: 500
diff changeset
114 def filectxfn(repo, memctx, path):
89eda60c90b3 single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents: 500
diff changeset
115 return context.memfilectx(path=path,
89eda60c90b3 single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents: 500
diff changeset
116 data='contents of %s' % path,
89eda60c90b3 single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents: 500
diff changeset
117 islink=False,
89eda60c90b3 single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents: 500
diff changeset
118 isexec=False,
89eda60c90b3 single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents: 500
diff changeset
119 copied=False)
89eda60c90b3 single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents: 500
diff changeset
120 ctx = context.memctx(repo,
89eda60c90b3 single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents: 500
diff changeset
121 (repo['tip'].node(), node.nullid),
89eda60c90b3 single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents: 500
diff changeset
122 'automated test',
89eda60c90b3 single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents: 500
diff changeset
123 ['bogus'],
89eda60c90b3 single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents: 500
diff changeset
124 filectxfn,
89eda60c90b3 single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents: 500
diff changeset
125 'an_author',
89eda60c90b3 single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents: 500
diff changeset
126 '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
127 {'branch': 'localhacking',})
89eda60c90b3 single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents: 500
diff changeset
128 n = repo.commitctx(ctx)
89eda60c90b3 single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents: 500
diff changeset
129 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
130 'contents of bogus')
89eda60c90b3 single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents: 500
diff changeset
131 before = repo['tip'].hex()
89eda60c90b3 single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents: 500
diff changeset
132 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
133 self.pushrevisions()
89eda60c90b3 single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents: 500
diff changeset
134 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
135 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
136 'contents of bogus')
89eda60c90b3 single: add another test for single-dir push
Augie Fackler <durin42@gmail.com>
parents: 500
diff changeset
137
691
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 643
diff changeset
138 def test_push_single_dir_one_incoming_and_two_outgoing(self):
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 643
diff changeset
139 # Tests simple pushing from default branch to a single dir repo
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 643
diff changeset
140 # Pushes two outgoing over one incoming svn rev
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 643
diff changeset
141 # (used to cause an "unknown revision")
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 643
diff changeset
142 # This can happen if someone committed to svn since our last pull (race).
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 643
diff changeset
143 repo = self._load_fixture_and_fetch('branch_from_tag.svndump',
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 643
diff changeset
144 stupid=False,
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 643
diff changeset
145 layout='single',
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 643
diff changeset
146 subdir='trunk')
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 643
diff changeset
147 self._add_svn_rev({'trunk/alpha': 'Changed'})
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 643
diff changeset
148 def file_callback(repo, memctx, path):
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 643
diff changeset
149 return context.memfilectx(path=path,
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 643
diff changeset
150 data='data of %s' % path,
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 643
diff changeset
151 islink=False,
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 643
diff changeset
152 isexec=False,
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 643
diff changeset
153 copied=False)
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 643
diff changeset
154 for fn in ['one', 'two']:
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 643
diff changeset
155 ctx = context.memctx(repo,
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 643
diff changeset
156 (repo['tip'].node(), node.nullid),
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 643
diff changeset
157 'automated test',
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 643
diff changeset
158 [fn],
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 643
diff changeset
159 file_callback,
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 643
diff changeset
160 'an_author',
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 643
diff changeset
161 '2009-10-19 18:49:30 -0500',
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 643
diff changeset
162 {'branch': 'default',})
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 643
diff changeset
163 repo.commitctx(ctx)
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 643
diff changeset
164 hg.update(repo, repo['tip'].node())
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 643
diff changeset
165 self.pushrevisions(expected_extra_back=1)
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 643
diff changeset
166 self.assertTrue('trunk/one' in self.svnls(''))
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 643
diff changeset
167 self.assertTrue('trunk/two' in self.svnls(''))
a45365f1492a push: fix case where we get >1 revs back after svn commit
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 643
diff changeset
168
500
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
169 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
170 # 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
171 # 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
172 # 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
173 # branch in that order.
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
174 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
175 stupid=False,
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
176 layout='single',
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
177 subdir='')
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
178 def file_callback(data):
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
179 def cb(repo, memctx, path):
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
180 if path == data:
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
181 return context.memfilectx(path=path,
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
182 data=data,
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
183 islink=False,
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
184 isexec=False,
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
185 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
186 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
187 return cb
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
188
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
189 def commit_to_branch(name, parent):
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
190 repo.commitctx(context.memctx(repo,
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
191 (parent, node.nullid),
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
192 'automated test (%s)' % name,
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
193 [name],
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
194 file_callback(name),
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
195 'an_author',
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
196 '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
197 {'branch': name,}))
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
198
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
199 parent = repo['tip'].node()
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
200 commit_to_branch('default', parent)
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
201 commit_to_branch('foo', parent)
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
202 hg.update(repo, repo['foo'].node())
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
203 self.pushrevisions()
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
204 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
205 self.assertTrue('foo' in self.svnls(''))
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
206 self.assertEqual(repo.branchtags().keys(), ['default'])
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
207 # 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
208 commands.update(ui.ui(),
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
209 self.repo,
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
210 self.repo.branchheads('default')[1],
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
211 clean=True)
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
212 self.pushrevisions()
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
213 self.assertTrue('default' in self.svnls(''))
5ddc212dbc56 push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents: 499
diff changeset
214 self.assertEquals(len(self.repo.branchheads('default')), 1)
577
930bb6df19a0 tests: make sure single dir clone tests get run by non-nose users
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 531
diff changeset
215
712
1041fb1bec8c tests & help: fix compatibility with Mercurial 1.4 and earlier.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 701
diff changeset
216 @test_util.requiresoption('branch')
701
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 691
diff changeset
217 def test_push_single_dir_renamed_branch(self, stupid=False):
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 691
diff changeset
218 # Tests pulling and pushing with a renamed branch
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 691
diff changeset
219 # Based on test_push_single_dir
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 691
diff changeset
220 test_util.load_svndump_fixture(self.repo_path,
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 691
diff changeset
221 'branch_from_tag.svndump')
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 691
diff changeset
222 cmd = ['clone', '--layout=single', '--branch=flaf']
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 691
diff changeset
223 if stupid:
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 691
diff changeset
224 cmd.append('--stupid')
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 691
diff changeset
225 cmd += [test_util.fileurl(self.repo_path), self.wc_path]
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 691
diff changeset
226 dispatch.dispatch(cmd)
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 691
diff changeset
227
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 691
diff changeset
228 def file_callback(repo, memctx, path):
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 691
diff changeset
229 if path == 'adding_file':
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 691
diff changeset
230 return context.memfilectx(path=path,
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 691
diff changeset
231 data='foo',
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 691
diff changeset
232 islink=False,
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 691
diff changeset
233 isexec=False,
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 691
diff changeset
234 copied=False)
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 691
diff changeset
235 raise IOError(errno.EINVAL, 'Invalid operation: ' + path)
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 691
diff changeset
236 ctx = context.memctx(self.repo,
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 691
diff changeset
237 (self.repo['tip'].node(), node.nullid),
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 691
diff changeset
238 'automated test',
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 691
diff changeset
239 ['adding_file'],
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 691
diff changeset
240 file_callback,
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 691
diff changeset
241 'an_author',
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 691
diff changeset
242 '2009-10-19 18:49:30 -0500',
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 691
diff changeset
243 {'branch': 'default',})
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 691
diff changeset
244 self.repo.commitctx(ctx)
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 691
diff changeset
245 hg.update(self.repo, self.repo['tip'].node())
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 691
diff changeset
246 self.pushrevisions()
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 691
diff changeset
247 self.assertTrue('adding_file' in self.svnls(''))
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 691
diff changeset
248
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 691
diff changeset
249 self.assertEquals(set(['flaf']),
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 691
diff changeset
250 set(self.repo[i].branch() for i in self.repo))
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 691
diff changeset
251
712
1041fb1bec8c tests & help: fix compatibility with Mercurial 1.4 and earlier.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 701
diff changeset
252 @test_util.requiresoption('branch')
701
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 691
diff changeset
253 def test_push_single_dir_renamed_branch_stupid(self):
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 691
diff changeset
254 self.test_push_single_dir_renamed_branch(True)
3b8088de027d clone: replace the --singlebranch with overloading for --branch
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 691
diff changeset
255
577
930bb6df19a0 tests: make sure single dir clone tests get run by non-nose users
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 531
diff changeset
256 def suite():
930bb6df19a0 tests: make sure single dir clone tests get run by non-nose users
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 531
diff changeset
257 all = [unittest.TestLoader().loadTestsFromTestCase(TestSingleDir)]
930bb6df19a0 tests: make sure single dir clone tests get run by non-nose users
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 531
diff changeset
258 return unittest.TestSuite(all)