14
13
# You should have received a copy of the GNU General Public License
15
14
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
18
"""Black-box tests for bzr log."""
243
242
self.assertContainsRe(log, r'revno: 2\n')
244
243
self.assertContainsRe(log, r'revno: 3\n')
245
def test_log_bad_message_re(self):
246
"""Bad --message argument gives a sensible message
248
See https://bugs.launchpad.net/bzr/+bug/251352
251
out, err = self.run_bzr(['log', '-m', '*'], retcode=3)
252
self.assertEqual("bzr: ERROR: Invalid regular expression"
253
" in log message filter"
255
": nothing to repeat\n", err)
256
self.assertEqual('', out)
247
259
class TestLogVerbose(TestCaseWithTransport):
974
986
self.assertNotContainsRe(log, '^3:', re.MULTILINE)
975
987
self.assertNotContainsRe(log, '^3.1.1:', re.MULTILINE)
976
988
self.assertNotContainsRe(log, '^4:', re.MULTILINE)
991
class TestLogMultiple(TestCaseWithTransport):
993
def prepare_tree(self):
994
tree = self.make_branch_and_tree('parent')
1000
'parent/dir1/dir2/',
1001
'parent/dir1/dir2/file3',
1004
tree.commit('add file1')
1006
tree.commit('add file2')
1007
tree.add(['dir1', 'dir1/dir2', 'dir1/dir2/file3'])
1008
tree.commit('add file3')
1010
tree.commit('add file4')
1011
tree.add('dir1/file5')
1012
tree.commit('add file5')
1013
child_tree = tree.bzrdir.sprout('child').open_workingtree()
1014
self.build_tree_contents([('child/file2', 'hello')])
1015
child_tree.commit(message='branch 1')
1016
tree.merge_from_branch(child_tree.branch)
1017
tree.commit(message='merge child branch')
1020
def assertRevnos(self, paths_str, expected_revnos):
1021
# confirm the revision numbers in log --line output are those expected
1022
out, err = self.run_bzr('log --line -n0 %s' % (paths_str,))
1023
self.assertEqual('', err)
1024
revnos = [s.split(':', 1)[0].lstrip() for s in out.splitlines()]
1025
self.assertEqual(expected_revnos, revnos)
1027
def test_log_files(self):
1028
"""The log for multiple file should only list revs for those files"""
1030
self.assertRevnos('file1 file2 dir1/dir2/file3',
1031
['6', '5.1.1', '3', '2', '1'])
1033
def test_log_directory(self):
1034
"""The log for a directory should show all nested files."""
1036
self.assertRevnos('dir1', ['5', '3'])
1038
def test_log_nested_directory(self):
1039
"""The log for a directory should show all nested files."""
1041
self.assertRevnos('dir1/dir2', ['3'])
1043
def test_log_in_nested_directory(self):
1044
"""The log for a directory should show all nested files."""
1047
self.assertRevnos('.', ['5', '3'])
1049
def test_log_files_and_directories(self):
1050
"""Logging files and directories together should be fine."""
1052
self.assertRevnos('file4 dir1/dir2', ['4', '3'])
1054
def test_log_files_and_dirs_in_nested_directory(self):
1055
"""The log for a directory should show all nested files."""
1058
self.assertRevnos('dir2 file5', ['5', '3'])