Merge lp:~rockstar/loggerhead/revnocache into lp:loggerhead

Proposed by Paul Hummer
Status: Rejected
Rejected by: Paul Hummer
Proposed branch: lp:~rockstar/loggerhead/revnocache
Merge into: lp:loggerhead
Diff against target: None lines
To merge this branch: bzr merge lp:~rockstar/loggerhead/revnocache
Reviewer Review Type Date Requested Status
Michael Hudson-Doyle Needs Resubmitting
Review via email: mp+5377@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Paul Hummer (rockstar) wrote :

This branch adds a MergeGraphCache from the bzr-revnocache plugin. This
allowed me to remove two of the whole history cache stuff. Something that I
had to do was convert all internal references to a revno to tuples. All the
tests pass now.

As the reviewer, please check that my implementation is sane. I'm sure there
will be MANY comments and changes I need to make, and I welcome them.

 reviewer mwhudson

Cheers,
Paul

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Hm, I think this branch may be guilty of trying to do too many things at once. I think there are two separate tasks: (1) use revnocache to make accessing the merge sorted revision graph more efficient (2) reducing the use of whole-history data in history.py. This sort of tries to do both :/

Also, it makes loggerhead hard-depend on revnocache being installed, which isn't great. So, sorry, I think we'll have to try again here... and I'm going on leave for a week so we don't really have a chance to talk about what would be better. Oops.

review: Needs Resubmitting

Unmerged revisions

338. By Paul Hummer

Removed unneeded code

337. By Paul Hummer

Fixed the last test

336. By Paul Hummer

Only one failing test now

335. By Paul Hummer

Fixed a bug in fix_revid

334. By Paul Hummer

Added converters for dotted revnos

333. By Paul Hummer

Fixed a bug in file views

332. By Paul Hummer

Eliminated the need for revgraphcache

331. By Paul Hummer

Added call to clear()

330. By Paul Hummer

Added hack to regenerate cache

329. By Paul Hummer

Removed pdb call

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'loggerhead/history.py'
2--- loggerhead/history.py 2009-03-19 20:04:24 +0000
3+++ loggerhead/history.py 2009-04-08 21:05:38 +0000
4@@ -42,11 +42,19 @@
5 from loggerhead import util
6 from loggerhead.wholehistory import compute_whole_history_data
7
8+from bzrlib.plugin import load_plugins
9+
10+load_plugins()
11+
12 import bzrlib
13 import bzrlib.branch
14 import bzrlib.delta
15 import bzrlib.diff
16 import bzrlib.errors
17+from bzrlib.plugins.revnocache import _branch_iter_merge_graph
18+from bzrlib.plugins.revnocache.mergegraphcache import MergeGraphCache
19+from bzrlib.plugins.revnocache.revnocache import RevnoCache
20+from bzrlib.plugins.revnocache.revgraphcache import RevGraphCache
21 import bzrlib.progress
22 import bzrlib.revision
23 import bzrlib.textfile
24@@ -177,6 +185,16 @@
25 file_id=file_id))
26
27
28+def make_mergegraphcache(branch):
29+ '''Make the mergegraphcache data structure for writing to the cache.'''
30+ return _branch_iter_merge_graph(branch)
31+
32+
33+def convert_revnostr_to_tuple(revno):
34+ '''Convert a revnostr (dotted or not) to its tuple form.'''
35+ return tuple([int(i) for i in revno.split('.')])
36+
37+
38 class History (object):
39 """Decorate a branch to provide information for rendering.
40
41@@ -199,18 +217,40 @@
42
43 self.last_revid = branch.last_revision()
44
45+ self.mergegraphcache = MergeGraphCache(branch=self._branch)
46+ if not self.mergegraphcache.exists():
47+ self.mergegraphcache.write(make_mergegraphcache(self._branch))
48+ else:
49+ revision = self.get_mergegraph_rev(revid=self.last_revid)
50+ if not revision:
51+ self.mergegraphcache.clear()
52+ self.mergegraphcache.write(make_mergegraphcache(self._branch))
53+
54 whole_history_data = whole_history_data_cache.get(self.last_revid)
55 if whole_history_data is None:
56 whole_history_data = compute_whole_history_data(branch)
57 whole_history_data_cache[self.last_revid] = whole_history_data
58
59- (self._revision_graph, self._full_history, self._revision_info,
60- self._revno_revid, self._merge_sort, self._where_merged,
61- ) = whole_history_data
62+ (self._revision_graph, self._full_history, self._merge_sort,
63+ self._where_merged) = whole_history_data
64
65 def use_file_cache(self, cache):
66 self._file_change_cache = cache
67
68+ def get_mergegraph_rev(self, revid=None, revno=None):
69+ '''Return the merge graph cache record for a given revid.'''
70+ if revid:
71+ for revision in self.mergegraphcache.iter():
72+ if revision[1] == revid:
73+ return revision
74+ if revno:
75+ if type(revno) == str:
76+ revno = convert_revnostr_to_tuple(revno)
77+ for revision in self.mergegraphcache.iter():
78+ if revision[3] == revno:
79+ return revision
80+ return None
81+
82 @property
83 def has_revisions(self):
84 return not bzrlib.revision.is_null(self.last_revid)
85@@ -219,12 +259,13 @@
86 return self._branch.get_config()
87
88 def get_revno(self, revid):
89- if revid not in self._revision_info:
90+ try:
91+ revno_str = '.'.join(
92+ [str(i) for i in self.get_mergegraph_rev(revid=revid)[3]])
93+ return revno_str
94+ except TypeError:
95 # ghost parent?
96 return 'unknown'
97- (seq, revid, merge_depth,
98- revno_str, end_of_merge) = self._revision_info[revid]
99- return revno_str
100
101 def get_revids_from(self, revid_list, start_revid):
102 """
103@@ -238,7 +279,8 @@
104
105 def introduced_revisions(revid):
106 r = set([revid])
107- seq, revid, md, revno, end_of_merge = self._revision_info[revid]
108+ seq, revid, md, revno, end_of_merge = self.get_mergegraph_rev(
109+ revid=revid)
110 i = seq + 1
111 while i < len(self._merge_sort) and self._merge_sort[i][2] > md:
112 r.add(self._merge_sort[i][1])
113@@ -358,11 +400,12 @@
114 return revid
115 if revid == 'head:':
116 return self.last_revid
117- try:
118- if self.revno_re.match(revid):
119- revid = self._revno_revid[revid]
120- except KeyError:
121- raise bzrlib.errors.NoSuchRevision(self._branch_nick, revid)
122+ if self.revno_re.match(revid):
123+ revno = convert_revnostr_to_tuple(revid)
124+ try:
125+ return self.get_mergegraph_rev(revno=revno)[1]
126+ except TypeError:
127+ raise bzrlib.errors.NoSuchRevision(self._branch_nick, revid)
128 return revid
129
130 def get_file_view(self, revid, file_id):
131
132=== modified file 'loggerhead/wholehistory.py'
133--- loggerhead/wholehistory.py 2008-12-05 20:09:14 +0000
134+++ loggerhead/wholehistory.py 2009-04-08 06:03:22 +0000
135@@ -75,5 +75,4 @@
136
137 log.info('built revision graph cache: %r secs' % (time.time() - z))
138
139- return (_revision_graph, _full_history, _revision_info,
140- _revno_revid, _merge_sort, _where_merged)
141+ return (_revision_graph, _full_history, _merge_sort, _where_merged)

Subscribers

People subscribed via source and target branches