/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
6423.1.1 by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened.
1
# Copyright (C) 2007, 2009-2012 Canonical Ltd
1551.12.14 by Aaron Bentley
Get merge-directive command basically working
2
#
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
4183.7.1 by Sabin Iacob
update FSF mailing address
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1551.12.14 by Aaron Bentley
Get merge-directive command basically working
16
17
import os
1551.12.42 by Aaron Bentley
Clean up blackbox tests
18
import smtplib
1551.12.16 by Aaron Bentley
Enable signing merge directives
19
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
20
from breezy import (
1551.14.1 by Aaron Bentley
Allow pull from a merge directive
21
    gpg,
2520.4.112 by Aaron Bentley
Make cherry-pick merge directives possible
22
    merge_directive,
1551.14.1 by Aaron Bentley
Allow pull from a merge directive
23
    tests,
24
    workingtree,
25
    )
1551.12.14 by Aaron Bentley
Get merge-directive command basically working
26
1551.12.26 by Aaron Bentley
Get email working, with optional message
27
2625.6.1 by Adeodato Simó
New EmailMessage class, façade around email.Message and MIMEMultipart.
28
EMAIL1 = """From: "J. Random Hacker" <jrandom@example.com>
1551.12.26 by Aaron Bentley
Get email working, with optional message
29
Subject: bar
2625.6.1 by Adeodato Simó
New EmailMessage class, façade around email.Message and MIMEMultipart.
30
To: pqm@example.com
6963.1.1 by Jelmer Vernooij
Fix a bunch of tests on python3.
31
User-Agent: Bazaar \\(.*\\)
1551.12.26 by Aaron Bentley
Get email working, with optional message
32
2687.2.2 by Martin Pool
Fix up other references to 0.19
33
# Bazaar merge directive format 2 \\(Bazaar 0.90\\)
1551.14.1 by Aaron Bentley
Allow pull from a merge directive
34
# revision_id: bar-id
1551.12.26 by Aaron Bentley
Get email working, with optional message
35
# target_branch: ../tree2
36
# testament_sha1: .*
37
# timestamp: .*
1551.12.33 by Aaron Bentley
Take public_branch as a string, not object
38
# source_branch: .
1551.12.26 by Aaron Bentley
Get email working, with optional message
39
#"""
40
41
1551.12.14 by Aaron Bentley
Get merge-directive command basically working
42
class TestMergeDirective(tests.TestCaseWithTransport):
43
1551.12.42 by Aaron Bentley
Clean up blackbox tests
44
    def prepare_merge_directive(self):
1551.14.1 by Aaron Bentley
Allow pull from a merge directive
45
        self.tree1 = self.make_branch_and_tree('tree1')
6855.4.1 by Jelmer Vernooij
Yet more bees.
46
        self.build_tree_contents([('tree1/file', b'a\nb\nc\nd\n')])
6404.6.7 by Vincent Ladeuil
Change set/remove to require a lock for the branch config files.
47
        self.tree1.branch.get_config_stack().set(
48
            'email', 'J. Random Hacker <jrandom@example.com>')
1551.14.1 by Aaron Bentley
Allow pull from a merge directive
49
        self.tree1.add('file')
6855.4.1 by Jelmer Vernooij
Yet more bees.
50
        self.tree1.commit('foo', rev_id=b'foo-id')
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
51
        self.tree2 = self.tree1.controldir.sprout('tree2').open_workingtree()
6855.4.1 by Jelmer Vernooij
Yet more bees.
52
        self.build_tree_contents([('tree1/file', b'a\nb\nc\nd\ne\n')])
53
        self.tree1.commit('bar', rev_id=b'bar-id')
1551.12.14 by Aaron Bentley
Get merge-directive command basically working
54
        os.chdir('tree1')
1551.14.7 by Aaron Bentley
test suite fixes
55
        return self.tree1, self.tree2
1551.12.42 by Aaron Bentley
Clean up blackbox tests
56
57
    def test_merge_directive(self):
58
        self.prepare_merge_directive()
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
59
        md_text = self.run_bzr('merge-directive ../tree2')[0]
1551.12.42 by Aaron Bentley
Clean up blackbox tests
60
        self.assertContainsRe(md_text, "\\+e")
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
61
        md_text = self.run_bzr('merge-directive -r -2 ../tree2')[0]
1551.12.42 by Aaron Bentley
Clean up blackbox tests
62
        self.assertNotContainsRe(md_text, "\\+e")
