43

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" ;)

0

3 Answers 3

86

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

svn log -r 1:HEAD --limit 1 <REPO_URL>
4
  • Don't forget to accept the answer if you are satisfied with it :) Commented Oct 27, 2009 at 21:09
  • Just did it. I'm new guy at the hood, I am still getting familiar :) Commented Oct 27, 2009 at 21:47
  • 7
    Only works if HEAD contains that file. If the file was deleted, this will fail
    – Viet
    Commented Jul 21, 2011 at 3:31
  • When you want first revision in given branch use option: --stop-on-copy Commented Apr 28, 2017 at 8:40
2

The last entry of

svn log http://...
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)
1
  • 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
    Commented Jan 17, 2019 at 9:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.