42

When working with a subdirectory in a repository, how to find the revision when that specific directory has been added to the repository? By using "svn info http://.." I can find out when it was modified for the last time ("Last Changed Rev"), but I also need to find out the revision number of the commit when that directory (or file) was added for the first time (it's "first" revision).

I have been searching for that at the "SVN book", googling, but, obviously, I got no results.

Note: I need this for making a PHP script which downloads logs and stores them locally, just to make it clear and avoid "use tortoise/svnx/versions/you_name_it application" ;)

Oliver Maksimovic
  • 3,204
  • 3
  • 28
  • 44

3 Answers3

84

You could use svn log, with a reverse revision range:

svn log -r 1:HEAD --limit 1 <REPO_URL>
bahrep
  • 29,961
  • 12
  • 103
  • 150
Christian C. Salvadó
  • 807,428
  • 183
  • 922
  • 838
2

The last entry of

svn log http://...
Mark
  • 106,305
  • 20
  • 172
  • 230
2

For someone trying to do this in pysvn:

def get_branch_creation_rev(url)
    import pysvn
    cl = pysvn.Client()
    return  pysvn.Revision(pysvn.opt_revision_kind.number,
                           cl.log(url)[-1].data.get('revision').number)
Xabs
  • 4,544
  • 3
  • 18
  • 22
  • 1
    also, if someone is looking to get the SVN author information aswell this is the command `cl.log(url)[-1].data.get('author')` – Surya Tej Jan 17 '19 at 09:20