Jul 282021
 

I was asked: Why does FreshPorts have links to both git and subversion repos?

The short answer is: because at the time, the commits were committed to those respective repos. The links to the other repo do not exist.

FreeBSD moved from using subversion to git.

During the transition, the subversion repo became read-only. All the commits before that date, point to the subversion repo. All the commits after that date, point to the git repo. In the code, there is more to it than a date, but that’s the basic generalization.

Take, for example, my port sysutils/anvil, all the commit before 06 Apr 2021 have a link to the git repo (https://cgit.freebsd.org/ports/), and all the commits before that, have a link to the subversion repo (https://svnweb.freebsd.org/ports/).

There is no need to change, from what I can see. However, there may be a way to link all older commits to git.

For example, can a link such as https://svnweb.freebsd.org/ports?view=revision&revision=554836 be easily converted into a link to the git repo?

Short answer: no.

Long answer: maybe.

From a discussion on #gitcvt:

[Jul 27 10:25] <@dvl> How can I locate svn revisions in git? e.g. 563183 -> https://svnweb.freebsd.org/ports?view=revision&revision=563183
[Jul 27 10:26] <@dvl> I’m hoping for a https://cgit.freebsd.org/ports/commit/?id= type URL
[Jul 27 10:28] <@dvl> See examples at https://www.freshports.org/x11-fonts/jetbrains-mono/#history

[Jul 27 15:44] <fbsdslack> <imp> dvl: find an answer yet?
[Jul 27 15:44] <fbsdslack> <imp> I have a git command recipe
[Jul 27 15:45] <fbsdslack> <imp> is that of interest?

[Jul 27 16:54] <fbsdslack> <imp> % git clone -o freebsd –config remote.freebsd.fetch=‘+refs/notes/*:refs/notes/*’ https://git.freebsd.org/${repo}.git
[Jul 27 16:55] <fbsdslack> <imp> grabs the notes, and then you can use –grep ‘revision=563183’
[Jul 27 16:55] <fbsdslack> <imp> with git log to find the commit.
[Jul 27 16:56] <fbsdslack> <imp> Details are in the committer’s guide in “Finding the Subversion Revision” section (there’s no anchor for this)
[Jul 27 16:56] <fbsdslack> <imp> % git config –add remote.freebsd.fetch “+refs/notes/*:refs/notes/*”
[Jul 27 16:57] <fbsdslack> <imp> may be needed if you already have a free (assuming your origin is ‘freebsd’)

In addition, there may be a way to redirect from subversion to git, based on the revision number.

[Jul 27 15:48] <@lwhsu> dvl: I’m thinking to generate a map file from svn revision to git hash, and use that file to send http redirection to cgit.f.o on svnweb.f.o
[Jul 27 15:49] <@lwhsu> to generate the map file, I think use the git note in each repository is a way.

My reading of the above: I can’t just provide a subversion revision number and create a link with that. I could run a one-off script, using the notes, and find a link for all the subversion commits.

For now, I’d rather not do that, given that the subversion repo is still online. Eventually, though, as imp pointed out: For FreshPorts, you can run a relatively simple script to scrape all that once and then have it forever because the mappings at this point will never change and there will be no new svn r numbers in the ports tree.

Website Pin Facebook Twitter Myspace Friendfeed Technorati del.icio.us Digg Google StumbleUpon Premium Responsive