Rev 422: Add a helper that computes where a given revision was merged. in http://bazaar.launchpad.net/~jameinel/loggerhead/history_db
John Arbash Meinel
john at arbash-meinel.com
Tue May 4 22:52:34 BST 2010
At http://bazaar.launchpad.net/~jameinel/loggerhead/history_db
------------------------------------------------------------
revno: 422
revision-id: john at arbash-meinel.com-20100504215224-k103otkyh9iwjikq
parent: john at arbash-meinel.com-20100504154101-sk411l8pc1dfwo6u
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: history_db
timestamp: Tue 2010-05-04 16:52:24 -0500
message:
Add a helper that computes where a given revision was merged.
This fixes a path where revision_ui was directly accessing the history private
variables.
It does require bzr-history-db/trunk >= 124.
-------------- next part --------------
=== modified file 'loggerhead/controllers/revision_ui.py'
--- a/loggerhead/controllers/revision_ui.py 2009-08-04 04:08:03 +0000
+++ b/loggerhead/controllers/revision_ui.py 2010-05-04 21:52:24 +0000
@@ -95,17 +95,7 @@
h.add_branch_nicks(change)
- if '.' in change.revno:
- # Walk "up" though the merge-sorted graph until we find a
- # revision with merge depth 0: this is the revision that merged
- # this one to mainline.
- ri = self._history._rev_info
- i = self._history._rev_indices[change.revid]
- while ri[i][0][2] > 0:
- i -= 1
- merged_in = ri[i][0][3]
- else:
- merged_in = None
+ merged_in = self._history.get_merged_in(change)
# Directory Breadcrumbs
directory_breadcrumbs = (
=== modified file 'loggerhead/history.py'
--- a/loggerhead/history.py 2010-05-04 15:41:01 +0000
+++ b/loggerhead/history.py 2010-05-04 21:52:24 +0000
@@ -351,7 +351,7 @@
# querier returns dotted revno tuples
query_revno_map = self._querier.get_dotted_revno_range_multi(
unknown)
- ghosts = set(revids)
+ ghosts = set(unknown)
for revid, dotted_revno in query_revno_map.iteritems():
revno_str = '.'.join(map(str, dotted_revno))
self._revno_revid_cache.set(revid, revno_str)
@@ -731,6 +731,21 @@
else:
return self._file_change_cache.get_file_changes(entry)
+ def get_merged_in(self, entry):
+ """Get the point where this entry was merged into the mainline.
+
+ :param entry: A Container having .revno and .revid.
+ :return: The revno string of the mainline revision.
+ """
+ if '.' not in entry.revno:
+ return None
+ rev_id_to_mainline = self._querier.get_mainline_where_merged(
+ [entry.revid])
+ revid = rev_id_to_mainline.get(entry.revid, None)
+ if revid is None:
+ return None
+ return self.get_revno(revid)
+
def add_changes(self, entry):
changes = self.get_file_changes(entry)
entry.changes = changes
More information about the bazaar-commits
mailing list