7143.15.2 by Jelmer Vernooij
Run autopep8.
63
        md_text = self.run_bzr(
64
            'merge-directive -r -1..-2 ../tree2')[0].encode('utf-8')
2520.4.112 by Aaron Bentley
Make cherry-pick merge directives possible
65
        md2 = merge_directive.MergeDirective.from_lines(
66
            md_text.splitlines(True))
6973.13.2 by Jelmer Vernooij
Fix some more tests.
67
        self.assertEqual(b'foo-id', md2.revision_id)
68
        self.assertEqual(b'bar-id', md2.base_revision_id)
1551.12.42 by Aaron Bentley
Clean up blackbox tests
69
70
    def test_submit_branch(self):
71
        self.prepare_merge_directive()
1551.12.14 by Aaron Bentley
Get merge-directive command basically working
72
        self.run_bzr_error(('No submit branch',), 'merge-directive', retcode=3)
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
73
        self.run_bzr('merge-directive ../tree2')
1551.12.42 by Aaron Bentley
Clean up blackbox tests
74
75
    def test_public_branch(self):
76
        self.prepare_merge_directive()
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
77
        self.run_bzr_error(('No public branch',),
78
                           'merge-directive --diff ../tree2', retcode=3)
79
        md_text = self.run_bzr('merge-directive ../tree2')[0]
1551.12.42 by Aaron Bentley
Clean up blackbox tests
80
        self.assertNotContainsRe(md_text, 'source_branch:')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
81
        self.run_bzr('merge-directive --diff ../tree2 .')
82
        self.run_bzr('merge-directive --diff')[0]
1551.12.42 by Aaron Bentley
Clean up blackbox tests
83
        self.assertNotContainsRe(md_text, 'source_branch:')
84
85
    def test_patch_types(self):
86
        self.prepare_merge_directive()
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
87
        md_text = self.run_bzr('merge-directive ../tree2')[0]
2520.4.81 by Aaron Bentley
Fix blackbox tests
88
        self.assertContainsRe(md_text, "# Begin bundle")
1551.12.42 by Aaron Bentley
Clean up blackbox tests
89
        self.assertContainsRe(md_text, "\\+e")
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
90
        md_text = self.run_bzr('merge-directive ../tree2 --diff .')[0]
2520.4.81 by Aaron Bentley
Fix blackbox tests
91
        self.assertNotContainsRe(md_text, "# Begin bundle")
1551.12.14 by Aaron Bentley
Get merge-directive command basically working
92
        self.assertContainsRe(md_text, "\\+e")
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
93
        md_text = self.run_bzr('merge-directive --plain')[0]
1551.12.14 by Aaron Bentley
Get merge-directive command basically working
94
        self.assertNotContainsRe(md_text, "\\+e")
1551.12.42 by Aaron Bentley
Clean up blackbox tests
95
96
    def test_message(self):
97
        self.prepare_merge_directive()
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
98
        md_text = self.run_bzr('merge-directive ../tree2')[0]
1551.12.27 by Aaron Bentley
support custom message everywhere
99
        self.assertNotContainsRe(md_text, 'message: Message for merge')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
100
        md_text = self.run_bzr('merge-directive -m Message_for_merge')[0]
101
        self.assertContainsRe(md_text, 'message: Message_for_merge')
1551.12.42 by Aaron Bentley
Clean up blackbox tests
102
103
    def test_signing(self):
104
        self.prepare_merge_directive()
1551.12.16 by Aaron Bentley
Enable signing merge directives
105
        old_strategy = gpg.GPGStrategy
106
        gpg.GPGStrategy = gpg.LoopbackGPGStrategy
107
        try:
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
108
            md_text = self.run_bzr('merge-directive --sign ../tree2')[0]
1551.12.16 by Aaron Bentley
Enable signing merge directives
109
        finally:
110
            gpg.GPGStrategy = old_strategy
111
        self.assertContainsRe(md_text, '^-----BEGIN PSEUDO-SIGNED CONTENT')
1551.12.42 by Aaron Bentley
Clean up blackbox tests
112
1551.12.57 by Aaron Bentley
Ensure server default works, too
113
    def run_bzr_fakemail(self, *args, **kwargs):
1551.12.26 by Aaron Bentley
Get email working, with optional message
114
        sendmail_calls = []
7143.15.2 by Jelmer Vernooij
Run autopep8.
115
1551.12.26 by Aaron Bentley
Get email working, with optional message
116
        def sendmail(self, from_, to, message):
117
            sendmail_calls.append((self, from_, to, message))
2338.2.1 by Marien Zwart
Make the merge directive tests work if there is no smtpd running on localhost.
118
        connect_calls = []
