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
=== modified file 'loggerhead/history.py'
--- loggerhead/history.py 2009-03-19 20:04:24 +0000
+++ loggerhead/history.py 2009-04-08 21:05:38 +0000
@@ -42,11 +42,19 @@
42from loggerhead import util42from loggerhead import util
43from loggerhead.wholehistory import compute_whole_history_data43from loggerhead.wholehistory import compute_whole_history_data
4444
45from bzrlib.plugin import load_plugins
46
47load_plugins()
48
45import bzrlib49import bzrlib
46import bzrlib.branch50import bzrlib.branch
47import bzrlib.delta51import bzrlib.delta
48import bzrlib.diff52import bzrlib.diff
49import bzrlib.errors53import bzrlib.errors
54from bzrlib.plugins.revnocache import _branch_iter_merge_graph
55from bzrlib.plugins.revnocache.mergegraphcache import MergeGraphCache
56from bzrlib.plugins.revnocache.revnocache import RevnoCache
57from bzrlib.plugins.revnocache.revgraphcache import RevGraphCache
50import bzrlib.progress58import bzrlib.progress
51import bzrlib.revision59import bzrlib.revision
52import bzrlib.textfile60import bzrlib.textfile
@@ -177,6 +185,16 @@
177 file_id=file_id))185 file_id=file_id))
178186
179187
188def make_mergegraphcache(branch):
189 '''Make the mergegraphcache data structure for writing to the cache.'''
190 return _branch_iter_merge_graph(branch)
191
192
193def convert_revnostr_to_tuple(revno):
194 '''Convert a revnostr (dotted or not) to its tuple form.'''
195 return tuple([int(i) for i in revno.split('.')])
196
197
180class History (object):198class History (object):
181 """Decorate a branch to provide information for rendering.199 """Decorate a branch to provide information for rendering.
182200
@@ -199,18 +217,40 @@
199217
200 self.last_revid = branch.last_revision()218 self.last_revid = branch.last_revision()
201219
220 self.mergegraphcache = MergeGraphCache(branch=self._branch)
221 if not self.mergegraphcache.exists():
222 self.mergegraphcache.write(make_mergegraphcache(self._branch))
223 else:
224 revision = self.get_mergegraph_rev(revid=self.last_revid)
225 if not revision:
226 self.mergegraphcache.clear()
227 self.mergegraphcache.write(make_mergegraphcache(self._branch))
228
202 whole_history_data = whole_history_data_cache.get(self.last_revid)229 whole_history_data = whole_history_data_cache.get(self.last_revid)
203 if whole_history_data is None:230 if whole_history_data is None:
204 whole_history_data = compute_whole_history_data(branch)231 whole_history_data = compute_whole_history_data(branch)
205 whole_history_data_cache[self.last_revid] = whole_history_data232 whole_history_data_cache[self.last_revid] = whole_history_data
206233
207 (self._revision_graph, self._full_history, self._revision_info,234 (self._revision_graph, self._full_history, self._merge_sort,
208 self._revno_revid, self._merge_sort, self._where_merged,235 self._where_merged) = whole_history_data
209 ) = whole_history_data
210236
211 def use_file_cache(self, cache):237 def use_file_cache(self, cache):
212 self._file_change_cache = cache238 self._file_change_cache = cache
213239
240 def get_mergegraph_rev(self, revid=None, revno=None):
241 '''Return the merge graph cache record for a given revid.'''
242 if revid:
243 for revision in self.mergegraphcache.iter():
244 if revision[1] == revid:
245 return revision
246 if revno:
247 if type(revno) == str:
248 revno = convert_revnostr_to_tuple(revno)
249 for revision in self.mergegraphcache.iter():
250 if revision[3] == revno:
251 return revision
252 return None
253
214 @property254 @property
215 def has_revisions(self):255 def has_revisions(self):
216 return not bzrlib.revision.is_null(self.last_revid)256 return not bzrlib.revision.is_null(self.last_revid)
@@ -219,12 +259,13 @@
219 return self._branch.get_config()259 return self._branch.get_config()
220260
221 def get_revno(self, revid):261 def get_revno(self, revid):
222 if revid not in self._revision_info:262 try:
263 revno_str = '.'.join(
264 [str(i) for i in self.get_mergegraph_rev(revid=revid)[3]])
265 return revno_str
266 except TypeError:
223 # ghost parent?267 # ghost parent?
224 return 'unknown'268 return 'unknown'
225 (seq, revid, merge_depth,
226 revno_str, end_of_merge) = self._revision_info[revid]
227 return revno_str
228269
229 def get_revids_from(self, revid_list, start_revid):270 def get_revids_from(self, revid_list, start_revid):
230 """271 """
@@ -238,7 +279,8 @@
238279
239 def introduced_revisions(revid):280 def introduced_revisions(revid):
240 r = set([revid])281 r = set([revid])
241 seq, revid, md, revno, end_of_merge = self._revision_info[revid]282 seq, revid, md, revno, end_of_merge = self.get_mergegraph_rev(
283 revid=revid)
242 i = seq + 1284 i = seq + 1
243 while i < len(self._merge_sort) and self._merge_sort[i][2] > md:285 while i < len(self._merge_sort) and self._merge_sort[i][2] > md:
244 r.add(self._merge_sort[i][1])286 r.add(self._merge_sort[i][1])
@@ -358,11 +400,12 @@
358 return revid400 return revid
359 if revid == 'head:':401 if revid == 'head:':
360 return self.last_revid402 return self.last_revid
361 try:403 if self.revno_re.match(revid):
362 if self.revno_re.match(revid):404 revno = convert_revnostr_to_tuple(revid)
363 revid = self._revno_revid[revid]405 try:
364 except KeyError:406 return self.get_mergegraph_rev(revno=revno)[1]
365 raise bzrlib.errors.NoSuchRevision(self._branch_nick, revid)407 except TypeError:
408 raise bzrlib.errors.NoSuchRevision(self._branch_nick, revid)
366 return revid409 return revid
367410
368 def get_file_view(self, revid, file_id):411 def get_file_view(self, revid, file_id):
369412
=== modified file 'loggerhead/wholehistory.py'
--- loggerhead/wholehistory.py 2008-12-05 20:09:14 +0000
+++ loggerhead/wholehistory.py 2009-04-08 06:03:22 +0000
@@ -75,5 +75,4 @@
7575
76 log.info('built revision graph cache: %r secs' % (time.time() - z))76 log.info('built revision graph cache: %r secs' % (time.time() - z))
7777
78 return (_revision_graph, _full_history, _revision_info,78 return (_revision_graph, _full_history, _merge_sort, _where_merged)
79 _revno_revid, _merge_sort, _where_merged)

Subscribers

People subscribed via source and target branches