[Fwd: Re: newbie question: using bzrlib api]

James Westby jw+debian at jameswestby.net
Thu Mar 6 22:49:42 GMT 2008


Hi,

Could someone answer Rohit's questions in this mail please?

Thanks,

James

-------- Forwarded Message --------
From: Rohit Nayak <kharifcrop at gmail.com>
To: James Westby <jw+debian at jameswestby.net>
Subject: Re: newbie question: using bzrlib api
Date: Thu, 6 Mar 2008 23:26:59 +0530

Hi James,

Thanks a lot for your detailed reply. I thought I would give you some
detail on what I am trying to achieve so you could advise me.

I am building a collaboration application. I wanted to do version
control on the individual text/html documents (each is like a wiki
page: editable by people who have write access to that page). The
version control would be a bit like google docs: versioning on
auto-save. We won't be versioning as often as google docs though ...

When someone wants to view previous versions I want to show a table of
previous versions and allow them to browse through each version.
Later I will use the diff/annotate/label features as well.

So essentially I am interested only in individual file versioning:
each revision will affect only one file.

For a given file I need to get all affected revisions and the ability
to pull the version corresponding to a revision. I tried
log.find_touching_revisions(b, fileid), but for some reason the
generator seems extremely slow: several seconds for each yield.
I guess I can write my own logformatter to append to a list.

Do you think bazaar is appropriate for this kind of use where I am
versioning large number of small individual documents?

On Thu, Mar 6, 2008 at 7:28 PM, James Westby <jw+debian at jameswestby.net> wrote:
> On Thu, 2008-03-06 at 18:19 +0530, Rohit Nayak wrote:
>  > I am integrating bazaar into a python web application. This is what I
>  > am using currently to add a file:
>
>  Hi,
>
>  It doesn't sound like you are a newbie if you are already at the
>  stage of integrating it :)
>
>
>  >
>  > from bzrlib import workingtree
>  > class bzrVCS:
>  >     def __init__(self, dir):
>  >         self.wt = workingtree.WorkingTree.open(REPODIR)
>  >     def add(self, path):
>  >         fileList = [path]
>  >         self.wt.add(fileList)
>  >     def commit(self, path, label=""):
>  >         fileList = [path]
>  >         self.wt.commit(message=label, specific_files=fileList)
>  >
>  > This works fine.
>  >
>  > However I am unable to figure out what the api is to
>  >       * get the list of previous versions (and related metadata: time
>  > of commit, label)
>
>  There are two steps for this. First you get the list of revision ids.
>  You get this from a branch, rather than a tree.
>
>   branch = self.wt
>   revisions = branch.revision_history()
>
>  now revisions[0] is the first commit, and revs[-1] is the most recent.
>
>  Now to get the information you want you need a Revision object. You
>  need to ask the repository for it.
>
>   rev_id = revisions[-2]
>   repo = branch.repository
>   revision = repo.get_revision(rev_id)
>
>  Now you have revision.message, revision.timestamp, revision.timezone
>  etc.
>
>
>  >       * get the contents of one of the previous versions
>  >
>
>  This information is stored within a revision tree. Again you ask the
>  repository for this using the revision_id
>
>   tree = repo.revision_tree(rev_id)
>
>  The RevisionTree object is a little harder to use than the Revision.
>  What exactly are you looking to achieve? If you give some more detail
>  we can probably help you to do that.
>
>  A couple of things that are interesting
>
>   tree.changes_from(other_tree)
>
>  gives you a TreeDelta which you is a form of diff.
>
>  I believe list_files() and get_file_lines() will allow you to get at the
>  state of the tree in that revision.
>
>
>  > The bzr version is 1.2.0.
>  >
>  > Any help or pointers to relevant posts/docs would be appreciated!
>
>  Please ask for more information if I missed anything above.
>
>  Thanks,
>
>  James
>
>
>







More information about the bazaar mailing list