Merge lp:~mbp/bzr/504102-test-isolation into lp:bzr

Proposed by Martin Pool
Status: Merged
Approved by: Robert Collins
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~mbp/bzr/504102-test-isolation
Merge into: lp:bzr
Diff against target: 68 lines (+18/-4)
3 files modified
NEWS (+4/-0)
bzrlib/bzrdir.py (+7/-4)
bzrlib/tests/per_bzrdir/test_bzrdir.py (+7/-0)
To merge this branch: bzr merge lp:~mbp/bzr/504102-test-isolation
Reviewer Review Type Date Requested Status
Robert Collins (community) Approve
Review via email: mp+17006@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Martin Pool (mbp) wrote :

The RemoteBzrDirFormat can act as either an archetype for creation, or a description of an actual remote bzrdir. When used to initialize, it should not mutate the archetype, because that smudges global state and causes a test failure.

Revision history for this message
Robert Collins (lifeless) wrote :

 review: approve
 merge: approved

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS'
2--- NEWS 2010-01-08 07:37:25 +0000
3+++ NEWS 2010-01-08 08:46:16 +0000
4@@ -61,6 +61,10 @@
5 returns ``EINTR`` by calling ``PyErr_CheckSignals``. This affected the
6 optional ``_readdir_pyx`` extension. (Andrew Bennetts, #495023)
7
8+* Fixed a side effect mutation of ``RemoteBzrDirFormat._network_name``
9+ that caused some tests to fail when run in a non-default order.
10+ Probably no user impact. (Martin Pool, #504102)
11+
12 * FTP transports support Unicode paths by encoding/decoding them as utf8.
13 (Vincent Ladeuil, #472161)
14
15
16=== modified file 'bzrlib/bzrdir.py'
17--- bzrlib/bzrdir.py 2010-01-08 07:37:25 +0000
18+++ bzrlib/bzrdir.py 2010-01-08 08:46:16 +0000
19@@ -1,4 +1,4 @@
20-# Copyright (C) 2005, 2006, 2007, 2008, 2009 Canonical Ltd
21+# Copyright (C) 2005-2010 Canonical Ltd
22 #
23 # This program is free software; you can redistribute it and/or modify
24 # it under the terms of the GNU General Public License as published by
25@@ -3108,6 +3108,10 @@
26
27 def __init__(self):
28 BzrDirMetaFormat1.__init__(self)
29+ # XXX: It's a bit ugly that the network name is here, because we'd
30+ # like to believe that format objects are stateless or at least
31+ # immutable, However, we do at least avoid mutating the name after
32+ # it's returned. See <https://bugs.edge.launchpad.net/bzr/+bug/504102>
33 self._network_name = None
34
35 def __repr__(self):
36@@ -3256,12 +3260,11 @@
37 args.append(self._serialize_NoneString(repo_format_name))
38 args.append(self._serialize_NoneTrueFalse(make_working_trees))
39 args.append(self._serialize_NoneTrueFalse(shared_repo))
40- if self._network_name is None:
41- self._network_name = \
42+ request_network_name = self._network_name or \
43 BzrDirFormat.get_default_format().network_name()
44 try:
45 response = client.call('BzrDirFormat.initialize_ex_1.16',
46- self.network_name(), path, *args)
47+ request_network_name, path, *args)
48 except errors.UnknownSmartMethod:
49 client._medium._remember_remote_is_before((1,16))
50 local_dir_format = BzrDirMetaFormat1()
51
52=== modified file 'bzrlib/tests/per_bzrdir/test_bzrdir.py'
53--- bzrlib/tests/per_bzrdir/test_bzrdir.py 2009-11-18 17:10:41 +0000
54+++ bzrlib/tests/per_bzrdir/test_bzrdir.py 2010-01-08 08:46:16 +0000
55@@ -1176,6 +1176,13 @@
56 # because the default open will not open them and
57 # they may not be initializable.
58 return
59+ # for remote formats, there must be no prior assumption about the
60+ # network name to use - it's possible that this may somehow have got
61+ # in through an unisolated test though - see
62+ # <https://bugs.edge.launchpad.net/bzr/+bug/504102>
63+ self.assertEquals(getattr(self.bzrdir_format,
64+ '_network_name', None),
65+ None)
66 # supported formats must be able to init and open
67 t = get_transport(self.get_url())
68 readonly_t = get_transport(self.get_readonly_url())