comparison tests/test_single_dir_clone.py @ 500:5ddc212dbc56

push: fix for single directory repository layouts
author Daniel Tang <dytang@cs.purdue.edu>
date Tue, 20 Oct 2009 14:34:00 -0400
parents 1fd3cfa47c5e
children 89eda60c90b3
comparison
equal deleted inserted replaced
499:1fd3cfa47c5e 500:5ddc212dbc56
1 import shutil 1 import shutil
2
3 from mercurial import commands
4 from mercurial import context
5 from mercurial import hg
6 from mercurial import node
7 from mercurial import ui
2 8
3 import test_util 9 import test_util
4 10
5 11
6 class TestSingleDir(test_util.TestBase): 12 class TestSingleDir(test_util.TestBase):
68 assert '[.]' not in extdata 74 assert '[.]' not in extdata
69 print extdata 75 print extdata
70 expect = '' # Not honestly sure what this should be... 76 expect = '' # Not honestly sure what this should be...
71 test = 4 77 test = 4
72 self.assertEqual(self.repo[test]['.hgsvnexternals'].data(), expect) 78 self.assertEqual(self.repo[test]['.hgsvnexternals'].data(), expect)
79
80 def test_push_single_dir(self):
81 # Tests simple pushing from default branch to a single dir repo
82 repo = self._load_fixture_and_fetch('branch_from_tag.svndump',
83 stupid=False,
84 layout='single',
85 subdir='')
86 def file_callback(repo, memctx, path):
87 if path == 'adding_file':
88 return context.memfilectx(path=path,
89 data='foo',
90 islink=False,
91 isexec=False,
92 copied=False)
93 raise IOError()
94 ctx = context.memctx(repo,
95 (repo['tip'].node(), node.nullid),
96 'automated test',
97 ['adding_file'],
98 file_callback,
99 'an_author',
100 '2009-10-19 18:49:30 -0500',
101 {'branch': 'default',})
102 repo.commitctx(ctx)
103 hg.update(repo, repo['tip'].node())
104 self.pushrevisions()
105 self.assertTrue('adding_file' in self.svnls(''))
106
107 def test_push_single_dir_branch(self):
108 # Tests local branches pushing to a single dir repo. Creates a fork at
109 # tip. The default branch adds a file called default, while branch foo
110 # adds a file called foo, then tries to push the foo branch and default
111 # branch in that order.
112 repo = self._load_fixture_and_fetch('branch_from_tag.svndump',
113 stupid=False,
114 layout='single',
115 subdir='')
116 def file_callback(data):
117 def cb(repo, memctx, path):
118 if path == data:
119 return context.memfilectx(path=path,
120 data=data,
121 islink=False,
122 isexec=False,
123 copied=False)
124 raise IOError()
125 return cb
126
127 def commit_to_branch(name, parent):
128 repo.commitctx(context.memctx(repo,
129 (parent, node.nullid),
130 'automated test (%s)' % name,
131 [name],
132 file_callback(name),
133 'an_author',
134 '2009-10-19 18:49:30 -0500',
135 {'branch': name,}))
136
137 parent = repo['tip'].node()
138 commit_to_branch('default', parent)
139 commit_to_branch('foo', parent)
140 hg.update(repo, repo['foo'].node())
141 self.pushrevisions()
142 repo = self.repo # repo is outdated after the rebase happens, refresh
143 self.assertTrue('foo' in self.svnls(''))
144 self.assertEqual(repo.branchtags().keys(), ['default'])
145 # Have to cross to another branch head, so hg.update doesn't work
146 commands.update(ui.ui(),
147 self.repo,
148 self.repo.branchheads('default')[1],
149 clean=True)
150 self.pushrevisions()
151 self.assertTrue('default' in self.svnls(''))
152 self.assertEquals(len(self.repo.branchheads('default')), 1)
153