2

I am trying to create a logical progression of svn branches where newer branches have pointers to files in the previous branch, rather than copies of those files. Once you change a file in a newer branch, it becomes disconnected from the copy in the older branch. (hence, copy-on-write) The actual files are not source code, but they are text files. I am exploring possibilities here and would like feedback on this proposed layout.

We begin with a typical subversion scenario with branches at the root level. When we create a new branch, it will begin life as a copy of the newest branch. So for example :

^/branches/1/A
^/branches/1/B

branch 1 is now in maintenance mode ; new development continues in branch 2.

svn copy ^/branches/1 ^/branches/2

yields

^/branches/2/A (a copy of ^/branches/1/A)
^/branches/2/B (a copy of ^/branches/1/B)

What I would like is, instead of having A and B be disconnected copies, to have them be pointers

^/branches/2/A -> ^/branches/1/A
^/branches/2/B -> ^/branches/1/B

Therefore, file A in branch 2 seamlessly "tracks changes" to file A in branch 1. When it becomes necessary for file A in branch 2 to differ from file A in branch 1, we "break the link", create an actual copy of the file, and go from there.

From my reading, this may be possible with svn:externals. Instead of svn copy, I would script out copying the directory structure of branch 1 into branch 2, then for each directory containing files, create an svn:externals property on the directory with URLs to the files from the previous branch.

Here are my questions/problems :

  • I want it to be impossible to make changes to branches/1/A from the svn:externals copy in branches/2/A. I believe this is only possible by pegging the svn:externals definition to a revision, which defeats the whole purpose. Is there something like svn:readonly ? (not that I could find)

  • svn:externals definitions are not recursive. In other words, ^/branches/3/A -> ^/branches/2/A (which itself points to) -> ^/branches/1/A is not possible. When there are 3 branches, 3 and 2 must both explicitly point back to branch 1.

The main thing I am trying to accomplish is that once a file is created in some branch, further branches always get changes to that file automatically. Some explicit action must be taken by the maintainers of these files in order to "break that link"

Is there a better way to set this up?

Todd Freed
  • 877
  • 6
  • 19

2 Answers2

2

This kind of copy-on-write functionality is what the FSFS database is doing underneath, but not exposed via client/server.

There is a project AutoMerger that may emulate in SVN what gerrit does for git. https://github.com/liveperson/Auto-Merger

Other SCMs that I know do this natively are StarTeam. Possibly Perforce and Mercurial can do this as well.

Electrawn
  • 2,254
  • 18
  • 24
0

In the end, I decided not to go with this approach, for the following reasons :

  • heavyweight branching - yes it can be scripted, but this requires maintenance and essentially means the script writer is in charge of creating branches

  • Reorganizing files/directories from branch to branch becomes very complicated.

  • No such thing as "recursive externals". Each copy in each successive branch has to point back to the actual file. See point number 2.

Instead, I am going with an automerging approach similar to (but not) AutoMerger.

Todd Freed
  • 877
  • 6
  • 19