509
509
if not _mod_revision.is_null(rev_id):
510
rh = self.b1.revision_history()
511
self.applyDeprecated(symbol_versioning.deprecated_in((2, 4, 0)),
512
tree.branch.set_revision_history, rh[:rh.index(rev_id)+1])
510
tree.branch.generate_revision_history(rev_id)
514
512
delta = tree.changes_from(self.b1.repository.revision_tree(rev_id))
515
513
self.assertFalse(delta.has_changed(),
651
649
bundle = self.get_valid_bundle('null:', 'a@cset-0-4')
654
open('b1/sub/dir/WithCaps.txt', 'ab').write('\nAdding some text\n')
655
open('b1/sub/dir/ pre space', 'ab').write(
652
with open('b1/sub/dir/WithCaps.txt', 'ab') as f: f.write('\nAdding some text\n')
653
with open('b1/sub/dir/ pre space', 'ab') as f: f.write(
656
654
'\r\nAdding some\r\nDOS format lines\r\n')
657
open('b1/sub/dir/nolastnewline.txt', 'ab').write('\n')
655
with open('b1/sub/dir/nolastnewline.txt', 'ab') as f: f.write('\n')
658
656
self.tree1.rename_one('sub/dir/ pre space',
659
657
'sub/ start space')
660
658
self.tree1.commit('Modified files', rev_id='a@cset-0-5')
682
680
def _test_symlink_bundle(self, link_name, link_target, new_link_target):
683
681
link_id = 'link-1'
685
self.requireFeature(tests.SymlinkFeature)
683
self.requireFeature(features.SymlinkFeature)
686
684
self.tree1 = self.make_branch_and_tree('b1')
687
685
self.b1 = self.tree1.branch
729
727
self._test_symlink_bundle('link', 'bar/foo', 'mars')
731
729
def test_unicode_symlink_bundle(self):
732
self.requireFeature(tests.UnicodeFilenameFeature)
730
self.requireFeature(features.UnicodeFilenameFeature)
733
731
self._test_symlink_bundle(u'\N{Euro Sign}link',
734
732
u'bar/\N{Euro Sign}foo',
735
733
u'mars\N{Euro Sign}')
809
807
self.tree1 = self.make_branch_and_tree('b1')
810
808
self.b1 = self.tree1.branch
812
open('b1/one', 'wb').write('one\n')
810
with open('b1/one', 'wb') as f: f.write('one\n')
813
811
self.tree1.add('one')
814
812
self.tree1.commit('add file', rev_id='a@cset-0-1')
815
open('b1/one', 'wb').write('two\n')
813
with open('b1/one', 'wb') as f: f.write('two\n')
816
814
self.tree1.commit('modify', rev_id='a@cset-0-2')
817
open('b1/one', 'wb').write('three\n')
815
with open('b1/one', 'wb') as f: f.write('three\n')
818
816
self.tree1.commit('modify', rev_id='a@cset-0-3')
819
817
bundle_file = StringIO()
820
818
rev_ids = write_bundle(self.tree1.branch.repository, 'a@cset-0-3',
836
834
return bundle_file.getvalue()
838
836
def test_unicode_bundle(self):
839
self.requireFeature(tests.UnicodeFilenameFeature)
837
self.requireFeature(features.UnicodeFilenameFeature)
840
838
# Handle international characters
842
840
f = open(u'b1/with Dod\N{Euro Sign}', 'wb')
899
897
bundle = self.get_valid_bundle('null:', 'white-1')
902
open('b1/trailing space ', 'ab').write('add some text\n')
900
with open('b1/trailing space ', 'ab') as f: f.write('add some text\n')
903
901
self.tree1.commit('add text', rev_id='white-2')
905
903
bundle = self.get_valid_bundle('white-1', 'white-2')
1420
1418
from bzrlib.testament import Testament
1421
1419
# monkey patch gpg signing mechanism
1422
1420
bzrlib.gpg.GPGStrategy = bzrlib.gpg.LoopbackGPGStrategy
1423
new_config = test_commit.MustSignConfig(branch)
1424
commit.Commit(config=new_config).commit(message="base",
1421
new_config = test_commit.MustSignConfig()
1422
commit.Commit(config_stack=new_config).commit(message="base",
1425
1423
allow_pointless=True,
1427
1425
working_tree=tree_a)
1836
1834
bundle, then the ConnectionReset error should be propagated.
1838
1836
# Instantiate a server that will provoke a ConnectionReset
1839
sock_server = _DisconnectingTCPServer()
1837
sock_server = DisconnectingServer()
1840
1838
self.start_server(sock_server)
1841
1839
# We don't really care what the url is since the server will close the
1842
1840
# connection without interpreting it
1844
1842
self.assertRaises(errors.ConnectionReset, read_mergeable_from_url, url)
1847
class _DisconnectingTCPServer(object):
1848
"""A TCP server that immediately closes any connection made to it."""
1850
def start_server(self):
1851
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
1852
self.sock.bind(('127.0.0.1', 0))
1854
self.port = self.sock.getsockname()[1]
1855
self.thread = threading.Thread(
1856
name='%s (port %d)' % (self.__class__.__name__, self.port),
1857
target=self.accept_and_close)
1860
def accept_and_close(self):
1861
conn, addr = self.sock.accept()
1862
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)
1865
1860
def get_url(self):
1866
return 'bzr://127.0.0.1:%d/' % (self.port,)
1868
def stop_server(self):
1870
# make sure the thread dies by connecting to the listening socket,
1871
# just in case the test failed to do so.
1872
conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
1873
conn.connect(self.sock.getsockname())
1875
except socket.error:
1861
"""Return the url of the server"""
1862
return "bzr://%s:%d/" % self.server.server_address