Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to close a subversion tag-branch?

Tags:

branch

svn

tags

Tags are implemented as branches in Subversion. Thus my question: after creating a Subversion tag - how do I close this branch such that no one adds changesets to that tag-branch by accident?

For example consider following directory layout:

calc+-trunk
    |-branches
    |-tags

At some point trunk is ready for release and is tagged:

$ svn cp svn://example.net/calc/trunk svn://example.net/calc/tags/v1.0

Now following accident might happen:

$ svn co svn://example.net/calc/tags/v1.0
$ cd v1.0
$ # change files
$ svn ci

(perhaps the above URL was copy'n'pasted and instead a branch was meant)

How can I close the branch calc/tags/v1.0 such that the last svn ci would fail?

I call it closing - alternatively you could call that operation switching a branch to read-only mode - or something like that.

like image 667
maxschlepzig Avatar asked Jul 02 '13 19:07

maxschlepzig


1 Answers

You can control commits through a pre-commit hook. This one will allow you to create, but not edit tags. You can control the access to branches (preventing changes on them or keeping who can make a change to a select group of people).

I created the original copy when I realized that users could accidentally edit a tag without meaning to. I wanted a way where users could create tags, but couldn't modify a tag once it was created.

You control the hook through a control file (and that control file can even reside in the repository for easy access). The first line prevents anyone from writing to the /tags directory (or any sub directories). The second one allows users to copy a branch to a new tag, but they can't modify anything in that tag.

[FILE You cannot edit a tag once it's been created]
file = /tags/**
access = read-only
users = @ALL

[FILE You cannot edit a tag once it's been created]
file = /tags/*
access = add-only
users = @ALL

You can do the same thing in a branch. Here, the 2.2 branch is completely locked and only Bob and Carol can make changes to the 2.3 branch as it's getting ready for release:

[FILE No one is allowed to touch the 2.2 branch. It is dead]
file = /branches/2.2
access = read-only
users = @all

[FILE Only Bob and Carol can make changes to the 2.3 branch]
file = /branches/2.3/**
access = read-only
users = @ALL

[FILE Only Bob and Carol can make changes to the 2.3 branch]
file = /branches/2.3/**
access = read-write
users bob, carol
like image 117
David W. Avatar answered Oct 04 '22 11:10

David W.