7143.15.2 by Jelmer Vernooij
Run autopep8.
119
2338.2.1 by Marien Zwart
Make the merge directive tests work if there is no smtpd running on localhost.
120
        def connect(self, host='localhost', port=0):
121
            connect_calls.append((self, host, port))
7143.15.2 by Jelmer Vernooij
Run autopep8.
122
2898.2.3 by James Henstridge
* Fix merge-directive blackbox test.
123
        def has_extn(self, extension):
124
            return False
7143.15.2 by Jelmer Vernooij
Run autopep8.
125
2898.2.3 by James Henstridge
* Fix merge-directive blackbox test.
126
        def ehlo(self):
127
            return (200, 'Ok')
1551.12.26 by Aaron Bentley
Get email working, with optional message
128
        old_sendmail = smtplib.SMTP.sendmail
129
        smtplib.SMTP.sendmail = sendmail
2338.2.1 by Marien Zwart
Make the merge directive tests work if there is no smtpd running on localhost.
130
        old_connect = smtplib.SMTP.connect
131
        smtplib.SMTP.connect = connect
2898.2.3 by James Henstridge
* Fix merge-directive blackbox test.
132
        old_ehlo = smtplib.SMTP.ehlo
133
        smtplib.SMTP.ehlo = ehlo
134
        old_has_extn = smtplib.SMTP.has_extn
135
        smtplib.SMTP.has_extn = has_extn
1551.12.26 by Aaron Bentley
Get email working, with optional message
136
        try:
1551.12.57 by Aaron Bentley
Ensure server default works, too
137
            result = self.run_bzr(*args, **kwargs)
1551.12.26 by Aaron Bentley
Get email working, with optional message
138
        finally:
139
            smtplib.SMTP.sendmail = old_sendmail
2338.2.1 by Marien Zwart
Make the merge directive tests work if there is no smtpd running on localhost.
140
            smtplib.SMTP.connect = old_connect
2898.2.3 by James Henstridge
* Fix merge-directive blackbox test.
141
            smtplib.SMTP.ehlo = old_ehlo
142
            smtplib.SMTP.has_extn = old_has_extn
1551.12.57 by Aaron Bentley
Ensure server default works, too
143
        return result + (connect_calls, sendmail_calls)
144
145
    def test_mail_default(self):
146
        tree1, tree2 = self.prepare_merge_directive()
147
        md_text, errr, connect_calls, sendmail_calls =\
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
148
            self.run_bzr_fakemail(['merge-directive', '--mail-to',
149
                                   'pqm@example.com', '--plain', '../tree2',
150
                                   '.'])
1551.12.26 by Aaron Bentley
Get email working, with optional message
151
        self.assertEqual('', md_text)
2338.2.1 by Marien Zwart
Make the merge directive tests work if there is no smtpd running on localhost.
152
        self.assertEqual(1, len(connect_calls))
153
        call = connect_calls[0]
1551.12.57 by Aaron Bentley
Ensure server default works, too
154
        self.assertEqual(('localhost', 0), call[1:3])
1551.12.26 by Aaron Bentley
Get email working, with optional message
155
        self.assertEqual(1, len(sendmail_calls))
156
        call = sendmail_calls[0]
2535.2.1 by Adeodato Simó
New SMTPConnection class, a reduced version of that in bzr-email.
157
        self.assertEqual(('jrandom@example.com', ['pqm@example.com']),
7143.15.2 by Jelmer Vernooij
Run autopep8.
158
                         call[1:3])
1551.12.26 by Aaron Bentley
Get email working, with optional message
159
        self.assertContainsRe(call[3], EMAIL1)
1551.14.1 by Aaron Bentley
Allow pull from a merge directive
160
1551.14.10 by Aaron Bentley
Remove 'manual' from test names
161
    def test_pull_raw(self):
1551.14.1 by Aaron Bentley
Allow pull from a merge directive
162
        self.prepare_merge_directive()
6855.4.1 by Jelmer Vernooij
Yet more bees.
163
        self.tree1.commit('baz', rev_id=b'baz-id')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
164
        md_text = self.run_bzr(['merge-directive', self.tree2.basedir,
165
                                '-r', '2', self.tree1.basedir, '--plain'])[0]
1551.14.1 by Aaron Bentley
Allow pull from a merge directive
166
        self.build_tree_contents([('../directive', md_text)])
167
        os.chdir('../tree2')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
168
        self.run_bzr('pull ../directive')
