Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tagging an SVN checkout with externals on development branches

Most of our projects use a lot of common code. We are (finally) moving towards a system where we are managing that shared code in a uniform way. We treat the shared code as a separate project in SVN, then reference it as an external. However, we tend to point the external libraries to development branches or even the trunk while the project is under development, due to the inevitable gotchas from porting the libraries from one usage to another.

As a result, we have been making mistakes when tagging files for release or internal milestones. Once in a while we will tag a project without ensuring that all the externals have been tagged first. How can we solve this problem? I'm looking for ways to reduce the possibility of a mistake or to recover/repair after making a sloppy tag like this. Ideally the solution would be a way to make SVN enforce the current policy, but I'm interested in any experience with problems like this.

like image 528
Ben Gartner Avatar asked Oct 04 '09 19:10

Ben Gartner


People also ask

How do I checkout tag in svn?

As such, to checkout a tag, you check out with your URL referencing the directory. To commit back that tag, you do a normal commit. To commit back to a different tag, you svn copy the files into the new "correct" tag directory, which you might have to mkdir ...; svn add (dir) prior to the svn copy.

How do I tag a branch in svn?

Select the folder in your working copy which you want to copy to a branch or tag, then select the command TortoiseSVN → Branch/Tag.... If you can't remember the naming convention you used last time, click the button on the right to open the repository browser so you can view the existing repository structure.

What is different between branch and tag in svn?

There is no difference between branches and tags in Subversion. The only difference is in what the user then does with the directory. Branches are typically created, edited, and then merged back into the trunk. Alternatively, tags are created as a snapshot of the project at a point in time and then never changed.

What is externals in svn?

What are externals definitions? Externals definitions map a local directory to the URL of a versioned resource. The svn:externals property can be set on any versioned directory and its value is a multi-line table of subdirectories and absolute repository URLs.


2 Answers

I would use two strategies to deal with that problem

  1. automate the tagging. Create a shell script that changes all svn:externals to a fixed revision/release tag before creating the tag on the project.
  2. have a script that checks existing tags for consistency. It's actually possible to reconstruct the state at tagging time even when you the external linked into the trunk: as you know the date and time when the tag was created, you can also find out what trunk revision was active at that point, and either modify the external to point to a specific revision of trunk, or to the release that was current at the time when the tag was made.

In addition, you can also come up with a pre-commit hook that checks whether a tag is being created, and whether all externals point to fixed revisions, rejecting the commit if this is not the case.

like image 164
Martin v. Löwis Avatar answered Sep 28 '22 07:09

Martin v. Löwis


Subversion client version 1.9 has a --pin-externals option for svn copy that looks like it will do exactly what is wanted here.

Thanks to danielsh (Daniel Shahaf) on freenode IRC channel #svn for this answer.

like image 21
Robert P. Goldman Avatar answered Sep 28 '22 07:09

Robert P. Goldman