def test_short_log_with_merges(self): wt = self.make_branch_and_memory_tree('.') wt.lock_write() try: wt.add('') wt.commit('rev-1', rev_id='rev-1', timestamp=1132586655, timezone=36000, committer='Joe Foo <*****@*****.**>') wt.commit('rev-merged', rev_id='rev-2a', timestamp=1132586700, timezone=36000, committer='Joe Foo <*****@*****.**>') wt.set_parent_ids(['rev-1', 'rev-2a']) wt.branch.set_last_revision_info(1, 'rev-1') wt.commit('rev-2', rev_id='rev-2b', timestamp=1132586800, timezone=36000, committer='Joe Foo <*****@*****.**>') logfile = self.make_utf8_encoded_stringio() formatter = ShortLogFormatter(to_file=logfile) show_log(wt.branch, formatter) self.assertEqualDiff(logfile.getvalue(), """\ 2 Joe Foo\t2005-11-22 [merge] rev-2 1 Joe Foo\t2005-11-22 rev-1 """) finally: wt.unlock()
def test_verbose_log(self): """Verbose log includes changed files bug #4676 """ wt = self.make_branch_and_tree('.') b = wt.branch self.build_tree(['a']) wt.add('a') # XXX: why does a longer nick show up? b.nick = 'test_verbose_log' wt.commit(message='add a', timestamp=1132711707, timezone=36000, committer='Lorem Ipsum <*****@*****.**>') logfile = file('out.tmp', 'w+') formatter = LongLogFormatter(to_file=logfile) show_log(b, formatter, verbose=True) logfile.flush() logfile.seek(0) log_contents = logfile.read() self.assertEqualDiff(log_contents, '''\ ------------------------------------------------------------ revno: 1 committer: Lorem Ipsum <*****@*****.**> branch nick: test_verbose_log timestamp: Wed 2005-11-23 12:08:27 +1000 message: add a added: a ''')
def get_commits(self, repository, start, end=None, full=None): branch = None if repository: repository = repository.lower() if repository not in self.branches: return None branch = self.branches[repository] if not branch: if len(self.branches) == 1: (repository, branch) = self.branches.items()[0] else: (repository, branch) = sorted(self.branches.iteritems(), reverse=True, key=lambda (k, v): v.repository.get_revision( v.last_revision_info()[1]).timestamp)[0] if not start: start = branch.revision_id_to_revno(branch.last_revision()) f = StringIO() log.show_log(branch, LogFormatter(f, repository, branch, full), start_revision=start, end_revision=end or start) f.seek(0) commits = f.readlines() commits.reverse() return commits
def test_line_log_single_merge_revision(self): wt = self.make_branch_and_memory_tree('.') wt.lock_write() try: wt.add('') wt.commit('rev-1', rev_id='rev-1', timestamp=1132586655, timezone=36000, committer='Joe Foo <*****@*****.**>') wt.commit('rev-merged', rev_id='rev-2a', timestamp=1132586700, timezone=36000, committer='Joe Foo <*****@*****.**>') wt.set_parent_ids(['rev-1', 'rev-2a']) wt.branch.set_last_revision_info(1, 'rev-1') wt.commit('rev-2', rev_id='rev-2b', timestamp=1132586800, timezone=36000, committer='Joe Foo <*****@*****.**>') logfile = self.make_utf8_encoded_stringio() formatter = LineLogFormatter(to_file=logfile) revspec = RevisionSpec.from_string('1.1.1') wtb = wt.branch rev = revspec.in_history(wtb) show_log(wtb, formatter, start_revision=rev, end_revision=rev) self.assertEqualDiff(logfile.getvalue(), """\ 1.1.1: Joe Foo 2005-11-22 rev-merged """) finally: wt.unlock()
def body(self): from bzrlib import log rev1 = rev2 = self.revno if rev1 == 0: rev1 = None rev2 = None # use 'replace' so that we don't abort if trying to write out # in e.g. the default C locale. # We must use StringIO.StringIO because we want a Unicode string that # we can pass to send_email and have that do the proper encoding. from StringIO import StringIO outf = StringIO() outf.write('At %s\n\n' % self.url()) lf = log.log_formatter('long', show_ids=True, to_file=outf) if len(self.revision.parent_ids) <= 1: # This is not a merge, so we can special case the display of one # revision, and not have to encur the show_log overhead. lr = log.LogRevision(self.revision, self.revno, 0, None) lf.log_revision(lr) else: # let the show_log code figure out what revisions need to be # displayed, as this is a merge log.show_log(self.branch, lf, start_revision=rev1, end_revision=rev2, verbose=True) return outf.getvalue()
def test_trailing_newlines(self): wt = self.make_branch_and_tree('.') b = make_commits_with_trailing_newlines(wt) sio = self.make_utf8_encoded_stringio() lf = LongLogFormatter(to_file=sio) show_log(b, lf) self.assertEqualDiff( sio.getvalue(), """\ ------------------------------------------------------------ revno: 3 committer: Joe Foo <*****@*****.**> branch nick: test timestamp: Mon 2005-11-21 09:32:56 -0600 message: single line with trailing newline ------------------------------------------------------------ revno: 2 author: Joe Bar <*****@*****.**> committer: Joe Foo <*****@*****.**> branch nick: test timestamp: Mon 2005-11-21 09:27:22 -0600 message: multiline log message ------------------------------------------------------------ revno: 1 committer: Joe Foo <*****@*****.**> branch nick: test timestamp: Mon 2005-11-21 09:24:15 -0600 message: simple log message """)
def test_line_log_single_merge_revision(self): wt = self.make_branch_and_memory_tree('.') wt.lock_write() try: wt.add('') wt.commit('rev-1', rev_id='rev-1', timestamp=1132586655, timezone=36000, committer='Joe Foo <*****@*****.**>') wt.commit('rev-merged', rev_id='rev-2a', timestamp=1132586700, timezone=36000, committer='Joe Foo <*****@*****.**>') wt.set_parent_ids(['rev-1', 'rev-2a']) wt.branch.set_last_revision_info(1, 'rev-1') wt.commit('rev-2', rev_id='rev-2b', timestamp=1132586800, timezone=36000, committer='Joe Foo <*****@*****.**>') logfile = self.make_utf8_encoded_stringio() formatter = LineLogFormatter(to_file=logfile) revspec = RevisionSpec.from_string('1.1.1') wtb = wt.branch rev = revspec.in_history(wtb) show_log(wtb, formatter, start_revision=rev, end_revision=rev) self.assertEqualDiff( logfile.getvalue(), """\ 1.1.1: Joe Foo 2005-11-22 rev-merged """) finally: wt.unlock()
def test_author_in_log(self): """Log includes the author name if it's set in the revision properties """ wt = self.make_branch_and_tree('.') b = wt.branch self.build_tree(['a']) wt.add('a') b.nick = 'test_author_log' wt.commit(message='add a', timestamp=1132711707, timezone=36000, committer='Lorem Ipsum <*****@*****.**>', author='John Doe <*****@*****.**>') sio = StringIO() formatter = LongLogFormatter(to_file=sio) show_log(b, formatter) self.assertEqualDiff( sio.getvalue(), '''\ ------------------------------------------------------------ revno: 1 author: John Doe <*****@*****.**> committer: Lorem Ipsum <*****@*****.**> branch nick: test_author_log timestamp: Wed 2005-11-23 12:08:27 +1000 message: add a ''')
def test_verbose_log(self): """Verbose log includes changed files bug #4676 """ wt = self.make_branch_and_tree('.') b = wt.branch self.build_tree(['a']) wt.add('a') # XXX: why does a longer nick show up? b.nick = 'test_verbose_log' wt.commit(message='add a', timestamp=1132711707, timezone=36000, committer='Lorem Ipsum <*****@*****.**>') logfile = file('out.tmp', 'w+') formatter = LongLogFormatter(to_file=logfile) show_log(b, formatter, verbose=True) logfile.flush() logfile.seek(0) log_contents = logfile.read() self.assertEqualDiff( log_contents, '''\ ------------------------------------------------------------ revno: 1 committer: Lorem Ipsum <*****@*****.**> branch nick: test_verbose_log timestamp: Wed 2005-11-23 12:08:27 +1000 message: add a added: a ''')
def test_author_in_log(self): """Log includes the author name if it's set in the revision properties """ wt = self.make_branch_and_tree('.') b = wt.branch self.build_tree(['a']) wt.add('a') b.nick = 'test_author_log' wt.commit(message='add a', timestamp=1132711707, timezone=36000, committer='Lorem Ipsum <*****@*****.**>', author='John Doe <*****@*****.**>') sio = StringIO() formatter = LongLogFormatter(to_file=sio) show_log(b, formatter) self.assertEqualDiff(sio.getvalue(), '''\ ------------------------------------------------------------ revno: 1 author: John Doe <*****@*****.**> committer: Lorem Ipsum <*****@*****.**> branch nick: test_author_log timestamp: Wed 2005-11-23 12:08:27 +1000 message: add a ''')
def test_trailing_newlines(self): wt = self.make_branch_and_tree('.') b = make_commits_with_trailing_newlines(wt) sio = self.make_utf8_encoded_stringio() lf = LongLogFormatter(to_file=sio) show_log(b, lf) self.assertEqualDiff(sio.getvalue(), """\ ------------------------------------------------------------ revno: 3 committer: Joe Foo <*****@*****.**> branch nick: test timestamp: Mon 2005-11-21 09:32:56 -0600 message: single line with trailing newline ------------------------------------------------------------ revno: 2 author: Joe Bar <*****@*****.**> committer: Joe Foo <*****@*****.**> branch nick: test timestamp: Mon 2005-11-21 09:27:22 -0600 message: multiline log message ------------------------------------------------------------ revno: 1 committer: Joe Foo <*****@*****.**> branch nick: test timestamp: Mon 2005-11-21 09:24:15 -0600 message: simple log message """)
def bundle(dir): branch = Branch.open(dir) output_zip = '%s_%d.zip'%(dir, branch.revno()) temp_dir = '/tmp/output_%d'%(branch.revno()) #Empty the temp_dir shutil.rmtree(temp_dir, True) #export the bzr repository to temp_dir export(branch.basis_tree(), temp_dir) #Compile the source code in templocation compileall.compile_dir(temp_dir) #Remove the .py files from the exported directory. clean_path(temp_dir, [".py"]) #create a HISTORY file in the temp_dir show_log(branch, ShortLogFormatter(open(temp_dir+os.sep+'HISTORY', 'w'))) #create a VERSION file in temp_dir f = open(temp_dir+os.sep+'VERSION', 'w') f.write(str(branch.revno())) f.close() #write to zip z.toZip(temp_dir, output_zip)
def log_screenful(): lf = log_formatter(formatter, to_file=LineConsumer(25)) try: show_log(tree.branch, lf, direction='reverse') except LinesDone: pass else: raise Exception, "LinesDone not raised"
def test_merges_are_indented_by_level(self): wt = self.make_branch_and_tree('parent') wt.commit('first post') self.run_bzr('branch parent child') self.run_bzr(['commit', '-m', 'branch 1', '--unchanged', 'child']) self.run_bzr('branch child smallerchild') self.run_bzr( ['commit', '-m', 'branch 2', '--unchanged', 'smallerchild']) os.chdir('child') self.run_bzr('merge ../smallerchild') self.run_bzr(['commit', '-m', 'merge branch 2']) os.chdir('../parent') self.run_bzr('merge ../child') wt.commit('merge branch 1') b = wt.branch sio = self.make_utf8_encoded_stringio() lf = LongLogFormatter(to_file=sio) show_log(b, lf, verbose=True) log = normalize_log(sio.getvalue()) self.assertEqualDiff( log, """\ ------------------------------------------------------------ revno: 2 committer: Lorem Ipsum <*****@*****.**> branch nick: parent timestamp: Just now message: merge branch 1 ------------------------------------------------------------ revno: 1.1.2 committer: Lorem Ipsum <*****@*****.**> branch nick: child timestamp: Just now message: merge branch 2 ------------------------------------------------------------ revno: 1.2.1 committer: Lorem Ipsum <*****@*****.**> branch nick: smallerchild timestamp: Just now message: branch 2 ------------------------------------------------------------ revno: 1.1.1 committer: Lorem Ipsum <*****@*****.**> branch nick: child timestamp: Just now message: branch 1 ------------------------------------------------------------ revno: 1 committer: Lorem Ipsum <*****@*****.**> branch nick: parent timestamp: Just now message: first post """)
def test_merges_are_indented_by_level(self): wt = self.make_branch_and_tree('parent') wt.commit('first post') self.run_bzr('branch parent child') self.run_bzr(['commit', '-m', 'branch 1', '--unchanged', 'child']) self.run_bzr('branch child smallerchild') self.run_bzr(['commit', '-m', 'branch 2', '--unchanged', 'smallerchild']) os.chdir('child') self.run_bzr('merge ../smallerchild') self.run_bzr(['commit', '-m', 'merge branch 2']) os.chdir('../parent') self.run_bzr('merge ../child') wt.commit('merge branch 1') b = wt.branch sio = self.make_utf8_encoded_stringio() lf = LongLogFormatter(to_file=sio) show_log(b, lf, verbose=True) log = normalize_log(sio.getvalue()) self.assertEqualDiff(log, """\ ------------------------------------------------------------ revno: 2 committer: Lorem Ipsum <*****@*****.**> branch nick: parent timestamp: Just now message: merge branch 1 ------------------------------------------------------------ revno: 1.1.2 committer: Lorem Ipsum <*****@*****.**> branch nick: child timestamp: Just now message: merge branch 2 ------------------------------------------------------------ revno: 1.2.1 committer: Lorem Ipsum <*****@*****.**> branch nick: smallerchild timestamp: Just now message: branch 2 ------------------------------------------------------------ revno: 1.1.1 committer: Lorem Ipsum <*****@*****.**> branch nick: child timestamp: Just now message: branch 1 ------------------------------------------------------------ revno: 1 committer: Lorem Ipsum <*****@*****.**> branch nick: parent timestamp: Just now message: first post """)
def getRevisionMessage(self, revision_id, revno): """Return the log message for a revision. :param revision_id: The revision-id of the revision. :param revno: The revno of the revision in the branch. :return: The log message entered for this revision. """ self.bzr_branch.lock_read() try: graph = self.bzr_branch.repository.get_graph() merged_revisions = self.getMergedRevisionIDs(revision_id, graph) authors = self.getAuthors(merged_revisions, graph) revision_set = RevisionSet() rev_authors = revision_set.acquireRevisionAuthors(authors) outf = StringIO() pretty_authors = [] for rev_author in rev_authors.values(): if rev_author.person is None: displayname = rev_author.name else: displayname = rev_author.person.unique_displayname pretty_authors.append(' %s' % displayname) if len(pretty_authors) > 0: outf.write('Merge authors:\n') pretty_authors.sort(key=lambda x: x.lower()) outf.write('\n'.join(pretty_authors[:5])) if len(pretty_authors) > 5: outf.write('...\n') outf.write('\n') bmps = self.findRelatedBMP(merged_revisions) if len(bmps) > 0: outf.write('Related merge proposals:\n') for bmp in bmps: outf.write(' %s\n' % canonical_url(bmp)) proposer = bmp.registrant outf.write(' proposed by: %s\n' % proposer.unique_displayname) for review in bmp.votes: # If comment is None, this is a request for a review, not # a completed review. if review.comment is None: continue outf.write(' review: %s - %s\n' % (review.comment.vote.title, review.reviewer.unique_displayname)) info = RevisionInfo(self.bzr_branch, revno, revision_id) lf = log_formatter('long', to_file=outf) show_log(self.bzr_branch, lf, start_revision=info, end_revision=info, verbose=True) finally: self.bzr_branch.unlock() return outf.getvalue()
def test_trailing_newlines(self): wt = self.make_branch_and_tree('.') b = make_commits_with_trailing_newlines(wt) sio = self.make_utf8_encoded_stringio() lf = LineLogFormatter(to_file=sio) show_log(b, lf) self.assertEqualDiff(sio.getvalue(), """\ 3: Joe Foo 2005-11-21 single line with trailing newline 2: Joe Bar 2005-11-21 multiline 1: Joe Foo 2005-11-21 simple log message """)
def test_trailing_newlines(self): wt = self.make_branch_and_tree('.') b = make_commits_with_trailing_newlines(wt) sio = self.make_utf8_encoded_stringio() lf = LineLogFormatter(to_file=sio) show_log(b, lf) self.assertEqualDiff( sio.getvalue(), """\ 3: Joe Foo 2005-11-21 single line with trailing newline 2: Joe Bar 2005-11-21 multiline 1: Joe Foo 2005-11-21 simple log message """)
def test_verbose_merge_revisions_contain_deltas(self): wt = self.make_branch_and_tree('parent') self.build_tree(['parent/f1', 'parent/f2']) wt.add(['f1', 'f2']) wt.commit('first post') self.run_bzr('branch parent child') os.unlink('child/f1') file('child/f2', 'wb').write('hello\n') self.run_bzr(['commit', '-m', 'removed f1 and modified f2', 'child']) os.chdir('parent') self.run_bzr('merge ../child') wt.commit('merge branch 1') b = wt.branch sio = self.make_utf8_encoded_stringio() lf = LongLogFormatter(to_file=sio) show_log(b, lf, verbose=True) log = normalize_log(sio.getvalue()) self.assertEqualDiff( log, """\ ------------------------------------------------------------ revno: 2 committer: Lorem Ipsum <*****@*****.**> branch nick: parent timestamp: Just now message: merge branch 1 removed: f1 modified: f2 ------------------------------------------------------------ revno: 1.1.1 committer: Lorem Ipsum <*****@*****.**> branch nick: child timestamp: Just now message: removed f1 and modified f2 removed: f1 modified: f2 ------------------------------------------------------------ revno: 1 committer: Lorem Ipsum <*****@*****.**> branch nick: parent timestamp: Just now message: first post added: f1 f2 """)
def test_verbose_merge_revisions_contain_deltas(self): wt = self.make_branch_and_tree('parent') self.build_tree(['parent/f1', 'parent/f2']) wt.add(['f1','f2']) wt.commit('first post') self.run_bzr('branch parent child') os.unlink('child/f1') file('child/f2', 'wb').write('hello\n') self.run_bzr(['commit', '-m', 'removed f1 and modified f2', 'child']) os.chdir('parent') self.run_bzr('merge ../child') wt.commit('merge branch 1') b = wt.branch sio = self.make_utf8_encoded_stringio() lf = LongLogFormatter(to_file=sio) show_log(b, lf, verbose=True) log = normalize_log(sio.getvalue()) self.assertEqualDiff(log, """\ ------------------------------------------------------------ revno: 2 committer: Lorem Ipsum <*****@*****.**> branch nick: parent timestamp: Just now message: merge branch 1 removed: f1 modified: f2 ------------------------------------------------------------ revno: 1.1.1 committer: Lorem Ipsum <*****@*****.**> branch nick: child timestamp: Just now message: removed f1 and modified f2 removed: f1 modified: f2 ------------------------------------------------------------ revno: 1 committer: Lorem Ipsum <*****@*****.**> branch nick: parent timestamp: Just now message: first post added: f1 f2 """)
def test_cur_revno(self): wt = self.make_branch_and_tree('.') b = wt.branch lf = LogCatcher() wt.commit('empty commit') show_log(b, lf, verbose=True, start_revision=1, end_revision=1) self.assertRaises(InvalidRevisionNumber, show_log, b, lf, start_revision=2, end_revision=1) self.assertRaises(InvalidRevisionNumber, show_log, b, lf, start_revision=1, end_revision=2) self.assertRaises(InvalidRevisionNumber, show_log, b, lf, start_revision=0, end_revision=2) self.assertRaises(InvalidRevisionNumber, show_log, b, lf, start_revision=1, end_revision=0) self.assertRaises(InvalidRevisionNumber, show_log, b, lf, start_revision=-1, end_revision=1) self.assertRaises(InvalidRevisionNumber, show_log, b, lf, start_revision=1, end_revision=-1)
def test_line_log(self): """Line log should show revno bug #5162 """ wt = self.make_branch_and_tree('.') b = wt.branch self.build_tree(['a']) wt.add('a') b.nick = 'test-line-log' wt.commit(message='add a', timestamp=1132711707, timezone=36000, committer='Line-Log-Formatter Tester <*****@*****.**>') logfile = file('out.tmp', 'w+') formatter = LineLogFormatter(to_file=logfile) show_log(b, formatter) logfile.flush() logfile.seek(0) log_contents = logfile.read() self.assertEqualDiff(log_contents, '1: Line-Log-Formatte... 2005-11-23 add a\n')
def test_properties_in_log(self): """Log includes the custom properties returned by the registered handlers. """ wt = self.make_branch_and_tree('.') b = wt.branch self.build_tree(['a']) wt.add('a') b.nick = 'test_properties_in_log' wt.commit(message='add a', timestamp=1132711707, timezone=36000, committer='Lorem Ipsum <*****@*****.**>', author='John Doe <*****@*****.**>') sio = StringIO() formatter = LongLogFormatter(to_file=sio) try: def trivial_custom_prop_handler(revision): return {'test_prop': 'test_value'} log.properties_handler_registry.register( 'trivial_custom_prop_handler', trivial_custom_prop_handler) show_log(b, formatter) finally: log.properties_handler_registry.remove( 'trivial_custom_prop_handler') self.assertEqualDiff( sio.getvalue(), '''\ ------------------------------------------------------------ revno: 1 test_prop: test_value author: John Doe <*****@*****.**> committer: Lorem Ipsum <*****@*****.**> branch nick: test_properties_in_log timestamp: Wed 2005-11-23 12:08:27 +1000 message: add a ''')
def body(self): from bzrlib import log rev1 = rev2 = self.revno if rev1 == 0: rev1 = None rev2 = None # use 'replace' so that we don't abort if trying to write out # in e.g. the default C locale. # We must use StringIO.StringIO because we want a Unicode string that # we can pass to send_email and have that do the proper encoding. from StringIO import StringIO outf = StringIO() outf.write('At %s\n\n' % self.url()) lf = log.log_formatter('long', show_ids=True, to_file=outf ) if len(self.revision.parent_ids) <= 1: # This is not a merge, so we can special case the display of one # revision, and not have to encur the show_log overhead. lr = log.LogRevision(self.revision, self.revno, 0, None) lf.log_revision(lr) else: # let the show_log code figure out what revisions need to be # displayed, as this is a merge log.show_log(self.branch, lf, start_revision=rev1, end_revision=rev2, verbose=True ) return outf.getvalue()
def test_properties_in_log(self): """Log includes the custom properties returned by the registered handlers. """ wt = self.make_branch_and_tree('.') b = wt.branch self.build_tree(['a']) wt.add('a') b.nick = 'test_properties_in_log' wt.commit(message='add a', timestamp=1132711707, timezone=36000, committer='Lorem Ipsum <*****@*****.**>', author='John Doe <*****@*****.**>') sio = StringIO() formatter = LongLogFormatter(to_file=sio) try: def trivial_custom_prop_handler(revision): return {'test_prop':'test_value'} log.properties_handler_registry.register( 'trivial_custom_prop_handler', trivial_custom_prop_handler) show_log(b, formatter) finally: log.properties_handler_registry.remove( 'trivial_custom_prop_handler') self.assertEqualDiff(sio.getvalue(), '''\ ------------------------------------------------------------ revno: 1 test_prop: test_value author: John Doe <*****@*****.**> committer: Lorem Ipsum <*****@*****.**> branch nick: test_properties_in_log timestamp: Wed 2005-11-23 12:08:27 +1000 message: add a ''')
def run(self, num=10): try: num = int(num) except (ValueError, TypeError): num = 10 warning('bzr lastlog only accepts numbers, defaulting to %d.' % num) dir, relpath = bzrdir.BzrDir.open_containing('.') b = dir.open_branch() num_revisions = len(b.revision_history()) if num_revisions == 0: error('Sorry, no revisions available.') return first_revision = num_revisions - num + 1 last_revision = num_revisions if first_revision < 1: first_revision = 1 outf = codecs.getwriter(bzrlib.user_encoding)(sys.stdout, errors='replace') lf = log_formatter('short', show_ids=False, to_file=outf, show_timezone='original') show_log(b, lf, None, verbose=False, direction='forward', start_revision=first_revision, end_revision=last_revision, search=None)
def get_commits(self, repository, start, end=None, full=None): branch = None if repository: repository = repository.lower() if repository not in self.branches: return None branch = self.branches[repository] if not branch: if len(self.branches) == 1: (repository, branch) = self.branches.items()[0] else: (repository, branch) = sorted(self.branches.iteritems(), reverse=True, key=lambda (k,v): v.repository.get_revision(v.last_revision_info()[1]).timestamp)[0] if not start: start = branch.revision_id_to_revno(branch.last_revision()) f=StringIO(); log.show_log(branch, LogFormatter(f, repository, branch, full), start_revision=start, end_revision=end or start) f.seek(0) commits = f.readlines() commits.reverse() return commits
def test_deltas_in_merge_revisions(self): """Check deltas created for both mainline and merge revisions""" eq = self.assertEquals wt = self.make_branch_and_tree('parent') self.build_tree(['parent/file1', 'parent/file2', 'parent/file3']) wt.add('file1') wt.add('file2') wt.commit(message='add file1 and file2') self.run_bzr('branch parent child') os.unlink('child/file1') file('child/file2', 'wb').write('hello\n') self.run_bzr(['commit', '-m', 'remove file1 and modify file2', 'child']) os.chdir('parent') self.run_bzr('merge ../child') wt.commit('merge child branch') os.chdir('..') b = wt.branch lf = LogCatcher() lf.supports_merge_revisions = True show_log(b, lf, verbose=True) eq(len(lf.logs),3) logentry = lf.logs[0] eq(logentry.revno, '2') eq(logentry.rev.message, 'merge child branch') d = logentry.delta self.checkDelta(d, removed=['file1'], modified=['file2']) logentry = lf.logs[1] eq(logentry.revno, '1.1.1') eq(logentry.rev.message, 'remove file1 and modify file2') d = logentry.delta self.checkDelta(d, removed=['file1'], modified=['file2']) logentry = lf.logs[2] eq(logentry.revno, '1') eq(logentry.rev.message, 'add file1 and file2') d = logentry.delta self.checkDelta(d, added=['file1', 'file2'])
def test_deltas_in_merge_revisions(self): """Check deltas created for both mainline and merge revisions""" eq = self.assertEquals wt = self.make_branch_and_tree('parent') self.build_tree(['parent/file1', 'parent/file2', 'parent/file3']) wt.add('file1') wt.add('file2') wt.commit(message='add file1 and file2') self.run_bzr('branch parent child') os.unlink('child/file1') file('child/file2', 'wb').write('hello\n') self.run_bzr( ['commit', '-m', 'remove file1 and modify file2', 'child']) os.chdir('parent') self.run_bzr('merge ../child') wt.commit('merge child branch') os.chdir('..') b = wt.branch lf = LogCatcher() lf.supports_merge_revisions = True show_log(b, lf, verbose=True) eq(len(lf.logs), 3) logentry = lf.logs[0] eq(logentry.revno, '2') eq(logentry.rev.message, 'merge child branch') d = logentry.delta self.checkDelta(d, removed=['file1'], modified=['file2']) logentry = lf.logs[1] eq(logentry.revno, '1.1.1') eq(logentry.rev.message, 'remove file1 and modify file2') d = logentry.delta self.checkDelta(d, removed=['file1'], modified=['file2']) logentry = lf.logs[2] eq(logentry.revno, '1') eq(logentry.rev.message, 'add file1 and file2') d = logentry.delta self.checkDelta(d, added=['file1', 'file2'])
def test_short_log_with_merges(self): wt = self.make_branch_and_memory_tree('.') wt.lock_write() try: wt.add('') wt.commit('rev-1', rev_id='rev-1', timestamp=1132586655, timezone=36000, committer='Joe Foo <*****@*****.**>') wt.commit('rev-merged', rev_id='rev-2a', timestamp=1132586700, timezone=36000, committer='Joe Foo <*****@*****.**>') wt.set_parent_ids(['rev-1', 'rev-2a']) wt.branch.set_last_revision_info(1, 'rev-1') wt.commit('rev-2', rev_id='rev-2b', timestamp=1132586800, timezone=36000, committer='Joe Foo <*****@*****.**>') logfile = self.make_utf8_encoded_stringio() formatter = ShortLogFormatter(to_file=logfile) show_log(wt.branch, formatter) self.assertEqualDiff( logfile.getvalue(), """\ 2 Joe Foo\t2005-11-22 [merge] rev-2 1 Joe Foo\t2005-11-22 rev-1 """) finally: wt.unlock()
def test_simple_log(self): eq = self.assertEquals wt = self.make_branch_and_tree('.') b = wt.branch lf = LogCatcher() show_log(b, lf) # no entries yet eq(lf.logs, []) wt.commit('empty commit') lf = LogCatcher() show_log(b, lf, verbose=True) eq(len(lf.logs), 1) eq(lf.logs[0].revno, '1') eq(lf.logs[0].rev.message, 'empty commit') d = lf.logs[0].delta self.log('log delta: %r' % d) self.checkDelta(d) self.build_tree(['hello']) wt.add('hello') wt.commit('add one file', committer=u'\u013d\xf3r\xe9m \xcdp\u0161\xfam ' u'<*****@*****.**>') lf = self.make_utf8_encoded_stringio() # log using regular thing show_log(b, LongLogFormatter(lf)) lf.seek(0) for l in lf.readlines(): self.log(l) # get log as data structure lf = LogCatcher() show_log(b, lf, verbose=True) eq(len(lf.logs), 2) self.log('log entries:') for logentry in lf.logs: self.log('%4s %s' % (logentry.revno, logentry.rev.message)) # first one is most recent logentry = lf.logs[0] eq(logentry.revno, '2') eq(logentry.rev.message, 'add one file') d = logentry.delta self.log('log 2 delta: %r' % d) self.checkDelta(d, added=['hello']) # commit a log message with control characters msg = "All 8-bit chars: " + ''.join([unichr(x) for x in range(256)]) self.log("original commit message: %r", msg) wt.commit(msg) lf = LogCatcher() show_log(b, lf, verbose=True) committed_msg = lf.logs[0].rev.message self.log("escaped commit message: %r", committed_msg) self.assert_(msg != committed_msg) self.assert_(len(committed_msg) > len(msg)) # Check that log message with only XML-valid characters isn't # escaped. As ElementTree apparently does some kind of # newline conversion, neither LF (\x0A) nor CR (\x0D) are # included in the test commit message, even though they are # valid XML 1.0 characters. msg = "\x09" + ''.join([unichr(x) for x in range(0x20, 256)]) self.log("original commit message: %r", msg) wt.commit(msg) lf = LogCatcher() show_log(b, lf, verbose=True) committed_msg = lf.logs[0].rev.message self.log("escaped commit message: %r", committed_msg) self.assert_(msg == committed_msg)