How to discover which files are tagged or branced in a hook script?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

How to discover which files are tagged or branced in a hook script?

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?

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

Reply | Threaded
Open this post in threaded view
|

Re: How to discover which files are tagged or branced in a hook script?

Branko Čibej
On 16.12.2017 17:29, Bo Berglund wrote:
> 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.

> 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.

> 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'."

You should also see the name of the tag in the path of the file.


> 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.


> 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

Reply | Threaded
Open this post in threaded view
|

Re: How to discover which files are tagged or branced in a hook script?

Bo Berglund
On Sun, 17 Dec 2017 01:22:06 +0100, Branko ?ibej <[hidden email]>
wrote:

>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.
...

>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?

>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.

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

Reply | Threaded
Open this post in threaded view
|

Re: How to discover which files are tagged or branced in a hook script?

Nathan Hartman
On Dec 17, 2017, at 6:35 PM, Bo Berglund <[hidden email]> wrote:

>
> On Sun, 17 Dec 2017 01:22:06 +0100, Branko ?ibej <[hidden email]>
> wrote:
>
>> 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.
> ...
>
>> 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. :-)

Reply | Threaded
Open this post in threaded view
|

Re: How to discover which files are tagged or branced in a hook script?

Andreas Krey
In reply to this post by Bo Berglund
On Mon, 18 Dec 2017 00:35:29 +0000, Bo Berglund wrote:
...
> I have a hard time getting to understand this...
> Do you mean that using "trunk", "branches" and "tags" as directories
> is entirely voluntary?

Exactly.

> 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
Reply | Threaded
Open this post in threaded view
|

Re: How to discover which files are tagged or branced in a hook script?

Andreas Krey
In reply to this post by Branko Čibej
On Sun, 17 Dec 2017 01:22:06 +0000, Branko ??ibej wrote:
...
> 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
Reply | Threaded
Open this post in threaded view
|

Re: How to discover which files are tagged or branced in a hook script?

Branko Čibej
On 18.12.2017 08:16, Andreas Krey wrote:
> On Sun, 17 Dec 2017 01:22:06 +0000, Branko ??ibej wrote:
> ...
>> 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.

> - which subtree it was taken of,

Recorded as the copied-from path.

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

Ah, that one is not recorded.

-- Brane
Reply | Threaded
Open this post in threaded view
|

Re: How to discover which files are tagged or branced in a hook script?

Johan Corveleyn-3
On Mon, Dec 18, 2017 at 8:44 AM, Branko Čibej <[hidden email]> wrote:

> On 18.12.2017 08:16, Andreas Krey wrote:
>> On Sun, 17 Dec 2017 01:22:06 +0000, Branko ??ibej wrote:
>> ...
>>> 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.
>
>> - which subtree it was taken of,
>
> Recorded as the copied-from path.
>
>> - 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