30
32
from bzrlib.selftest import TestCaseInTempDir, BzrTestBase
33
from bzrlib.branch import Branch
34
from bzrlib.commands import run_bzr
32
37
class ExternalBase(TestCaseInTempDir):
34
38
def runbzr(self, args, retcode=0,backtick=False):
37
from subprocess import call
38
except ImportError, e:
42
39
if isinstance(args, basestring):
43
40
args = args.split()
96
93
def test_ignore_patterns(self):
97
94
from bzrlib.branch import Branch
99
b = Branch('.', init=True)
96
b = Branch.initialize('.')
100
97
self.assertEquals(list(b.unknowns()), [])
102
99
file('foo.tmp', 'wt').write('tmp files are ignored')
151
147
os.rmdir('revertdir')
152
148
self.runbzr('revert')
154
def skipped_test_mv_modes(self):
150
def test_mv_modes(self):
155
151
"""Test two modes of operation for mv"""
156
152
from bzrlib.branch import Branch
157
b = Branch('.', init=True)
153
b = Branch.initialize('.')
158
154
self.build_tree(['a', 'c', 'subdir/'])
155
self.run_bzr('add', self.test_dir)
159
156
self.run_bzr('mv', 'a', 'b')
160
157
self.run_bzr('mv', 'b', 'subdir')
161
158
self.run_bzr('mv', 'subdir/b', 'a')
162
self.run_bzr('mv', 'a', 'b', 'subdir')
159
self.run_bzr('mv', 'a', 'c', 'subdir')
163
160
self.run_bzr('mv', 'subdir/a', 'subdir/newa')
165
163
def test_main_version(self):
166
164
"""Check output from version command and master option is reasonable"""
167
165
# output is intentionally passed through to stdout so that we
219
214
self.runbzr('merge ../b')
220
215
self.check_file_contents('goodbye', 'quux')
221
216
# Merging a branch pulls its revision into the tree
218
b = Branch.open('../b')
224
219
a.get_revision_xml(b.last_patch())
226
220
self.log('pending merges: %s', a.pending_merges())
227
# assert a.pending_merges() == [b.last_patch()], "Assertion %s %s" \
228
# % (a.pending_merges(), b.last_patch())
221
# assert a.pending_merges() == [b.last_patch()], "Assertion %s %s" \
222
# % (a.pending_merges(), b.last_patch())
225
"""Pull changes from one branch to another."""
229
self.example_branch()
231
self.runbzr('branch a b')
233
self.runbzr('commit -m blah --unchanged')
236
b = Branch.open('../b')
237
assert a.revision_history() == b.revision_history()[:-1]
238
self.runbzr('pull ../b')
239
assert a.revision_history() == b.revision_history()
240
self.runbzr('commit -m blah2 --unchanged')
242
self.runbzr('commit -m blah3 --unchanged')
243
self.runbzr('pull ../a', retcode=1)
245
self.runbzr('merge ../b')
246
self.runbzr('commit -m blah4 --unchanged')
248
self.runbzr('pull ../a')
249
assert a.revision_history()[-1] == b.revision_history()[-1]
252
def test_add_reports(self):
253
"""add command prints the names of added files."""
254
b = Branch.initialize('.')
255
self.build_tree(['top.txt', 'dir/', 'dir/sub.txt'])
257
from cStringIO import StringIO
260
ret = self.apply_redirected(None, out, None,
263
self.assertEquals(ret, 0)
265
# the ordering is not defined at the moment
266
results = sorted(out.getvalue().rstrip('\n').split('\n'))
267
self.assertEquals(['added dir',
230
273
class OldTests(ExternalBase):
231
274
"""old tests moved from ./testbzr."""