Rev 3417: a little bit more cleanup, change how ghosts are handled 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 21:04:53 BST 2008
At http://bzr.arbash-meinel.com/branches/bzr/1.4-dev/find_unique_ancestors
------------------------------------------------------------
revno: 3417
revision-id: john at arbash-meinel.com-20080501200437-yfprhb36wggjq50n
parent: john at arbash-meinel.com-20080501193204-eqsmaw2t6dh2q7ul
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: find_unique_ancestors
timestamp: Thu 2008-05-01 15:04:37 -0500
message:
a little bit more cleanup, change how ghosts are handled
modified:
bzrlib/status.py status.py-20050505062338-431bfa63ec9b19e6
bzrlib/tests/test_status.py test_status.py-20060516190614-fbf6432e4a6e8aa5
-------------- next part --------------
=== modified file 'bzrlib/status.py'
--- a/bzrlib/status.py 2008-05-01 19:32:04 +0000
+++ b/bzrlib/status.py 2008-05-01 20:04:37 +0000
@@ -159,6 +159,8 @@
are considered ghosts should not be present in the map.
:return: An the iterator from MergeSorter.iter_topo_order()
"""
+ # MergeSorter requires that all nodes be present in the graph, so get rid
+ # of any references pointing outside of this graph.
parent_graph = {}
for revision_id in revision_ids:
if revision_id not in parent_map: # ghost
@@ -199,7 +201,7 @@
rev = branch.repository.get_revisions([merge])[0]
except errors.NoSuchRevision:
# If we are missing a revision, just print out the revision id
- to_file.write(first_prefix + merge + '\n')
+ to_file.write(first_prefix + '(ghost) ' + merge + '\n')
other_revisions.append(merge)
continue
@@ -211,11 +213,6 @@
# last committed revision.
merge_extra = graph.find_unique_ancestors(merge, other_revisions)
other_revisions.append(merge)
- # Now that we have the revisions, we need to sort them to get a proper
- # listing. We want to sort in reverse topological order (which
- # MergeSorter gives us). MergeSorter requires that there are no
- # dangling references, though, so clean up the graph to point to only
- # present nodes.
merge_extra.discard(_mod_revision.NULL_REVISION)
# Get a handle to all of the revisions we will need
@@ -223,21 +220,32 @@
revisions = dict((rev.revision_id, rev) for rev in
branch.repository.get_revisions(merge_extra))
except errors.NoSuchRevision:
- # If we are missing a revision, just print out the revision id
- to_file.write(first_prefix + merge + '\n')
- else:
- # Display the revisions brought in by this merge.
- rev_id_iterator = _get_sorted_revisions(merge, merge_extra,
- branch.repository.get_parent_map(merge_extra))
- # Skip the first node
- num, first, depth, eom = rev_id_iterator.next()
- if first != merge:
- raise AssertionError('Somehow we misunderstood how'
- ' iter_topo_order works %s != %s' % (first, merge))
- for num, sub_merge, depth, eom in rev_id_iterator:
- if sub_merge in ignore:
- continue
- log_message = log_formatter.log_string(None,
- revisions[sub_merge],
- term_width - len(sub_prefix))
- to_file.write(sub_prefix + log_message + '\n')
+ # One of the sub nodes is a ghost, check each one
+ revisions = {}
+ for revision_id in merge_extra:
+ try:
+ rev = branch.repository.get_revisions(merge_extra)[0]
+ except errors.NoSuchRevision:
+ revisions[revision_id] = None
+ else:
+ revisions[revision_id] = rev
+
+ # Display the revisions brought in by this merge.
+ rev_id_iterator = _get_sorted_revisions(merge, merge_extra,
+ branch.repository.get_parent_map(merge_extra))
+ # Skip the first node
+ num, first, depth, eom = rev_id_iterator.next()
+ if first != merge:
+ raise AssertionError('Somehow we misunderstood how'
+ ' iter_topo_order works %s != %s' % (first, merge))
+ for num, sub_merge, depth, eom in rev_id_iterator:
+ if sub_merge in ignore:
+ continue
+ rev = revisions[sub_merge]
+ if rev is None:
+ to_file.write(sub_prefix + '(ghost) ' + sub_merge + '\n')
+ continue
+ log_message = log_formatter.log_string(None,
+ revisions[sub_merge],
+ term_width - len(sub_prefix))
+ to_file.write(sub_prefix + log_message + '\n')
=== modified file 'bzrlib/tests/test_status.py'
--- a/bzrlib/tests/test_status.py 2008-04-30 22:18:14 +0000
+++ b/bzrlib/tests/test_status.py 2008-05-01 20:04:37 +0000
@@ -68,6 +68,36 @@
' Joe Foo 2007-12-04 commit 3c\n',
output.getvalue())
+ def test_with_pending_ghost(self):
+ """Test when a pending merge is itself a ghost"""
+ tree = self.make_branch_and_tree('a')
+ tree.commit('first')
+ tree2.add_parent_tree_id('a-ghost-revision')
+ tree.lock_read()
+ self.addCleanup(tree.unlock)
+ output = StringIO()
+ show_pending_merges(tree, output)
+ self.assertEqual('pending merges:\n'
+ ' (ghost) a-ghost-revision\n',
+ output.get_value())
+
+ def test_pending_with_ghosts(self):
+ """Test when a pending merge's ancestry includes ghosts."""
+ config.GlobalConfig().set_user_option('email', 'Joe Foo <joe at foo.com>')
+ tree = self.make_branch_and_tree('a')
+ tree.commit('empty commit')
+ tree2 = tree.bzrdir.clone('b').open_workingtree()
+ tree2.add_parent_tree_id('a-ghost-revision')
+ tree2.commit('commit with ghost', timestamp=1196796819, timezone=0)
+ tree.merge_from_branch(tree2.branch)
+ self.addCleanup(tree.unlock)
+ output = StringIO()
+ show_pending_merges(tree, output)
+ self.assertEqual('pending merges:\n'
+ ' Joe Foo 2007-12-04 commit with ghost\n',
+ ' (ghost) a-ghost-revision\n',
+ output.get_value())
+
def tests_revision_to_revision(self):
"""doing a status between two revision trees should work."""
tree = self.make_branch_and_tree('.')
More information about the bazaar-commits
mailing list