comparison tests/test_push_command.py @ 331:75f082b5897e

Switch to using url scheme wrappers instead of duplicating each command we wrap. The 'hg svn url' command has been killed; the replacement is '.hg/hgrc'. More stuff related to its disappearance has been stripped, including two tests. HgChangeReceiver now takes a UUID argument, which it uses to ensure that remote repositories remain unchanged. This is a temporary solution, and I'm not entirely satisfied with how it's done either. Access to the UUID file has been isolated in a HgChangeReceiver property. Some more tests have been updated to use ui.pushbuffer()/popbuffer(), and to pass through the Mercurial API. Moved the arguments to wrappers.pull() to the UI configuration. Also, remove HgChangeReceiver.opts in favour of a 'usebranchnames' instance & configuration variable. The name is taken from the ConvertExtension.
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Fri, 15 May 2009 19:18:43 +0200
parents 3848a7f9b983
children c0b943cef0c3
comparison
equal deleted inserted replaced
330:5f8f2fd4fd54 331:75f082b5897e
1 import atexit
1 import os 2 import os
3 import random
2 import socket 4 import socket
3 import subprocess 5 import subprocess
4 import unittest 6 import unittest
5 7
6 from mercurial import context 8 from mercurial import context
9 from mercurial import commands
7 from mercurial import hg 10 from mercurial import hg
8 from mercurial import node 11 from mercurial import node
9 from mercurial import ui 12 from mercurial import ui
10 from mercurial import revlog 13 from mercurial import revlog
11 from mercurial import util as hgutil 14 from mercurial import util as hgutil
12 15
13 import wrappers
14 import test_util 16 import test_util
15 import time 17 import time
16 18
17 19
18 class PushOverSvnserveTests(test_util.TestBase): 20 class PushOverSvnserveTests(test_util.TestBase):
19 def setUp(self): 21 def setUp(self):
20 test_util.TestBase.setUp(self) 22 test_util.TestBase.setUp(self)
21 test_util.load_svndump_fixture(self.repo_path, 'simple_branch.svndump') 23 test_util.load_svndump_fixture(self.repo_path, 'simple_branch.svndump')
22 open(os.path.join(self.repo_path, 'conf', 'svnserve.conf'), 24 open(os.path.join(self.repo_path, 'conf', 'svnserve.conf'),
23 'w').write('[general]\nanon-access=write\n[sasl]\n') 25 'w').write('[general]\nanon-access=write\n[sasl]\n')
24 # Paranoia: we try and connect to localhost on 3689 before we start 26 self.port = random.randint(socket.IPPORT_USERRESERVED, 65535)
25 # svnserve. If it is running, we force the test to fail early. 27 self.host = 'localhost'
26 user_has_own_svnserve = False 28 args = ['svnserve', '--daemon', '--foreground',
27 try: 29 '--listen-port=%d' % self.port,
28 s = socket.socket() 30 '--listen-host=%s' % self.host,
29 s.settimeout(0.3) 31 '--root=%s' % self.repo_path]
30 s.connect(('localhost', 3690)) 32 svnserve = subprocess.Popen(args, stdout=subprocess.PIPE,
31 s.close() 33 stderr=subprocess.STDOUT)
32 user_has_own_svnserve = True 34 self.svnserve_pid = svnserve.pid
33 except:
34 pass
35 if user_has_own_svnserve:
36 assert False, ('You appear to be running your own svnserve!'
37 ' You can probably ignore this test failure.')
38 args = ['svnserve', '-d', '--foreground', '-r', self.repo_path]
39 self.svnserve_pid = subprocess.Popen(args).pid
40 time.sleep(2) 35 time.sleep(2)
41 wrappers.clone(None, ui.ui(), source='svn://localhost/', 36 commands.clone(ui.ui(), 'svn://%s:%d/' % (self.host, self.port),
42 dest=self.wc_path, noupdate=True) 37 self.wc_path, noupdate=True)
43 38
44 def tearDown(self): 39 def tearDown(self):
45 os.system('kill -9 %d' % self.svnserve_pid) 40 os.kill(self.svnserve_pid, 9)
46 test_util.TestBase.tearDown(self) 41 test_util.TestBase.tearDown(self)
47 42
48 def test_push_to_default(self, commit=True): 43 def test_push_to_default(self, commit=True):
49 repo = self.repo 44 repo = self.repo
50 old_tip = repo['tip'].node() 45 old_tip = repo['tip'].node()
68 new_hash = repo.commitctx(ctx) 63 new_hash = repo.commitctx(ctx)
69 if not commit: 64 if not commit:
70 return # some tests use this test as an extended setup. 65 return # some tests use this test as an extended setup.
71 hg.update(repo, repo['tip'].node()) 66 hg.update(repo, repo['tip'].node())
72 oldauthor = repo['tip'].user() 67 oldauthor = repo['tip'].user()
73 wrappers.push(None, ui.ui(), repo=self.repo) 68 commands.push(repo.ui, repo)
74 tip = self.repo['tip'] 69 tip = self.repo['tip']
75 self.assertNotEqual(oldauthor, tip.user()) 70 self.assertNotEqual(oldauthor, tip.user())
76 self.assertNotEqual(tip.node(), old_tip) 71 self.assertNotEqual(tip.node(), old_tip)
77 self.assertEqual(tip.parents()[0].node(), expected_parent) 72 self.assertEqual(tip.parents()[0].node(), expected_parent)
78 self.assertEqual(tip['adding_file'].data(), 'foo') 73 self.assertEqual(tip['adding_file'].data(), 'foo')
170 '2008-12-21 16:32:00 -0500', 165 '2008-12-21 16:32:00 -0500',
171 {'branch': 'localbranch', }) 166 {'branch': 'localbranch', })
172 newhash = self.repo.commitctx(ctx) 167 newhash = self.repo.commitctx(ctx)
173 repo = self.repo 168 repo = self.repo
174 hg.update(repo, newhash) 169 hg.update(repo, newhash)
175 wrappers.push(None, ui.ui(), repo=repo) 170 commands.push(repo.ui, repo)
176 self.assertEqual(self.repo['tip'].parents()[0].parents()[0].node(), oldtiphash) 171 self.assertEqual(self.repo['tip'].parents()[0].parents()[0].node(), oldtiphash)
177 self.assertEqual(self.repo['tip'].files(), ['delta', ]) 172 self.assertEqual(self.repo['tip'].files(), ['delta', ])
178 self.assertEqual(self.repo['tip'].manifest().keys(), 173 self.assertEqual(self.repo['tip'].manifest().keys(),
179 ['alpha', 'beta', 'gamma', 'delta']) 174 ['alpha', 'beta', 'gamma', 'delta'])
180 175