Discussion:
How to discover which files are tagged or branced in a hook script?
Bo Berglund
2017-12-16 16:29:59 UTC
Permalink
If there is a commit to a tag operation, how can I find out which is
the tag and which files carry that tag?

I am trying to use svnlook for this on a repository converted from CVS
when investigating how to create a commit hook that will give me the
information about the files as well as the tag name.

But when I test sityh svnlook info on a revision which is the tag
commit I only see the tag as a log message comment created by cvs2svn
during conversion:

"This commit was manufactured by cvs2svn to create tag
'TagHTMLAdded3'."

When an actual tagging operation as opposed to the cvs2svn conversion
commit is done on the repository and the post_commit hook fires, how
can I know that the commit was for a tag/branch operation and which
tag/branch was involved?
And which files were tagged/branched?

I am working to adapt my CVSMailer program that sends out email to the
developer team when a change has been committed. So I need to just dig
out this information and then plug it into the existing mailer
program. (Well, maybe a bit more work, but basically that is it.)

Follow-up
---------------
I have tried various ways to get at the information but failed so far,
the best I could do is to use
svnlook changed -r <revision> <repository>
but then I have to parse the returned path looking for keyword /tags/
and grab the bit following this keyword:

D:\>C:\Programs\Subversion\svnlook changed -r 792 D:\SVN\bosse
A XMLTV/tags/Rel_XMLTV2MEI_1-0-2-56_2011-02-09/

If I use "info" I am getting the response below but than the tag name
is embedded in the log message and cannot be relied upon:

D:\>C:\Programs\Subversion\svnlook info -r 792 D:\SVN\bosse
cvs2svn
2011-07-05 09:10:25 +0200 (ti, 05 jul 2011)
91
This commit was manufactured by cvs2svn to create tag
'Rel_XMLTV2MEI_1-0-2-56_2011-02-09'.

And using "changed" is basically also non-working except for parsing a
supplied path:

D:\>C:\Programs\Subversion\svnlook changed -r 792 D:\SVN\bosse
--copy-info
A + XMLTV/tags/Rel_XMLTV2MEI_1-0-2-56_2011-02-09/
(from XMLTV/trunk/:r791)

And none of these show the *files* affected by the tagging....

So I tried to use the following command:

D:\>C:\Programs\Subversion\svnlook tree -r 792 D:\SVN\bosse --show-ids
--full-paths

But this lists ALL files in the *whole* repository, not even limiting
to the files in the module that was tagged by r792 even though the
documentation shows otherwise.

The repository is organized into modules (top level directories) as
was the CVS repository. These are each containing a separate project
non-related to the other projects except for the department managing
those projects.

When the whole *project* is tagged I want to be able to list all the
involved files even though they are not modified themselves.

How can this be accomplished? svnlook seems not to be able to do it...
--
Bo Berglund
Developer in Sweden
Branko Čibej
2017-12-17 00:22:06 UTC
Permalink
Post by Bo Berglund
If there is a commit to a tag operation, how can I find out which is
the tag and which files carry that tag?
We'll have to dispel some misconceptions. Subversion's data model is
significantly different from CVS's. Tags (and branches) are not
properties of files, they're just (sub)trees within the repository.
Creating a tag or a branch is exactly the same as copying a directory:
the only thing that happens at the repository level is that a new
version of the directory is created.
Post by Bo Berglund
I am trying to use svnlook for this on a repository converted from CVS
when investigating how to create a commit hook that will give me the
information about the files as well as the tag name.
The /path/ of the file implies which branch or tag it belongs to. There
is no other information you need.
Post by Bo Berglund
But when I test sityh svnlook info on a revision which is the tag
commit I only see the tag as a log message comment created by cvs2svn
"This commit was manufactured by cvs2svn to create tag
'TagHTMLAdded3'."
You should also see the name of the tag in the path of the file.
Post by Bo Berglund
When an actual tagging operation as opposed to the cvs2svn conversion
commit is done on the repository and the post_commit hook fires, how
can I know that the commit was for a tag/branch operation and which
tag/branch was involved?
And which files were tagged/branched?
See above; you'll see which path was created.

