[RFC] browsing history API

Goffredo Baroncelli kreijack at alice.it
Wed May 17 20:09:17 BST 2006

Hi all,

for my project ( a bazaar web interface[*] ) I need to browse the full 
history[**] both on the branch basis and on the file_id basis ( of a specific 
branch of course).

The first thing can be done via a


which return a list of 

	(sequence, rev_id, merge_depth, end_of_merge)

For the second case ( an history on the file_id basis ), the 
bzrlib.log._show_log( ) function perform for every revision a 
branch.get_revision_delta(revno) and check for the presence of the file_id 

In my opinion that is too expensive, and I'd propose a new API which 
calculates the revision history on the basis of weave or knit index , 
depending on whichever you use.

So I suggest to add to the class Weave and KnitVersionedFile a function like

	# knit
	def get_index_set(self):
		return self._index._cache.keys( )


	# wave
	def get_index_set(self):
		return self._names

which return a _set_ of the revision contained; then I suggest to add to the 
Branch class two functions like


def get_full_revision_history(self):
	# return the full (merged revision included) revision history of the
	# branch

	# TODO: cache the revision computed

    	h = self.revision_history( )
    	r = bzrlib.tsort.merge_sort(self.repository.get_revision_graph( ),h[-1])
    	l=list([ revid for (seq, revid, merge_depth, end_of_merge) in r ])
    	l.reverse( )
    	return l

def get_full_revision_history_by_fileid( self, file_id):
	# return the full (merged revision included) revision history of the
	# branch of the file_id involved

	# w can be a Weave or a KnitVersionedFile class
        w = self.repository.weave_store.get_weave(file_id,

        _revids = w.get_index_set( )
        h = self.get_full_revision_history()
        revids = [ ]

        for i in h:
            if i in _revids:

        return revids


These functions can improve the speed of the bzr log command; see the patch 
enclosed. Comments are welcome.


[*] http://goffredo-baroncelli.homelinux.net/bazaar
[**] for the full history I mean all the revisions with the _merged_ 
revisions; for the history I mean only the main revision without the merged 
gpg key@ keyserver.linux.it: Goffredo Baroncelli (ghigo) <kreijack at inwind.it>
Key fingerprint = CE3C 7E01 6782 30A3 5B87  87C0 BB86 505C 6B2A CFF9
-------------- next part --------------
A non-text attachment was scrubbed...
Name: diff
Type: text/x-diff
Size: 2806 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060517/b6a9661c/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060517/b6a9661c/attachment.pgp 

More information about the bazaar mailing list