Rev 3415: Pull out terminal width from the inner loop of show_pending_merges in http://bzr.arbash-meinel.com/branches/bzr/1.4-dev/find_unique_ancestors
John Arbash Meinel
john at arbash-meinel.com
Thu May 1 18:42:33 BST 2008
At http://bzr.arbash-meinel.com/branches/bzr/1.4-dev/find_unique_ancestors
------------------------------------------------------------
revno: 3415
revision-id: john at arbash-meinel.com-20080501174214-o12sdv6548vvxems
parent: john at arbash-meinel.com-20080430221814-32fn9bgqi2t5psj6
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: find_unique_ancestors
timestamp: Thu 2008-05-01 12:42:14 -0500
message:
Pull out terminal width from the inner loop of show_pending_merges
modified:
bzrlib/status.py status.py-20050505062338-431bfa63ec9b19e6
-------------- next part --------------
=== modified file 'bzrlib/status.py'
--- a/bzrlib/status.py 2008-04-25 02:48:12 +0000
+++ b/bzrlib/status.py 2008-05-01 17:42:14 +0000
@@ -148,6 +148,9 @@
def show_pending_merges(new, to_file, short=False):
"""Write out a display of pending merges in a working tree."""
+ # we need one extra space for terminals that wrap on last char
+ term_width = osutils.terminal_width() - 1
+
parents = new.get_parent_ids()
if len(parents) < 2:
return
@@ -179,13 +182,9 @@
merged_graph[next_merge] = [p for p in parent_map[next_merge]
if p in merge_extra]
sorter = tsort.MergeSorter(merged_graph, merge)
+
# Get a handle to all of the revisions we will need
- width = osutils.terminal_width()
try:
- from bzrlib.osutils import terminal_width
- width = terminal_width() - 1 # we need one extra space to avoid
- # extra blank lines
- m_revision = branch.repository.get_revision(merge)
revisions = dict((rev.revision_id, rev) for rev in
branch.repository.get_revisions(merge_extra))
except errors.NoSuchRevision:
@@ -206,7 +205,7 @@
else:
prefix = ' '
to_file.write(prefix)
- to_file.write(line_log(m_revision, width - len(prefix)))
+ to_file.write(line_log(m_revision, term_width - len(prefix)))
to_file.write('\n')
for num, mmerge, depth, eom in rev_id_iterator:
if mmerge in ignore:
@@ -217,5 +216,5 @@
else:
prefix = ' '
to_file.write(prefix)
- to_file.write(line_log(mm_revision, width - len(prefix)))
+ to_file.write(line_log(mm_revision, term_width - len(prefix)))
to_file.write('\n')
More information about the bazaar-commits
mailing list