Mercurial > hgsubversion
comparison tests/test_push_command.py @ 356:62f90781eb10
push: don't refuse to push if it looks like we haven't pulled all changes.
We can't rely on the most-recent change number matching our most-recent
change number because there can be changes in svn that produce no
corresponding hg changeset.
| author | Augie Fackler <durin42@gmail.com> |
|---|---|
| date | Wed, 27 May 2009 21:40:58 -0500 |
| parents | 5d0d9424913f |
| children | db3a53a2cd76 37718f514acb |
comparison
equal
deleted
inserted
replaced
| 355:256863a65141 | 356:62f90781eb10 |
|---|---|
| 1 import atexit | 1 import atexit |
| 2 import os | 2 import os |
| 3 import random | 3 import random |
| 4 import shutil | |
| 4 import socket | 5 import socket |
| 5 import subprocess | 6 import subprocess |
| 6 import unittest | 7 import unittest |
| 7 | 8 |
| 8 from mercurial import context | 9 from mercurial import context |
| 210 assert False, "this is impossible, adding_file2 should not be in this manifest." | 211 assert False, "this is impossible, adding_file2 should not be in this manifest." |
| 211 except revlog.LookupError, e: | 212 except revlog.LookupError, e: |
| 212 pass | 213 pass |
| 213 self.assertEqual(tip.branch(), 'default') | 214 self.assertEqual(tip.branch(), 'default') |
| 214 | 215 |
| 215 def test_push_to_branch(self): | 216 def test_push_to_branch(self, push=True): |
| 216 repo = self.repo | 217 repo = self.repo |
| 217 def file_callback(repo, memctx, path): | 218 def file_callback(repo, memctx, path): |
| 218 if path == 'adding_file': | 219 if path == 'adding_file': |
| 219 return context.memfilectx(path=path, | 220 return context.memfilectx(path=path, |
| 220 data='foo', | 221 data='foo', |
| 229 file_callback, | 230 file_callback, |
| 230 'an_author', | 231 'an_author', |
| 231 '2008-10-07 20:59:48 -0500', | 232 '2008-10-07 20:59:48 -0500', |
| 232 {'branch': 'the_branch',}) | 233 {'branch': 'the_branch',}) |
| 233 new_hash = repo.commitctx(ctx) | 234 new_hash = repo.commitctx(ctx) |
| 234 #commands.update(ui.ui(), self.repo, node='tip') | 235 hg.update(repo, repo['tip'].node()) |
| 235 hg.update(repo, repo['tip'].node()) | 236 if push: |
| 236 self.pushrevisions() | 237 self.pushrevisions() |
| 237 tip = self.repo['tip'] | 238 tip = self.repo['tip'] |
| 238 self.assertNotEqual(tip.node(), new_hash) | 239 self.assertNotEqual(tip.node(), new_hash) |
| 239 self.assertEqual(tip['adding_file'].data(), 'foo') | 240 self.assertEqual(tip['adding_file'].data(), 'foo') |
| 240 self.assertEqual(tip.branch(), 'the_branch') | 241 self.assertEqual(tip.branch(), 'the_branch') |
| 242 | |
| 243 def push_to_non_tip(self): | |
| 244 self.test_push_to_branch(push=False) | |
| 245 wc2path = self.wc_path + '_clone' | |
| 246 u = self.repo.ui | |
| 247 hg.clone(self.repo.ui, self.wc_path, wc2path, update=False) | |
| 248 self.pushrevisions() | |
| 249 oldf = open(os.path.join(self.wc_path, '.hg', 'hgrc')) | |
| 250 hgrc = oldf.read() | |
| 251 oldf.close() | |
| 252 shutil.rmtree(self.wc_path) | |
| 253 hg.clone(u, wc2path, self.wc_path, update=False) | |
| 254 oldf = open(os.path.join(self.wc_path, '.hg', 'hgrc'), 'w') | |
| 255 oldf.write(hgrc) | |
| 256 oldf.close() | |
| 257 | |
| 258 # do a commit here | |
| 259 self.commitchanges([('foobaz', 'foobaz', 'This file is added on default.', ), | |
| 260 ], | |
| 261 parent='default', | |
| 262 message='commit to default') | |
| 263 from hgsubversion import svncommands | |
| 264 svncommands.rebuildmeta(u, | |
| 265 self.repo, | |
| 266 os.path.dirname(self.repo.path), | |
| 267 args=[test_util.fileurl(self.repo_path)]) | |
| 268 | |
| 269 | |
| 270 hg.update(self.repo, self.repo['tip'].node()) | |
| 271 oldnode = self.repo['tip'].hex() | |
| 272 self.pushrevisions(expected_extra_back=1) | |
| 273 self.assertNotEqual(oldnode, self.repo['tip'].hex(), 'Revision was not pushed.') | |
| 241 | 274 |
| 242 def test_delete_file(self): | 275 def test_delete_file(self): |
| 243 repo = self.repo | 276 repo = self.repo |
| 244 def file_callback(repo, memctx, path): | 277 def file_callback(repo, memctx, path): |
| 245 raise IOError() | 278 raise IOError() |
