42
40
from bzrlib.bundle.serializer.v4 import BundleSerializerV4
43
41
from bzrlib.repofmt import knitrepo
44
42
from bzrlib.tests import (
48
48
from bzrlib.transform import TreeTransform
49
from bzrlib.tests import (
54
51
def get_text(vf, key):
512
509
if not _mod_revision.is_null(rev_id):
513
rh = self.b1.revision_history()
514
self.applyDeprecated(symbol_versioning.deprecated_in((2, 4, 0)),
515
tree.branch.set_revision_history, rh[:rh.index(rev_id)+1])
510
tree.branch.generate_revision_history(rev_id)
517
512
delta = tree.changes_from(self.b1.repository.revision_tree(rev_id))
518
513
self.assertFalse(delta.has_changed(),
1423
1418
from bzrlib.testament import Testament
1424
1419
# monkey patch gpg signing mechanism
1425
1420
bzrlib.gpg.GPGStrategy = bzrlib.gpg.LoopbackGPGStrategy
1426
new_config = test_commit.MustSignConfig(branch)
1427
commit.Commit(config=new_config).commit(message="base",
1421
new_config = test_commit.MustSignConfig()
1422
commit.Commit(config_stack=new_config).commit(message="base",
1428
1423
allow_pointless=True,
1430
1425
working_tree=tree_a)
1839
1834
bundle, then the ConnectionReset error should be propagated.
1841
1836
# Instantiate a server that will provoke a ConnectionReset
1842
sock_server = _DisconnectingTCPServer()
1837
sock_server = DisconnectingServer()
1843
1838
self.start_server(sock_server)
1844
1839
# We don't really care what the url is since the server will close the
1845
1840
# connection without interpreting it
1847
1842
self.assertRaises(errors.ConnectionReset, read_mergeable_from_url, url)
1850
class _DisconnectingTCPServer(object):
1851
"""A TCP server that immediately closes any connection made to it."""
1853
def start_server(self):
1854
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
1855
self.sock.bind(('127.0.0.1', 0))
1857
self.port = self.sock.getsockname()[1]
1858
self.thread = threading.Thread(
1859
name='%s (port %d)' % (self.__class__.__name__, self.port),
1860
target=self.accept_and_close)
1863
def accept_and_close(self):
1864
conn, addr = self.sock.accept()
1865
conn.shutdown(socket.SHUT_RDWR)
1845
class DisconnectingHandler(SocketServer.BaseRequestHandler):
1846
"""A request handler that immediately closes any connection made to it."""
1849
self.request.close()
1852
class DisconnectingServer(test_server.TestingTCPServerInAThread):
1855
super(DisconnectingServer, self).__init__(
1857
test_server.TestingTCPServer,
1858
DisconnectingHandler)
1868
1860
def get_url(self):
1869
return 'bzr://127.0.0.1:%d/' % (self.port,)
1871
def stop_server(self):
1873
# make sure the thread dies by connecting to the listening socket,
1874
# just in case the test failed to do so.
1875
conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
1876
conn.connect(self.sock.getsockname())
1878
except socket.error:
1861
"""Return the url of the server"""
1862
return "bzr://%s:%d/" % self.server.server_address