1551.14.1 by Aaron Bentley
Allow pull from a merge directive
169
        wt = workingtree.WorkingTree.open('.')
6973.13.2 by Jelmer Vernooij
Fix some more tests.
170
        self.assertEqual(b'bar-id', wt.last_revision())
1551.14.1 by Aaron Bentley
Allow pull from a merge directive
171
1551.14.10 by Aaron Bentley
Remove 'manual' from test names
172
    def test_pull_user_r(self):
1551.14.4 by Aaron Bentley
Change bundle reader and merge directive to both be 'mergeables'
173
        """If the user supplies -r, an error is emitted"""
1551.14.1 by Aaron Bentley
Allow pull from a merge directive
174
        self.prepare_merge_directive()
6855.4.1 by Jelmer Vernooij
Yet more bees.
175
        self.tree1.commit('baz', rev_id=b'baz-id')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
176
        md_text = self.run_bzr(['merge-directive', self.tree2.basedir,
177
                                self.tree1.basedir, '--plain'])[0]
1551.14.1 by Aaron Bentley
Allow pull from a merge directive
178
        self.build_tree_contents([('../directive', md_text)])
179
        os.chdir('../tree2')
1551.14.4 by Aaron Bentley
Change bundle reader and merge directive to both be 'mergeables'
180
        self.run_bzr_error(
181
            ('Cannot use -r with merge directives or bundles',),
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
182
            'pull -r 2 ../directive')
1551.14.1 by Aaron Bentley
Allow pull from a merge directive
183
1551.14.10 by Aaron Bentley
Remove 'manual' from test names
184
    def test_pull_bundle(self):
1551.14.1 by Aaron Bentley
Allow pull from a merge directive
185
        self.prepare_merge_directive()
6855.4.1 by Jelmer Vernooij
Yet more bees.
186
        self.tree1.commit('baz', rev_id=b'baz-id')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
187
        md_text = self.run_bzr(['merge-directive', self.tree2.basedir,
188
                                '-r', '2', '/dev/null', '--bundle'])[0]
1551.14.1 by Aaron Bentley
Allow pull from a merge directive
189
        self.build_tree_contents([('../directive', md_text)])
190
        os.chdir('../tree2')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
191
        self.run_bzr('pull ../directive')
1551.14.1 by Aaron Bentley
Allow pull from a merge directive
192
        wt = workingtree.WorkingTree.open('.')
6973.13.2 by Jelmer Vernooij
Fix some more tests.
193
        self.assertEqual(b'bar-id', wt.last_revision())
1551.14.2 by Aaron Bentley
Support manual merge from merge directives
194
1551.14.10 by Aaron Bentley
Remove 'manual' from test names
195
    def test_merge_raw(self):
1551.14.2 by Aaron Bentley
Support manual merge from merge directives
196
        self.prepare_merge_directive()
6855.4.1 by Jelmer Vernooij
Yet more bees.
197
        self.tree1.commit('baz', rev_id=b'baz-id')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
198
        md_text = self.run_bzr(['merge-directive', self.tree2.basedir,
199
                                '-r', '2', self.tree1.basedir, '--plain'])[0]
1551.14.2 by Aaron Bentley
Support manual merge from merge directives
200
        self.build_tree_contents([('../directive', md_text)])
201
        os.chdir('../tree2')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
202
        self.run_bzr('merge ../directive')
1551.14.2 by Aaron Bentley
Support manual merge from merge directives
203
        wt = workingtree.WorkingTree.open('.')
6973.13.2 by Jelmer Vernooij
Fix some more tests.
204
        self.assertEqual(b'bar-id', wt.get_parent_ids()[1])
1551.14.2 by Aaron Bentley
Support manual merge from merge directives
205
1551.14.10 by Aaron Bentley
Remove 'manual' from test names
206
    def test_merge_user_r(self):
1551.14.4 by Aaron Bentley
Change bundle reader and merge directive to both be 'mergeables'
207
        """If the user supplies -r, an error is emitted"""
1551.14.2 by Aaron Bentley
Support manual merge from merge directives
208
        self.prepare_merge_directive()
6855.4.1 by Jelmer Vernooij
Yet more bees.
209
        self.tree1.commit('baz', rev_id=b'baz-id')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
210
        md_text = self.run_bzr(['merge-directive', self.tree2.basedir,
211
                                self.tree1.basedir, '--plain'])[0]
1551.14.2 by Aaron Bentley
Support manual merge from merge directives
212
        self.build_tree_contents([('../directive', md_text)])
213
        os.chdir('../tree2')
