def _set_revision(self, revision): if revision is None: return self._revision = revision if revision.committer is not None: self.committer.set_text(revision.committer) else: self.committer.set_text("") author = revision.properties.get('author', '') if author != '': self.author.set_text(author) self.author.show() self.author_label.show() else: self.author.hide() self.author_label.hide() if revision.timestamp is not None: self.timestamp.set_text(format_date(revision.timestamp, revision.timezone)) try: self.branchnick.show() self.branchnick_label.show() self.branchnick.set_text(revision.properties['branch-nick']) except KeyError: self.branchnick.hide() self.branchnick_label.hide() self._add_parents_or_children(revision.parent_ids, self.parents_widgets, self.parents_table) file_info = revision.properties.get('file-info', None) if file_info is not None: try: file_info = bdecode(file_info.encode('UTF-8')) except ValueError: trace.note('Invalid per-file info for revision:%s, value: %r', revision.revision_id, file_info) file_info = None if file_info: if self._file_id is None: text = [] for fi in file_info: text.append('%(path)s\n%(message)s' % fi) self.file_info_buffer.set_text('\n'.join(text)) self.file_info_box.show() else: text = [] for fi in file_info: if fi['file_id'] == self._file_id: text.append(fi['message']) if text: self.file_info_buffer.set_text('\n'.join(text)) self.file_info_box.show() else: self.file_info_box.hide() else: self.file_info_box.hide()
def log_revision(self, revision): r = revision.rev if self.hide_merges and len(r.parent_ids) > 1: return to_file = self.to_file to_file.write('\033[33mrevision %s (%s)\033[m\n' % (r.revision_id, revision.revno)) author = r.properties.get('author', None) if author is not None: to_file.write('\033[;1mAuthor:\033[m %s\n\033[;1mCommitter:\033[m %s\n' % (author, r.committer)) else: to_file.write('\033[;1mAuthor:\033[m %s\n' % (r.committer,)) to_file.write('\033[;1mDate:\033[m ' + format_date(revision.rev.timestamp, revision.rev.timezone or 0) + '\n') branch_nick = r.properties.get('branch-nick', None) if branch_nick is not None: to_file.write('\033[;1mBranch:\033[m %s\n' % (branch_nick,)) if revision.tags: to_file.write('\033[;1mTags:\033[m \033[93m%s\033[m\n' % (', '.join(revision.tags),)) bugs = r.properties.get('bugs', None) if bugs: to_file.write('\033[;1mBugs:\033[m \033[91m%s\033[m\n' % (bugs.replace('\n', ', '),)) to_file.write('\n') for line in r.message.strip().splitlines(): to_file.write(' ' + line + '\n') if revision.diff is not None: to_file.write('\n') self.show_diff(self.to_exact_file, revision.diff, '') to_file.write('\n') to_file.write('\n')
def log_revision(self, revision): """Log a revision, either merged or not.""" to_file = self.to_file date_str = format_date(revision.rev.timestamp, revision.rev.timezone or 0, self.show_timezone, date_fmt='%Y-%m-%d', show_offset=False) authors = revision.rev.get_apparent_authors() to_file.write('%s %s\n\n' % (date_str, ", ".join(authors))) if revision.delta is not None and revision.delta.has_changed(): for c in revision.delta.added + revision.delta.removed + \ revision.delta.modified: path, = c[:1] to_file.write('\t* %s:\n' % (path,)) for c in revision.delta.renamed: oldpath, newpath = c[:2] # For renamed files, show both the old and the new path to_file.write('\t* %s:\n\t* %s:\n' % (oldpath, newpath)) to_file.write('\n') if not revision.rev.message: to_file.write('\tNo commit message\n') else: message = revision.rev.message.rstrip('\r\n') for l in message.split('\n'): to_file.write('\t%s\n' % (l.lstrip(),)) to_file.write('\n')
def get_bzr_modification_date(filename): from bzrlib.osutils import format_date mtime, timezone = get_bzr_timestamp(filename) return format_date(mtime, timezone, 'utc', date_fmt=DATE_FORMAT, show_offset=False)
def test_commit_time(self): tree = self.make_branch_and_tree('tree') self.build_tree(['tree/hello.txt']) tree.add('hello.txt') out, err = self.run_bzr("commit -m hello " "--commit-time='2009-10-10 08:00:00 +0100' tree/hello.txt") last_rev = tree.branch.repository.get_revision(tree.last_revision()) self.assertEqual( 'Sat 2009-10-10 08:00:00 +0100', osutils.format_date(last_rev.timestamp, last_rev.timezone))
def __str__(self): timestamp = self.top_rev.rev.timestamp timezone = self.top_rev.rev.timezone message = self.top_rev.rev.message or "(NO LOG MESSAGE)" rev_id = self.top_rev.rev.revision_id or "(NO REVISION ID)" if timestamp: date_str = format_date(timestamp, timezone or 0, 'original') else: date_str = "(NO DATE)" rev_url_base = "https://bazaar.launchpad.net/%s/revision/" % ( self.branch_info.loggerhead_path) # In loggerhead, you can use either a revision number or a # revision ID. In other words, these would reach the same page: # # https://bazaar.launchpad.net/~launchpad-pqm/launchpad/devel/\ # revision/9202 # # -and- # # https://bazaar.launchpad.net/~launchpad-pqm/launchpad/devel/\ # revision/[email protected]\ # ritpv21q8w61gbpt # # In our links, even when the link text is a revnum, we still # use a rev-id for the target. This is both so that the URL will # still work if you manually tweak it (say to "db-devel" from # "devel") and so that hovering over a revnum on the wiki page # will give you some information about it before you click # (because a rev id often identifies the committer). rev_id_url = rev_url_base + rev_id if len(self.contained_revs) <= 10: commits_block = "\n ".join([ "[[%s|%s]]" % (rev_url_base + lr.rev.revision_id, lr.revno) for lr in self.contained_revs ]) else: commits_block = ("''see the [[%s|full revision]] for details " "(it contains %d commits)''" % (rev_id_url, len(self.contained_revs))) name = self.branch_info.name text = [ " * [[%s|r%s%s]] -- %s\n" % (rev_id_url, self.top_rev.revno, ' (%s)' % name.encode('utf-8') if name else '', date_str), " {{{\n%s\n}}}\n" % message.encode('utf-8'), " '''Commits:'''\n ", commits_block, "\n", ] return ''.join(text)
def __str__(self): timestamp = self.top_rev.rev.timestamp timezone = self.top_rev.rev.timezone message = self.top_rev.rev.message or "(NO LOG MESSAGE)" rev_id = self.top_rev.rev.revision_id or "(NO REVISION ID)" if timestamp: date_str = format_date(timestamp, timezone or 0, 'original') else: date_str = "(NO DATE)" rev_url_base = "http://bazaar.launchpad.net/%s/revision/" % ( self.branch_info.loggerhead_path) # In loggerhead, you can use either a revision number or a # revision ID. In other words, these would reach the same page: # # http://bazaar.launchpad.net/~launchpad-pqm/launchpad/devel/\ # revision/9202 # # -and- # # http://bazaar.launchpad.net/~launchpad-pqm/launchpad/devel/\ # revision/[email protected]\ # ritpv21q8w61gbpt # # In our links, even when the link text is a revnum, we still # use a rev-id for the target. This is both so that the URL will # still work if you manually tweak it (say to "db-devel" from # "devel") and so that hovering over a revnum on the wiki page # will give you some information about it before you click # (because a rev id often identifies the committer). rev_id_url = rev_url_base + rev_id if len(self.contained_revs) <= 10: commits_block = "\n ".join( ["[[%s|%s]]" % (rev_url_base + lr.rev.revision_id, lr.revno) for lr in self.contained_revs]) else: commits_block = ("''see the [[%s|full revision]] for details " "(it contains %d commits)''" % (rev_id_url, len(self.contained_revs))) name = self.branch_info.name text = [ " * [[%s|r%s%s]] -- %s\n" % ( rev_id_url, self.top_rev.revno, ' (%s)' % name.encode('utf-8') if name else '', date_str), " {{{\n%s\n}}}\n" % message.encode('utf-8'), " '''Commits:'''\n ", commits_block, "\n", ] return ''.join(text)
def _show_branch_stats(branch, verbose, outfile): """Show statistics about a branch.""" revno, head = branch.last_revision_info() outfile.write('\n') outfile.write('Branch history:\n') outfile.write(' %8d revision%s\n' % (revno, plural(revno))) stats = branch.repository.gather_stats(head, committers=verbose) if verbose: committers = stats['committers'] outfile.write(' %8d committer%s\n' % (committers, plural(committers))) if revno: timestamp, timezone = stats['firstrev'] age = int((time.time() - timestamp) / 3600 / 24) outfile.write(' %8d day%s old\n' % (age, plural(age))) outfile.write(' first revision: %s\n' % osutils.format_date(timestamp, timezone)) timestamp, timezone = stats['latestrev'] outfile.write(' latest revision: %s\n' % osutils.format_date(timestamp, timezone)) return stats
def test_commit_time_positive_32bit(self): tree = self.make_branch_and_tree('tree') self.build_tree(['tree/hello.txt']) tree.add('hello.txt') out, err = self.run_bzr( "commit -m hello " "--commit-time='2039-01-01 00:00:00 +0000' tree/hello.txt") last_rev = tree.branch.repository.get_revision(tree.last_revision()) self.assertEqual( 'Sat 2039-01-01 00:00:00 +0000', osutils.format_date(last_rev.timestamp, last_rev.timezone))
def create_date_str(timestamp=None, offset=None): """Just a wrapper around format_date to provide the right format. We don't want to use '%a' in the time string, because it is locale dependant. We also want to force timezone original, and show_offset Without parameters this function yields the current date in the local time zone. """ if timestamp is None and offset is None: timestamp = time.time() offset = local_time_offset() return format_date(timestamp, offset, date_fmt='%Y-%m-%d %H:%M:%S', timezone='original', show_offset=True)
def log_revision(self, revision): # We need two indents: one per depth and one for the information # relative to that indent. Most mainline revnos are 5 chars or # less while dotted revnos are typically 11 chars or less. Once # calculated, we need to remember the offset for a given depth # as we might be starting from a dotted revno in the first column # and we want subsequent mainline revisions to line up. depth = revision.merge_depth indent = " " * depth global logvar revno_width = self.revno_width_by_depth.get(depth) if revno_width is None: if revision.revno is None or revision.revno.find(".") == -1: # mainline revno, e.g. 12345 revno_width = 5 else: # dotted revno, e.g. 12345.10.55 revno_width = 11 self.revno_width_by_depth[depth] = revno_width offset = " " * (revno_width + 1) to_file = self.to_file tags = "" if revision.tags: tags = " {%s}" % (", ".join(revision.tags)) logvar += "<item>\n<title>%s committed revision %s %s</title>\n" % ( self.short_author(revision.rev), revision.revno or "", self.merge_marker(revision), ) logvar += "<pubDate>%s</pubDate>\n" % format_date( revision.rev.timestamp, revision.rev.timezone or 0, self.show_timezone, date_fmt="%a, %d %b %Y %H:%M:%S %z", show_offset=False, ) logvar += "<description>\n" self.show_properties(revision.rev, indent + offset) if revision.rev.message: message = revision.rev.message.rstrip("\r\n") for l in message.split("\n"): logvar += web.net.websafe(l) logvar += "</description>\n" logvar += "<guid>%s</guid>\n" % revision.rev.revision_id logvar += "<link>$l#%s</link>\n" % revision.revno logvar += "</item>\n"
def format_patch_date(secs, offset=0): """Format a POSIX timestamp and optional offset as a patch-style date. Inverse of parse_patch_date. """ if offset % 60 != 0: raise ValueError( "can't represent timezone %s offset by fractional minutes" % offset) # so that we don't need to do calculations on pre-epoch times, # which doesn't work with win32 python gmtime, we always # give the epoch in utc if secs == 0: offset = 0 return osutils.format_date(secs, offset=offset, date_fmt='%Y-%m-%d %H:%M:%S')
def format_patch_date(secs, offset=0): """Format a POSIX timestamp and optional offset as a patch-style date. Inverse of parse_patch_date. """ if offset % 60 != 0: raise ValueError( "can't represent timezone %s offset by fractional minutes" % offset) # so that we don't need to do calculations on pre-epoch times, # which doesn't work with win32 python gmtime, we always # give the epoch in utc if secs == 0: offset = 0 if secs + offset < 0: from warnings import warn warn("gmtime of negative time (%s, %s) may not work on Windows" % (secs, offset)) return osutils.format_date(secs, offset=offset, date_fmt='%Y-%m-%d %H:%M:%S')
def generate_for_iterator(self, feed, revno_revision_iterator): template = Template(self.ATOM_ITEM_TEMPLATE) for revno, revision in self.iter_revisions(): feed += template.substitute({ 'title': 'revision %s' % revno, 'id': revision.revision_id, 'author': revision.committer, 'updated': format_date(revision.timestamp, revision.timezone or 0, 'utc', '%Y-%m-%dT%H:%M:%SZ', show_offset=False), 'content': revision.message, }) return feed
def log_revision(self, revision): """Log a revision, either merged or not.""" indent = ' ' * revision.merge_depth to_file = self.to_file to_file.write(indent + '-' * 60 + '\n') if revision.revno is not None: to_file.write(indent + 'revno: %s\n' % (revision.revno,)) if revision.tags: to_file.write(indent + 'tags: %s\n' % (', '.join(revision.tags))) if self.show_ids: to_file.write(indent + 'revision-id: ' + revision.rev.revision_id) to_file.write('\n') for parent_id in revision.rev.parent_ids: to_file.write(indent + 'parent: %s\n' % (parent_id,)) self.show_properties(revision.rev, indent) author = revision.rev.properties.get('author', None) if author is not None: to_file.write(indent + 'author: %s\n' % (author,)) to_file.write(indent + 'committer: %s\n' % (revision.rev.committer,)) branch_nick = revision.rev.properties.get('branch-nick', None) if branch_nick is not None: to_file.write(indent + 'branch nick: %s\n' % (branch_nick,)) date_str = format_date(revision.rev.timestamp, revision.rev.timezone or 0, self.show_timezone) to_file.write(indent + 'timestamp: %s\n' % (date_str,)) to_file.write(indent + 'message:\n') if not revision.rev.message: to_file.write(indent + ' (no message)\n') else: message = revision.rev.message.rstrip('\r\n') for l in message.split('\n'): to_file.write(indent + ' %s\n' % (l,)) if revision.delta is not None: revision.delta.show(to_file, self.show_ids, indent=indent)
def generate(self): """Generate the feed content. The title of the feed is pulled from the branch nick, and the id from the branch URL. :return: a bytestring containing the feed. """ template = Template(self.ATOM_HEAD_TEMPLATE) feed = template.substitute({ 'title': self.branch.nick, 'id': str(self.branch.base), 'updated': format_date(self.now, 0, 'utc', '%Y-%m-%dT%H:%M:%SZ', show_offset=False) }) feed = self.generate_for_iterator(feed, self.iter_revisions()) return feed.encode('utf8')
def log_revision(self, revision): r = revision.rev if self.hide_merges and len(r.parent_ids) > 1: return to_file = self.to_file to_file.write('\033[33mrevision %s (%s)\033[m\n' % (r.revision_id, revision.revno)) author = r.properties.get('author', None) if author is not None: to_file.write( '\033[;1mAuthor:\033[m %s\n\033[;1mCommitter:\033[m %s\n' % (author, r.committer)) else: to_file.write('\033[;1mAuthor:\033[m %s\n' % (r.committer, )) to_file.write( '\033[;1mDate:\033[m ' + format_date(revision.rev.timestamp, revision.rev.timezone or 0) + '\n') branch_nick = r.properties.get('branch-nick', None) if branch_nick is not None: to_file.write('\033[;1mBranch:\033[m %s\n' % (branch_nick, )) if revision.tags: to_file.write('\033[;1mTags:\033[m \033[93m%s\033[m\n' % (', '.join(revision.tags), )) bugs = r.properties.get('bugs', None) if bugs: to_file.write('\033[;1mBugs:\033[m \033[91m%s\033[m\n' % (bugs.replace('\n', ', '), )) to_file.write('\n') for line in r.message.strip().splitlines(): to_file.write(' ' + line + '\n') if revision.diff is not None: to_file.write('\n') self.show_diff(self.to_exact_file, revision.diff, '') to_file.write('\n') to_file.write('\n')
def date_string(self, rev): return format_date(rev.timestamp, rev.timezone or 0, self.show_timezone, date_fmt="%Y-%m-%d", show_offset=False)
def log_revision(self, revision): # We need two indents: one per depth and one for the information # relative to that indent. Most mainline revnos are 5 chars or # less while dotted revnos are typically 11 chars or less. Once # calculated, we need to remember the offset for a given depth # as we might be starting from a dotted revno in the first column # and we want subsequent mainline revisions to line up. depth = revision.merge_depth indent = " " * depth global logvar revno_width = self.revno_width_by_depth.get(depth) if revno_width is None: if revision.revno is None or revision.revno.find(".") == -1: # mainline revno, e.g. 12345 revno_width = 5 else: # dotted revno, e.g. 12345.10.55 revno_width = 11 self.revno_width_by_depth[depth] = revno_width offset = " " * (revno_width + 1) to_file = self.to_file tags = "" if revision.tags: tags = " {%s}" % (", ".join(revision.tags)) logvar += '<div id="%s" class="revision">' % revision.revno logvar += '<div class="revdate">%s</div>' % format_date( revision.rev.timestamp, revision.rev.timezone or 0, self.show_timezone, date_fmt="%Y-%m-%d", show_offset=False, ) logvar += '<div class="revbody">' logvar += '<p class="revinfo">%s committed revision <span class="hl">%s</span> %s</p>' % ( self.short_author(revision.rev), revision.revno or "", self.merge_marker(revision), ) if tags != "": logvar += '<p class="tags">%s</p>' % tags self.show_properties(revision.rev, indent + offset) if self.show_ids or revision.revno is None: logvar += '<p class="revmessage">revision-id:%s</p>' % revision.rev.revision_id if not revision.rev.message: logvar += '<p class="revmessage">(no message)</p>' else: message = revision.rev.message.rstrip("\r\n") for l in message.split("\n"): logvar += '<p class="revmessage">%s</p>' % web.net.websafe(l) if revision.delta is not None: # Use the standard status output to display changes from bzrlib.delta import report_delta report_delta( to_file, revision.delta, short_status=self.delta_format == 1, show_ids=self.show_ids, indent=indent + offset, ) if revision.diff is not None: self.show_diff(self.to_exact_file, revision.diff, " ") logvar += '</div><div class="clear"></div></div>'
def test_info_shared_repository_with_trees(self): format = bzrdir.format_registry.make_bzrdir('knit') transport = self.get_transport() # Create shared repository with working trees repo = self.make_repository('repo', shared=True, format=format) repo.set_make_working_trees(True) out, err = self.run_bzr('info -v repo') self.assertEqualDiff( """Shared repository with trees (format: dirstate or dirstate-tags or knit) Location: shared repository: repo Format: control: Meta directory format 1 repository: %s Create working tree for new branches inside the repository. Repository: 0 revisions """ % (format.repository_format.get_format_description(), ), out) self.assertEqual('', err) # Create two branches repo.bzrdir.root_transport.mkdir('branch1') branch1 = repo.bzrdir.create_branch_convenience('repo/branch1', format=format) branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch() # Empty first branch out, err = self.run_bzr('info repo/branch1 --verbose') self.assertEqualDiff( """Repository tree (format: knit) Location: shared repository: repo repository branch: repo/branch1 Format: control: Meta directory format 1 working tree: Working tree format 3 branch: %s repository: %s In the working tree: 0 unchanged 0 modified 0 added 0 removed 0 renamed 0 unknown 0 ignored 0 versioned subdirectories Branch history: 0 revisions 0 committers Repository: 0 revisions """ % (format.get_branch_format().get_format_description(), format.repository_format.get_format_description(), ), out) self.assertEqual('', err) # Update first branch self.build_tree(['repo/branch1/a']) tree1 = branch1.bzrdir.open_workingtree() tree1.add('a') tree1.commit('commit one') rev = repo.get_revision(branch1.revision_history()[0]) datestring_first = format_date(rev.timestamp, rev.timezone) out, err = self.run_bzr('info -v repo/branch1') self.assertEqualDiff( """Repository tree (format: knit) Location: shared repository: repo repository branch: repo/branch1 Format: control: Meta directory format 1 working tree: Working tree format 3 branch: %s repository: %s In the working tree: 1 unchanged 0 modified 0 added 0 removed 0 renamed 0 unknown 0 ignored 0 versioned subdirectories Branch history: 1 revision 1 committer 0 days old first revision: %s latest revision: %s Repository: 1 revision """ % (format.get_branch_format().get_format_description(), format.repository_format.get_format_description(), datestring_first, datestring_first, ), out) self.assertEqual('', err) # Out of date second branch out, err = self.run_bzr('info repo/branch2 --verbose') self.assertEqualDiff( """Repository tree (format: knit) Location: shared repository: repo repository branch: repo/branch2 Related branches: parent branch: repo/branch1 Format: control: Meta directory format 1 working tree: Working tree format 3 branch: %s repository: %s In the working tree: 0 unchanged 0 modified 0 added 0 removed 0 renamed 0 unknown 0 ignored 0 versioned subdirectories Branch history: 0 revisions 0 committers Repository: 1 revision """ % (format.get_branch_format().get_format_description(), format.repository_format.get_format_description(), ), out) self.assertEqual('', err) # Update second branch tree2 = branch2.bzrdir.open_workingtree() tree2.pull(branch1) out, err = self.run_bzr('info -v repo/branch2') self.assertEqualDiff( """Repository tree (format: knit) Location: shared repository: repo repository branch: repo/branch2 Related branches: parent branch: repo/branch1 Format: control: Meta directory format 1 working tree: Working tree format 3 branch: %s repository: %s In the working tree: 1 unchanged 0 modified 0 added 0 removed 0 renamed 0 unknown 0 ignored 0 versioned subdirectories Branch history: 1 revision 1 committer 0 days old first revision: %s latest revision: %s Repository: 1 revision """ % (format.get_branch_format().get_format_description(), format.repository_format.get_format_description(), datestring_first, datestring_first, ), out) self.assertEqual('', err) # Show info about repository with revisions out, err = self.run_bzr('info -v repo') self.assertEqualDiff( """Shared repository with trees (format: dirstate or dirstate-tags or knit) Location: shared repository: repo Format: control: Meta directory format 1 repository: %s Create working tree for new branches inside the repository. Repository: 1 revision """ % (format.repository_format.get_format_description(), ), out) self.assertEqual('', err)
def test_info_shared_repository(self): format = bzrdir.format_registry.make_bzrdir('knit') transport = self.get_transport() # Create shared repository repo = self.make_repository('repo', shared=True, format=format) repo.set_make_working_trees(False) out, err = self.run_bzr('info -v repo') self.assertEqualDiff( """Shared repository (format: dirstate or dirstate-tags or knit) Location: shared repository: %s Format: control: Meta directory format 1 repository: %s Repository: 0 revisions """ % ('repo', format.repository_format.get_format_description(), ), out) self.assertEqual('', err) # Create branch inside shared repository repo.bzrdir.root_transport.mkdir('branch') branch1 = repo.bzrdir.create_branch_convenience('repo/branch', format=format) out, err = self.run_bzr('info -v repo/branch') self.assertEqualDiff( """Repository branch (format: dirstate or knit) Location: shared repository: repo repository branch: repo/branch Format: control: Meta directory format 1 branch: %s repository: %s Branch history: 0 revisions 0 committers Repository: 0 revisions """ % (format.get_branch_format().get_format_description(), format.repository_format.get_format_description(), ), out) self.assertEqual('', err) # Create lightweight checkout transport.mkdir('tree') transport.mkdir('tree/lightcheckout') tree2 = branch1.create_checkout('tree/lightcheckout', lightweight=True) branch2 = tree2.branch self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2, shared_repo=repo, repo_branch=branch1, verbose=True) # Create normal checkout tree3 = branch1.create_checkout('tree/checkout') self.assertCheckoutStatusOutput('tree/checkout --verbose', tree3, verbose=True, light_checkout=False, repo_branch=branch1) # Update lightweight checkout self.build_tree(['tree/lightcheckout/a']) tree2.add('a') tree2.commit('commit one') rev = repo.get_revision(branch2.revision_history()[0]) datestring_first = format_date(rev.timestamp, rev.timezone) out, err = self.run_bzr('info tree/lightcheckout --verbose') self.assertEqualDiff( """Lightweight checkout (format: 1.6 or 1.6.1-rich-root or \ dirstate or dirstate-tags or \ pack-0.92 or rich-root or rich-root-pack) Location: light checkout root: tree/lightcheckout checkout of branch: repo/branch shared repository: repo Format: control: Meta directory format 1 working tree: Working tree format 4 branch: %s repository: %s In the working tree: 1 unchanged 0 modified 0 added 0 removed 0 renamed 0 unknown 0 ignored 0 versioned subdirectories Branch history: 1 revision 1 committer 0 days old first revision: %s latest revision: %s Repository: 1 revision """ % (format.get_branch_format().get_format_description(), format.repository_format.get_format_description(), datestring_first, datestring_first, ), out) self.assertEqual('', err) # Out of date checkout out, err = self.run_bzr('info -v tree/checkout') self.assertEqualDiff( """Checkout (format: dirstate) Location: checkout root: tree/checkout checkout of branch: repo/branch Format: control: Meta directory format 1 working tree: Working tree format 4 branch: %s repository: %s Branch is out of date: missing 1 revision. In the working tree: 0 unchanged 0 modified 0 added 0 removed 0 renamed 0 unknown 0 ignored 0 versioned subdirectories Branch history: 0 revisions 0 committers Repository: 0 revisions """ % (format.get_branch_format().get_format_description(), format.repository_format.get_format_description(), ), out) self.assertEqual('', err) # Update checkout tree3.update() self.build_tree(['tree/checkout/b']) tree3.add('b') out, err = self.run_bzr('info tree/checkout --verbose') self.assertEqualDiff( """Checkout (format: dirstate) Location: checkout root: tree/checkout checkout of branch: repo/branch Format: control: Meta directory format 1 working tree: Working tree format 4 branch: %s repository: %s In the working tree: 1 unchanged 0 modified 1 added 0 removed 0 renamed 0 unknown 0 ignored 0 versioned subdirectories Branch history: 1 revision 1 committer 0 days old first revision: %s latest revision: %s Repository: 1 revision """ % (format.get_branch_format().get_format_description(), format.repository_format.get_format_description(), datestring_first, datestring_first, ), out) self.assertEqual('', err) tree3.commit('commit two') # Out of date lightweight checkout rev = repo.get_revision(branch1.revision_history()[-1]) datestring_last = format_date(rev.timestamp, rev.timezone) out, err = self.run_bzr('info tree/lightcheckout --verbose') self.assertEqualDiff( """Lightweight checkout (format: 1.6 or 1.6.1-rich-root or \ dirstate or dirstate-tags or \ pack-0.92 or rich-root or rich-root-pack) Location: light checkout root: tree/lightcheckout checkout of branch: repo/branch shared repository: repo Format: control: Meta directory format 1 working tree: Working tree format 4 branch: %s repository: %s Working tree is out of date: missing 1 revision. In the working tree: 1 unchanged 0 modified 0 added 0 removed 0 renamed 0 unknown 0 ignored 0 versioned subdirectories Branch history: 2 revisions 1 committer 0 days old first revision: %s latest revision: %s Repository: 2 revisions """ % (format.get_branch_format().get_format_description(), format.repository_format.get_format_description(), datestring_first, datestring_last, ), out) self.assertEqual('', err) # Show info about shared branch out, err = self.run_bzr('info repo/branch --verbose') self.assertEqualDiff( """Repository branch (format: dirstate or knit) Location: shared repository: repo repository branch: repo/branch Format: control: Meta directory format 1 branch: %s repository: %s Branch history: 2 revisions 1 committer 0 days old first revision: %s latest revision: %s Repository: 2 revisions """ % (format.get_branch_format().get_format_description(), format.repository_format.get_format_description(), datestring_first, datestring_last, ), out) self.assertEqual('', err) # Show info about repository with revisions out, err = self.run_bzr('info -v repo') self.assertEqualDiff( """Shared repository (format: dirstate or dirstate-tags or knit) Location: shared repository: repo Format: control: Meta directory format 1 repository: %s Repository: 2 revisions """ % (format.repository_format.get_format_description(), ), out) self.assertEqual('', err)
def test_info_standalone(self): transport = self.get_transport() # Create initial standalone branch tree1 = self.make_branch_and_tree('standalone', 'weave') self.build_tree(['standalone/a']) tree1.add('a') branch1 = tree1.branch out, err = self.run_bzr('info standalone') self.assertEqualDiff( """Standalone tree (format: weave) Location: branch root: standalone """, out) self.assertEqual('', err) out, err = self.run_bzr('info standalone -v') self.assertEqualDiff( """Standalone tree (format: weave) Location: branch root: standalone Format: control: All-in-one format 6 working tree: Working tree format 2 branch: Branch format 4 repository: Weave repository format 6 In the working tree: 0 unchanged 0 modified 1 added 0 removed 0 renamed 0 unknown 0 ignored 0 versioned subdirectories Branch history: 0 revisions 0 committers Repository: 0 revisions """, out) self.assertEqual('', err) tree1.commit('commit one') rev = branch1.repository.get_revision(branch1.revision_history()[0]) datestring_first = format_date(rev.timestamp, rev.timezone) # Branch standalone with push location branch2 = branch1.bzrdir.sprout('branch').open_branch() branch2.set_push_location(branch1.bzrdir.root_transport.base) out, err = self.run_bzr('info branch') self.assertEqualDiff( """Standalone tree (format: weave) Location: branch root: branch Related branches: push branch: standalone parent branch: standalone """, out) self.assertEqual('', err) out, err = self.run_bzr('info branch --verbose') self.assertEqualDiff( """Standalone tree (format: weave) Location: branch root: branch Related branches: push branch: standalone parent branch: standalone Format: control: All-in-one format 6 working tree: Working tree format 2 branch: Branch format 4 repository: Weave repository format 6 In the working tree: 1 unchanged 0 modified 0 added 0 removed 0 renamed 0 unknown 0 ignored 0 versioned subdirectories Branch history: 1 revision 1 committer 0 days old first revision: %s latest revision: %s Repository: 1 revision """ % (datestring_first, datestring_first, ), out) self.assertEqual('', err) # Branch and bind to standalone, needs upgrade to metadir # (creates backup as unknown) branch1.bzrdir.sprout('bound') knit1_format = bzrdir.format_registry.make_bzrdir('knit') upgrade.upgrade('bound', knit1_format) branch3 = bzrdir.BzrDir.open('bound').open_branch() branch3.bind(branch1) bound_tree = branch3.bzrdir.open_workingtree() out, err = self.run_bzr('info -v bound') self.assertEqualDiff( """Checkout (format: knit) Location: checkout root: bound checkout of branch: standalone Related branches: parent branch: standalone Format: control: Meta directory format 1 working tree: %s branch: %s repository: %s In the working tree: 1 unchanged 0 modified 0 added 0 removed 0 renamed 1 unknown 0 ignored 0 versioned subdirectories Branch history: 1 revision 1 committer 0 days old first revision: %s latest revision: %s Repository: 1 revision """ % (bound_tree._format.get_format_description(), branch3._format.get_format_description(), branch3.repository._format.get_format_description(), datestring_first, datestring_first, ), out) self.assertEqual('', err) # Checkout standalone (same as above, but does not have parent set) branch4 = bzrdir.BzrDir.create_branch_convenience('checkout', format=knit1_format) branch4.bind(branch1) branch4.bzrdir.open_workingtree().update() out, err = self.run_bzr('info checkout --verbose') self.assertEqualDiff( """Checkout (format: knit) Location: checkout root: checkout checkout of branch: standalone Format: control: Meta directory format 1 working tree: Working tree format 3 branch: Branch format 5 repository: %s In the working tree: 1 unchanged 0 modified 0 added 0 removed 0 renamed 0 unknown 0 ignored 0 versioned subdirectories Branch history: 1 revision 1 committer 0 days old first revision: %s latest revision: %s Repository: 1 revision """ % (branch4.repository._format.get_format_description(), datestring_first, datestring_first, ), out) self.assertEqual('', err) # Lightweight checkout (same as above, different branch and repository) tree5 = branch1.create_checkout('lightcheckout', lightweight=True) branch5 = tree5.branch out, err = self.run_bzr('info -v lightcheckout') self.assertEqualDiff( """Lightweight checkout (format: 1.6 or 1.6.1-rich-root \ or dirstate or dirstate-tags or \ pack-0.92 or rich-root or rich-root-pack) Location: light checkout root: lightcheckout checkout of branch: standalone Format: control: Meta directory format 1 working tree: Working tree format 4 branch: Branch format 4 repository: Weave repository format 6 In the working tree: 1 unchanged 0 modified 0 added 0 removed 0 renamed 0 unknown 0 ignored 0 versioned subdirectories Branch history: 1 revision 1 committer 0 days old first revision: %s latest revision: %s Repository: 1 revision """ % (datestring_first, datestring_first,), out) self.assertEqual('', err) # Update initial standalone branch self.build_tree(['standalone/b']) tree1.add('b') tree1.commit('commit two') rev = branch1.repository.get_revision(branch1.revision_history()[-1]) datestring_last = format_date(rev.timestamp, rev.timezone) # Out of date branched standalone branch will not be detected out, err = self.run_bzr('info -v branch') self.assertEqualDiff( """Standalone tree (format: weave) Location: branch root: branch Related branches: push branch: standalone parent branch: standalone Format: control: All-in-one format 6 working tree: Working tree format 2 branch: Branch format 4 repository: Weave repository format 6 In the working tree: 1 unchanged 0 modified 0 added 0 removed 0 renamed 0 unknown 0 ignored 0 versioned subdirectories Branch history: 1 revision 1 committer 0 days old first revision: %s latest revision: %s Repository: 1 revision """ % (datestring_first, datestring_first, ), out) self.assertEqual('', err) # Out of date bound branch out, err = self.run_bzr('info -v bound') self.assertEqualDiff( """Checkout (format: knit) Location: checkout root: bound checkout of branch: standalone Related branches: parent branch: standalone Format: control: Meta directory format 1 working tree: Working tree format 3 branch: Branch format 5 repository: %s Branch is out of date: missing 1 revision. In the working tree: 1 unchanged 0 modified 0 added 0 removed 0 renamed 1 unknown 0 ignored 0 versioned subdirectories Branch history: 1 revision 1 committer 0 days old first revision: %s latest revision: %s Repository: 1 revision """ % (branch3.repository._format.get_format_description(), datestring_first, datestring_first, ), out) self.assertEqual('', err) # Out of date checkout out, err = self.run_bzr('info -v checkout') self.assertEqualDiff( """Checkout (format: knit) Location: checkout root: checkout checkout of branch: standalone Format: control: Meta directory format 1 working tree: Working tree format 3 branch: Branch format 5 repository: %s Branch is out of date: missing 1 revision. In the working tree: 1 unchanged 0 modified 0 added 0 removed 0 renamed 0 unknown 0 ignored 0 versioned subdirectories Branch history: 1 revision 1 committer 0 days old first revision: %s latest revision: %s Repository: 1 revision """ % (branch4.repository._format.get_format_description(), datestring_first, datestring_first, ), out) self.assertEqual('', err) # Out of date lightweight checkout out, err = self.run_bzr('info lightcheckout --verbose') self.assertEqualDiff( """Lightweight checkout (format: 1.6 or 1.6.1-rich-root or \ dirstate or dirstate-tags or \ pack-0.92 or rich-root or rich-root-pack) Location: light checkout root: lightcheckout checkout of branch: standalone Format: control: Meta directory format 1 working tree: Working tree format 4 branch: Branch format 4 repository: Weave repository format 6 Working tree is out of date: missing 1 revision. In the working tree: 1 unchanged 0 modified 0 added 0 removed 0 renamed 0 unknown 0 ignored 0 versioned subdirectories Branch history: 2 revisions 1 committer 0 days old first revision: %s latest revision: %s Repository: 2 revisions """ % (datestring_first, datestring_last,), out) self.assertEqual('', err)
def _set_revision(self, revision): if revision is None: return self.avatarsbox.reset() self._revision = revision if revision.committer is not None: self.committer.set_text(revision.committer) self.avatarsbox.add(revision.committer, "committer") else: self.committer.set_text("") self.avatarsbox.hide() author = revision.properties.get("author", "") self.avatarsbox.merge(revision.get_apparent_authors(), "author") if author != "": self.author.set_text(author) self.author.show() self.author_label.show() else: self.author.hide() self.author_label.hide() if revision.timestamp is not None: self.timestamp.set_text(format_date(revision.timestamp, revision.timezone)) try: self.branchnick.show() self.branchnick_label.show() self.branchnick.set_text(revision.properties["branch-nick"]) except KeyError: self.branchnick.hide() self.branchnick_label.hide() self._add_parents_or_children(revision.parent_ids, self.parents_widgets, self.parents_table) file_info = revision.properties.get("file-info", None) if file_info is not None: try: file_info = bdecode(file_info.encode("UTF-8")) except ValueError: trace.note("Invalid per-file info for revision:%s, value: %r", revision.revision_id, file_info) file_info = None if file_info: if self._file_id is None: text = [] for fi in file_info: text.append("%(path)s\n%(message)s" % fi) self.file_info_buffer.set_text("\n".join(text)) self.file_info_box.show() else: text = [] for fi in file_info: if fi["file_id"] == self._file_id: text.append(fi["message"]) if text: self.file_info_buffer.set_text("\n".join(text)) self.file_info_box.show() else: self.file_info_box.hide() else: self.file_info_box.hide()