39
41
self.fail("%s exists" % conf_path)
41
43
config.ensure_config_dir_exists()
42
conf = open(conf_path,'wb')
44
f = open(conf_path,'wb')
44
conf.write("""[DEFAULT]
45
47
email=Joe Foo <joe@foo.com>
53
def _make_simple_branch(self, relpath='.'):
54
wt = self.make_branch_and_tree(relpath)
55
wt.commit('first revision')
56
wt.commit('second revision')
51
59
def test_log_default_format(self):
53
open('a', 'wb').write('foo\n')
56
self.run_bzr('commit -m 1')
57
open('a', 'wb').write('baz\n')
59
self.run_bzr('commit -m 2')
61
# only the lines formatter is this short
62
self.assertEquals(3, len(self.run_bzr('log')[0].split('\n')))
60
self._make_simple_branch()
61
# only the lines formatter is this short, one line by revision
62
log = self.run_bzr('log')[0]
63
self.assertEquals(2, len(log.splitlines()))
64
65
def test_log_format_arg(self):
66
open('a', 'wb').write('foo\n')
69
self.run_bzr('commit -m 1')
70
open('a', 'wb').write('baz\n')
72
self.run_bzr('commit -m 2')
75
len(self.run_bzr('log --log-format short')[0].split('\n')))
66
self._make_simple_branch()
67
log = self.run_bzr(['log', '--log-format', 'short'])[0]
77
69
def test_missing_default_format(self):
82
open('a', 'wb').write('foo\n')
84
self.run_bzr('commit -m 1')
87
self.run_bzr('branch a b')
90
open('a', 'wb').write('bar\n')
91
self.run_bzr('commit -m 2')
93
open('a', 'wb').write('baz\n')
94
self.run_bzr('commit -m 3')
99
len(self.run_bzr('missing', retcode=1)[0].split('\n')))
70
wt = self._make_simple_branch('a')
71
self.run_bzr(['branch', 'a', 'b'])
72
wt.commit('third revision')
73
wt.commit('fourth revision')
75
missing = self.run_bzr('missing', retcode=1, working_dir='b')[0]
76
# one line for 'Using save location'
77
# one line for 'You are missing 2 revision(s)'
78
# one line by missing revision (the line log format is used as
80
self.assertEquals(4, len(missing.splitlines()))
103
82
def test_missing_format_arg(self):
108
open('a', 'wb').write('foo\n')
109
self.run_bzr('add a')
110
self.run_bzr('commit -m 1')
113
self.run_bzr('branch a b')
116
open('a', 'wb').write('bar\n')
117
self.run_bzr('commit -m 2')
119
open('a', 'wb').write('baz\n')
120
self.run_bzr('commit -m 3')
125
len(self.run_bzr('missing --log-format short',
126
retcode=1)[0].split('\n')))
83
wt = self._make_simple_branch('a')
84
self.run_bzr(['branch', 'a', 'b'])
85
wt.commit('third revision')
86
wt.commit('fourth revision')
88
missing = self.run_bzr(['missing', '--log-format', 'short'],
89
retcode=1, working_dir='b')[0]
90
# one line for 'Using save location'
91
# one line for 'You are missing 2 revision(s)'
92
# three lines by missing revision
93
self.assertEquals(8, len(missing.splitlines()))
130
95
def test_logformat_gnu_changelog(self):
131
96
# from http://launchpad.net/bugs/29582/
132
repo_url = self.make_trivial_history()
134
out, err = self.run_bzr(
135
['log', self.get_url('repo/a'),
136
'--log-format=gnu-changelog',
138
self.assertEquals(err, '')
139
self.assertEqualDiff(out,
140
"""2009-03-03 Joe Foo <joe@foo.com>
146
def make_trivial_history(self):
147
"""Make a one-commit history and return the URL of the branch"""
148
repo = self.make_repository('repo', shared=True, format='1.6')
149
bb = self.make_branch_builder('repo/a')
151
bb.build_snapshot('rev-1', None,
152
[('add', ('', 'root-id', 'directory', ''))],
153
timestamp=1236045060)
155
return self.get_url('repo/a')
97
wt = self.make_branch_and_tree('.')
98
wt.commit('first revision', timestamp=1236045060,
101
log, err = self.run_bzr(['log', '--log-format', 'gnu-changelog',
103
self.assertEquals('', err)
104
expected = """2009-03-03 Joe Foo <joe@foo.com>
109
self.assertEqualDiff(expected, log)