I've been modifying an existing program which always exports the head revision, but I would like it to be more flexible and checkout any revision based on a date/time.
With SVN cli directly this would be no problem, I would run something like: svn log -r {start date}:{end date} --xml
and I can simply set these values to a range guaranteed to return a reasonable number of values and iterate the results to find the largest revision. However pysvn's log, export and info/info2 functions all use a revision as input, which is not something the user's of this tool will know or even be aware of.
My question is, with pysvn is it possible to either directly perform an export based on a date or is it possible to at least determine the last revision committed up to a supplied date (preferably without fetching a log of the entire commit history)?
The trick is to use a date revision in the call to export.
Here are is the extract from the reference docs that are on: http://pysvn.tigris.org/docs/pysvn_prog_ref.html#pysvn_revision
pysvn.Revision - subversion revision
The Revision object has three member variables:
kind - the kind of revision, its value is one of the opt_revision_kind enumerations.
date - date and time when kind is opt_revision_kind.date, as seconds since the epoch which is compatible with python's time module.
number - revision number when kind is opt_revision_kind.number
Interface summary:
import pysvn
import time
revhead = pysvn.Revision( pysvn.opt_revision_kind.head )
revdate = pysvn.Revision( pysvn.opt_revision_kind.date, time.time() )
revnum = pysvn.Revision( pysvn.opt_revision_kind.number, 4721 )