Is there an API function for removing revision(s) from a repository?

John Arbash Meinel john at
Thu Dec 31 04:32:25 GMT 2009

Hash: SHA1

Neil Martinsen-Burrell wrote:
> I'm working on a plugin for easing the colocated branch workflow (a
> working tree in directory x, shared repository in x/.bzr/branches) and I
> would like to provide a command to remove a branch completely from the
> shared repository.  I can easily remove the branch from the
> .bzr/branches directory, but any new revisions that branch introduced
> will still be in the repository.  Since the tips of the branches in
> .bzr/branches are all of the active heads, it should be easy enough to
> find the union of their ancestry and then remove the revisions that are
> not in that set.  However, I can't find a method on Repository objects
> that allows for the removal of revisions.  Does such a thing exist
> currently?  If not, is such a thing possible with the data structures
> that we have?  That is, will adding such a thing be possible before 3.0
> or should I forget about it for now?
> (The only way I know of now to accomplish this is to create a new shared
> repository, branch all of the extant branches into that new repository
> and then move the new repository into place.  This is terrible for large
> projects and is O(history) like we keep trying to avoid.)
> -Neil

If you run a Packer with a specific list of revisions (that you want to
keep) and include all pack files, I think that pack action will prune
all of the unwanted revisions. It may not prune all of the inventories
and texts, but I think it could go either way there.

You could consider exposing this as part of the "Repository.pack()" api,
but I don't think that api should be 'lossy'. Instead, something like
"Repository.garbage_collect(heads)" or something like that.


Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla -


More information about the bazaar mailing list