[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: get revision on which a node was added

From: C. Michael Pilato <cmpilato_at_collab.net>
Date: 2007-04-02 16:46:38 CEST

Ewout wrote:
> Hello all,
>
> Does anyone know if the svn API has a way to extract the revision
> on which a particular node was added to the repository?
>
> A pass through the header files only yielded one way: walking the
> node history until the beginning. In ruby, this would look like this
>
> hist = root.node_history(path)
> hist = hist.prev until hist.prev.nil?
> crev = hist.location.last
>
> This seems quite inefficient. Is there a more optimal way of doing this?

This is the way to answer the question, yes.

However, if you think you're going to be asking the question of many files,
there are alternate roads you can take. Some time ago, I needed (or wanted,
really) to answer a similar question, so I wrote a tool which asked
svn_fs_paths_changed() of each revision in the repository, and just made a
mapping of paths -> first_appeared_revs.

If you have a BDB repository, you can also take a sneakier route. Sort the
keys of the 'nodes' in ascending order, then find the first row of every set
of rows whose keys have a particular "node-id" component (a distinct line of
history). That key's "txn-id" component is the transaction in which that
line of history came into being. And the value for the row in the 'nodes'
table will hold the "committed-path" for the object. Now lookup the "txn-id"
in the 'transactions' table, where sits a field that holds the revision
associated with that transaction (if it was committed). Committed-path,
committed-rev, done deal.

Of course, for FSFS, life isn't so database-y.

-- 
C. Michael Pilato <cmpilato@collab.net>
CollabNet   <>   www.collab.net   <>   Distributed Development On Demand

Received on Mon Apr 2 16:46:50 2007

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.