The structure of the repository is entirely free-form. The
trunk/branches/tags convention is exactly that: a convention, nothing
more. Of course it helps to pick a convention and stick with it.
Post by Bo Berglund
I am working to adapt my CVSMailer program that sends out email to the
developer team when a change has been committed. So I need to just dig
out this information and then plug it into the existing mailer
program. (Well, maybe a bit more work, but basically that is it.)
I'd very strongly recommend to use one of the existing Subversion mailer
scripts. There's one in the Subversion repository:

https://svn.apache.org/repos/asf/subversion/trunk/tools/hook-scripts/mailer

but there are others. You can certainly use this script to see how it
gathers commit info from the repository.

-- Brane
Bo Berglund
2017-12-17 23:35:29 UTC
Permalink
Post by Branko Čibej
We'll have to dispel some misconceptions. Subversion's data model is
significantly different from CVS's. Tags (and branches) are not
properties of files, they're just (sub)trees within the repository.
the only thing that happens at the repository level is that a new
version of the directory is created.
...
Post by Branko Čibej
The structure of the repository is entirely free-form. The
trunk/branches/tags convention is exactly that: a convention, nothing
more. Of course it helps to pick a convention and stick with it.
I have a hard time getting to understand this...
Do you mean that using "trunk", "branches" and "tags" as directories
is entirely voluntary? Does this also mean that files inside a
tags/something directory can be modified and committed, thus changing
the content of the tag?

In my CVS life there is a clear distinction between a tag and a branch
in that it is not possible to commit changes into a tag but it *is*
into a branch. So tags are immutable snapshots of the situaton at a
specific moment in time. Is this not the case in svn?
Post by Branko Čibej
I'd very strongly recommend to use one of the existing Subversion mailer
https://svn.apache.org/repos/asf/subversion/trunk/tools/hook-scripts/mailer
but there are others. You can certainly use this script to see how it
gathers commit info from the repository.
I looked at it but could not make much of it since it is in Python, a
language I am very much not familiar with. I am doing ObjectPascal
(Delphi and FreePascal) for windows and linux platforms and also C
(not C++ though) for embedded controllers...

The Python code was very hard reading for me so I will try my way
along the Pascal rouad to get a commithook mailer that replicates the
emails we got out of CVS.

More experientation has shown up how I can use "svnlook tree" properly
to extract the files in a new tag, so that part is at least covered
now.
--
Bo Berglund
Developer in Sweden
Nathan Hartman
2017-12-18 02:01:32 UTC
Permalink
Post by Bo Berglund
Post by Branko Čibej
We'll have to dispel some misconceptions. Subversion's data model is
significantly different from CVS's. Tags (and branches) are not
properties of files, they're just (sub)trees within the repository.
the only thing that happens at the repository level is that a new
version of the directory is created.
...
Post by Branko Čibej
The structure of the repository is entirely free-form. The
trunk/branches/tags convention is exactly that: a convention, nothing
more. Of course it helps to pick a convention and stick with it.
I have a hard time getting to understand this...
Do you mean that using "trunk", "branches" and "tags" as directories
is entirely voluntary? Does this also mean that files inside a
tags/something directory can be modified and committed, thus changing
the content of the tag?
In my CVS life there is a clear distinction between a tag and a branch
in that it is not possible to commit changes into a tag but it *is*
into a branch. So tags are immutable snapshots of the situaton at a
specific moment in time. Is this not the case in svn?
Yes a tag is basically a copy of a directory as it appeared at a given revision. This is a server side copy which means it does not take up any storage space. Yes this means that you can commit there which modifies the content of the tag -- however: (1) history in Subversion is immutable and therefore never lost, so the original tagged content can always be recovered, and (2) immediately after tagging you can prevent any further commits to that sub tree thus making your tag immutable, though admittedly I don't know the incantation to do that. See the svn book by C. Michael Pilato et al, sorry I am on my phone and don't have the link handy, but I recall that the chapter about tags addresses this issue. The svn book is a good resource and includes a chapter on CVS to Subversion migration which may be helpful to you. Hope this helps. :-)
Andreas Krey
2017-12-18 07:10:38 UTC
Permalink
On Mon, 18 Dec 2017 00:35:29 +0000, Bo Berglund wrote:
...
Post by Bo Berglund
I have a hard time getting to understand this...
Do you mean that using "trunk", "branches" and "tags" as directories
is entirely voluntary?
Exactly.
Post by Bo Berglund
Does this also mean that files inside a
tags/something directory can be modified and committed, thus changing
the content of the tag?
Exactly. Since svn doesn't even know the concept of a 'tag' and its
preferred writeonce property, accidentally doing an 'svn cp trunk tags/1.0'
twice has interesting consequences.