1551.14.4 by Aaron Bentley
Change bundle reader and merge directive to both be 'mergeables'
214
        self.run_bzr_error(
215
            ('Cannot use -r with merge directives or bundles',),
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
216
            'merge -r 2 ../directive')
1551.14.2 by Aaron Bentley
Support manual merge from merge directives
217
1551.14.10 by Aaron Bentley
Remove 'manual' from test names
218
    def test_merge_bundle(self):
1551.14.2 by Aaron Bentley
Support manual merge from merge directives
219
        self.prepare_merge_directive()
6855.4.1 by Jelmer Vernooij
Yet more bees.
220
        self.tree1.commit('baz', rev_id=b'baz-id')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
221
        md_text = self.run_bzr(['merge-directive', self.tree2.basedir,
7143.15.2 by Jelmer Vernooij
Run autopep8.
222
                                '-r', '2', '/dev/null', '--bundle'])[0]
1551.14.2 by Aaron Bentley
Support manual merge from merge directives
223
        self.build_tree_contents([('../directive', md_text)])
224
        os.chdir('../tree2')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
225
        self.run_bzr('merge ../directive')
1551.14.2 by Aaron Bentley
Support manual merge from merge directives
226
        wt = workingtree.WorkingTree.open('.')
6973.13.2 by Jelmer Vernooij
Fix some more tests.
227
        self.assertEqual(b'bar-id', wt.get_parent_ids()[1])
1551.14.6 by Aaron Bentley
Merge bzr.dev
228
1551.12.57 by Aaron Bentley
Ensure server default works, too
229
    def test_mail_uses_config(self):
230
        tree1, tree2 = self.prepare_merge_directive()
6404.6.1 by Vincent Ladeuil
Tests passing for a first rough version of a cached branch config store. The changes here are too invasive and several parallel proposals have been made.
231
        br = tree1.branch
6404.6.7 by Vincent Ladeuil
Change set/remove to require a lock for the branch config files.
232
        br.get_config_stack().set('smtp_server', 'bogushost')
1551.12.57 by Aaron Bentley
Ensure server default works, too
233
        md_text, errr, connect_calls, sendmail_calls =\
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
234
            self.run_bzr_fakemail('merge-directive --mail-to'
235
                                  ' pqm@example.com --plain ../tree2 .')
1551.12.57 by Aaron Bentley
Ensure server default works, too
236
        call = connect_calls[0]
237
        self.assertEqual(('bogushost', 0), call[1:3])
2490.2.28 by Aaron Bentley
Fix handling of null revision
238
239
    def test_no_common_ancestor(self):
240
        foo = self.make_branch_and_tree('foo')
241
        foo.commit('rev1')
242
        bar = self.make_branch_and_tree('bar')
6423.1.1 by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened.
243
        self.run_bzr('merge-directive ../bar', working_dir='foo')
2490.2.28 by Aaron Bentley
Fix handling of null revision
244
245
    def test_no_commits(self):
246
        foo = self.make_branch_and_tree('foo')
247
        bar = self.make_branch_and_tree('bar')
248
        self.run_bzr_error(('No revisions to bundle.', ),
7143.15.2 by Jelmer Vernooij
Run autopep8.
249
                           'merge-directive ../bar', working_dir='foo')
2552.1.1 by John Arbash Meinel
(Adeodato Simó) fix bug #120591 by using exact encoding for merge directives.
250
2530.2.1 by Adeodato Simó
Add encoding_type = 'exact' to cmd_merge_directive. (LP #120591)
251
    def test_encoding_exact(self):
252
        tree1, tree2 = self.prepare_merge_directive()
253
        tree1.commit(u'messag\xe9')
7143.15.2 by Jelmer Vernooij
Run autopep8.
254
        self.run_bzr('merge-directive ../tree2')  # no exception raised
5171.3.13 by Martin von Gagern
Add --directory option to 7 more commands.
255
256
    def test_merge_directive_directory(self):
257
        """Test --directory option"""
258
        import re
259
        re_timestamp = re.compile(r'^# timestamp: .*', re.M)
260
        self.prepare_merge_directive()
261
        md1 = self.run_bzr('merge-directive ../tree2')[0]
262
        md1 = re_timestamp.sub('# timestamp: XXX', md1)
263
        os.chdir('..')
264
        md2 = self.run_bzr('merge-directive --directory tree1 tree2')[0]
265
        md2 = re_timestamp.sub('# timestamp: XXX', md2)
266
        self.assertEqualDiff(md1.replace('../tree2', 'tree2'), md2)