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

Re: Fork and merge individual files

From: Ryan Schmidt <subversion-2012c_at_ryandesign.com>
Date: Tue, 17 Dec 2013 21:49:13 -0600

On Dec 17, 2013, at 13:56, Zé wrote:

> Does subversion provide a way to fork and merge individual files stored in various points within a repository? If it does, can anyone provide a small example showcasing this feature?

Subversion does not have a “fork” command but it does have a “copy” command, and yes you can copy individual files (or entire directories) from any point in the repository’s history.

For example, if you have a working copy of the MacPorts portfiles collection:

$ svn checkout https://svn.macports.org/repository/macports/trunk/dports
$ cd dports

The libpng portfile is currently at version 1.5.x but let’s say for whatever reason you wanted to make a new portfile for the old 1.2.x version. Using:

$ svn log graphics/libpng —limit 30

I discovered that the last revision when that portfile used version 1.2.x was r71090. So as a first step of making a new libpng12 portfile I could:

$ svn copy graphics/libpng_at_71090 graphics/libpng12

Now there’s a new directory graphics/libpng12 containing what graphics/libpng contained back in r71090 three years ago. Then I would edit the files in graphics/libpng12 further and test them before committing them.

My example shows copying an old directory, but if you wanted to copy only a single file you could do it the same way.

My example could be described as “forking” an old version, but I didn’t show merging. I suppose if I had made a change to libpng and wanted to merge it back to libpng12 I could do that, in the usual way, assuming the files weren’t too different from one another. If they were very different, I could still merge, but might encounter a conflict, which I would then have to resolve. Often in MacPorts, since individual changes to our portfiles are fairly small, I just make the same change manually to each portfile that needs it and commit them, often together in the same commit, rather than bother with merging.
Received on 2013-12-18 04:50:05 CET

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

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