Andreas
--
"Totally trivial. Famous last words."
From: Linus Torvalds <torvalds@*.org>
Date: Fri, 22 Jan 2010 07:29:21 -0800
Andreas Krey
2017-12-18 07:16:31 UTC
Permalink
On Sun, 17 Dec 2017 01:22:06 +0000, Branko ??ibej wrote:
...
Post by Branko Čibej
The /path/ of the file implies which branch or tag it belongs to. There
is no other information you need.
Oh yes, there is. Knowing which files are included in the tag
is fine (and a very basic property), but I'd also like to be
able to find out

- which revision of the source tree the tag was taken of,

- which subtree it was taken of,

- and from the other end: which is the last tag
taken from a specific subtree.

Andreas
--
"Totally trivial. Famous last words."
From: Linus Torvalds <torvalds@*.org>
Date: Fri, 22 Jan 2010 07:29:21 -0800
Branko Čibej
2017-12-18 07:44:34 UTC
Permalink
Post by Andreas Krey
...
Post by Branko Čibej
The /path/ of the file implies which branch or tag it belongs to. There
is no other information you need.
Oh yes, there is. Knowing which files are included in the tag
is fine (and a very basic property), but I'd also like to be
able to find out
- which revision of the source tree the tag was taken of,
Recorded as the copied-from revision.
Post by Andreas Krey
- which subtree it was taken of,
Recorded as the copied-from path.
Post by Andreas Krey
- and from the other end: which is the last tag
taken from a specific subtree.
Ah, that one is not recorded.

-- Brane
Johan Corveleyn
2017-12-18 11:03:06 UTC
Permalink
Post by Branko Čibej
Post by Andreas Krey
...
Post by Branko Čibej
The /path/ of the file implies which branch or tag it belongs to. There
is no other information you need.
Oh yes, there is. Knowing which files are included in the tag
is fine (and a very basic property), but I'd also like to be
able to find out
- which revision of the source tree the tag was taken of,
Recorded as the copied-from revision.
Post by Andreas Krey
- which subtree it was taken of,
Recorded as the copied-from path.
Post by Andreas Krey
- and from the other end: which is the last tag
taken from a specific subtree.
Ah, that one is not recorded.
Indeed, that's a well known shortcoming of the way tags are currently
emulated in SVN (the emulation doesn't support looking up the list of
tags a file was ever copied to, because we have no "copy-to"
information). To support this, SVN would either have to record copy-to
information, or add a new tag feature / concept.

I just browsed to some old Subversion notes, and found this particular
issue mentioned in the notes of "EuroOSCON 2005" [1]. Time flies :-)
...

For making the /tags directory "write-once", most installations use
some pre-commit hook. I've been using a variation of David Weintraub's
excellent pre-commit-access-control-hook.pl [2]. Here you can give
/tags the "add-only" permission (configured in some ini file). I've
googled around a bit, and David has continued his set of Subversion
hook scripts on GitHub [3], so there you can find a newer version of
those scripts.

[1] The bullet starting with 'Subversion has no way to answer "What
branches/tags is this version of this file present in?"' in
http://svn.apache.org/repos/asf/subversion/trunk/notes/EuroOSCON-2005-vc-bof.txt

[2] https://svn.haxx.se/users/archive-2006-11/0564.shtml

[3] https://github.com/qazwart/SVN-Precommit-Kitchen-Sink-Hook
And his SVN-Watcher hook: https://github.com/qazwart/SVN-Watcher-Hook
--
Johan
Loading...