Discussion:
How to see when an item was added using svnlook?
Bo Berglund
2018-01-01 20:28:26 UTC
Permalink
I am trying to use svnlook to find the revision when a directory was
created. I want to use this to dig out the timestamps of tags and
branches. My svn version is 1.9.7 (both server and client).

So far I have not found a way to do it...

svnlook history <repo> <project>/branches/<branchdir>
shows a lot of revisions which are for changes to any file within the
directory, but not the addition commit for the actual directory itself
AND unrelated directories (the command below is on one line):

D:\>svnlook history D:\SVN\test\bosse
/CVSMailer/branches/Branch_Rel_1-2-9 -l 5
REVISION PATH
-------- ----
120 /CVSMailer/branches/Branch_Rel_1-2-9
119 /CVSMailer/branches/Branch_Rel_1-2-9
103 /CVSMailer/branches/Branch_Rel_1-2-9
100 /CVSMailer/trunk
98 /CVSMailer/trunk
... and the list continues in *trunk* for about 50 lines ...


Is there a command to show the revision when an item (directory or
file) was actually created in svn?

I have read the whole SVNBook 1.7 chapter on svnlook but did not find
an obvious candidate.

If I know the revision I can get additional information using svnlook:

D:\>svnlook info -r 699 D:\SVN\test\bosse
cvs2svn
2006-04-22 23:17:29 +0200 (lö, 22 apr 2006)
79
This commit was manufactured by cvs2svn to create tag
'Rel_1-5-2-50_20060422'.

D:\>svnlook changed -r 699 D:\SVN\test\bosse --copy-info
A + CVSMailer/tags/Rel_1-5-2-50_20060422/
(from CVSMailer/trunk/:r698)

But lacking the revision number when it was added I cannot find the
extra info like the date...
--
Bo Berglund
Developer in Sweden
Branko Čibej
2018-01-02 08:42:07 UTC
Permalink
Post by Bo Berglund
I am trying to use svnlook to find the revision when a directory was
created. I want to use this to dig out the timestamps of tags and
branches. My svn version is 1.9.7 (both server and client).
So far I have not found a way to do it...
svnlook history <repo> <project>/branches/<branchdir>
shows a lot of revisions which are for changes to any file within the
directory, but not the addition commit for the actual directory itself
The directories are not unrelated.
Post by Bo Berglund
D:\>svnlook history D:\SVN\test\bosse
/CVSMailer/branches/Branch_Rel_1-2-9 -l 5
REVISION PATH
-------- ----
120 /CVSMailer/branches/Branch_Rel_1-2-9
119 /CVSMailer/branches/Branch_Rel_1-2-9
103 /CVSMailer/branches/Branch_Rel_1-2-9
100 /CVSMailer/trunk
98 /CVSMailer/trunk
... and the list continues in *trunk* for about 50 lines ...
Yes, that is correct. You asked for the history of the item; it was
copied (branched) from trunk in r103, and svnlook is showing the whole
history.
Post by Bo Berglund
Is there a command to show the revision when an item (directory or
file) was actually created in svn?
Currently the only hack to do this is by using 'svn log --stop-on-copy'
in a working copy.
Post by Bo Berglund
I have read the whole SVNBook 1.7 chapter on svnlook but did not find
an obvious candidate.
D:\>svnlook info -r 699 D:\SVN\test\bosse
cvs2svn
2006-04-22 23:17:29 +0200 (lö, 22 apr 2006)
79
This commit was manufactured by cvs2svn to create tag
'Rel_1-5-2-50_20060422'.
D:\>svnlook changed -r 699 D:\SVN\test\bosse --copy-info
A + CVSMailer/tags/Rel_1-5-2-50_20060422/
(from CVSMailer/trunk/:r698)
But lacking the revision number when it was added I cannot find the
extra info like the date...
"The date" is a revision property.

What are you actually trying to achieve? There's a good chance that
whatever you're trying to use svnlook for has already been implemented
half a dozen times, using an existing tool might get you to your goal
quite a bit faster.

-- Brane
Daniel Shahaf
2018-01-02 09:59:15 UTC
Permalink
Post by Branko Čibej
Post by Bo Berglund
Is there a command to show the revision when an item (directory or
file) was actually created in svn?
Currently the only hack to do this is by using 'svn log --stop-on-copy'
in a working copy.
Wouldn't 'svn log --stop-on-copy URL' work?

There's also this (not immediately obvious) command for showing the
revision that created TARGET at that location, via a copy or otherwise:

svn log -r 0:HEAD -q -v --stop-on-copy --limit=1 -- TARGET
Branko Čibej
2018-01-02 10:37:49 UTC
Permalink
Post by Daniel Shahaf
Post by Branko Čibej
Post by Bo Berglund
Is there a command to show the revision when an item (directory or
file) was actually created in svn?
Currently the only hack to do this is by using 'svn log --stop-on-copy'
in a working copy.
Wouldn't 'svn log --stop-on-copy URL' work?
It would ... I just didn't want to confuse the issue by introducing the
not-so-subtle difference between the "client" and the "working copy."
Post by Daniel Shahaf
There's also this (not immediately obvious) command for showing the
svn log -r 0:HEAD -q -v --stop-on-copy --limit=1 -- TARGET
Indeed, that's a better hack.

-- Brane
Bo Berglund
2018-01-02 12:29:40 UTC
Permalink
On Tue, 02 Jan 2018 09:59:15 +0000, Daniel Shahaf
Post by Daniel Shahaf
Post by Branko Čibej
Post by Bo Berglund
Is there a command to show the revision when an item (directory or
file) was actually created in svn?
Currently the only hack to do this is by using 'svn log --stop-on-copy'
in a working copy.
Wouldn't 'svn log --stop-on-copy URL' work?
There's also this (not immediately obvious) command for showing the
svn log -r 0:HEAD -q -v --stop-on-copy --limit=1 -- TARGET
I believe this only works in a working copy, not on the server in a
hook...
--
Bo Berglund
Developer in Sweden
Johan Corveleyn
2018-01-02 12:42:52 UTC
Permalink
Post by Bo Berglund
On Tue, 02 Jan 2018 09:59:15 +0000, Daniel Shahaf
Post by Daniel Shahaf
Post by Branko Čibej
Post by Bo Berglund
Is there a command to show the revision when an item (directory or
file) was actually created in svn?
Currently the only hack to do this is by using 'svn log --stop-on-copy'
in a working copy.
Wouldn't 'svn log --stop-on-copy URL' work?
There's also this (not immediately obvious) command for showing the
svn log -r 0:HEAD -q -v --stop-on-copy --limit=1 -- TARGET
I believe this only works in a working copy, not on the server in a
hook...
As Daniel suggested, this also works with a URL as target. You don't
need a working copy. It's fine to run 'svn' with a URL from within a
hook:

svn log -r 0:HEAD -q -v --stop-on-copy --limit=1 -- $URL_TO_BRANCH

Some svn admins only try to limit their hooks to svnlook, but at some
point that falls short of what you need to do ('svn' is often more
powerful). I see no problem using the 'svn' executable.
--
Johan
Johan Corveleyn
2018-01-02 12:46:25 UTC
Permalink
Post by Johan Corveleyn
Post by Bo Berglund
On Tue, 02 Jan 2018 09:59:15 +0000, Daniel Shahaf
Post by Daniel Shahaf
Post by Branko Čibej
Post by Bo Berglund
Is there a command to show the revision when an item (directory or
file) was actually created in svn?
Currently the only hack to do this is by using 'svn log --stop-on-copy'
in a working copy.
Wouldn't 'svn log --stop-on-copy URL' work?
There's also this (not immediately obvious) command for showing the
svn log -r 0:HEAD -q -v --stop-on-copy --limit=1 -- TARGET
I believe this only works in a working copy, not on the server in a
hook...
As Daniel suggested, this also works with a URL as target. You don't
need a working copy. It's fine to run 'svn' with a URL from within a
svn log -r 0:HEAD -q -v --stop-on-copy --limit=1 -- $URL_TO_BRANCH
Some svn admins only try to limit their hooks to svnlook, but at some
point that falls short of what you need to do ('svn' is often more
powerful). I see no problem using the 'svn' executable.
Forgot to add: an important difference, of course, is that 'svn' can
only be used to inspect revisions that have already been committed
(like from a post-commit hook, or from tools that run in a cron job
and inspect committed revisions). If you want to inspect an
uncommitted transaction, as you would do in the pre-commit hook, then
you have no alternative, you have to use svnlook.
--
Johan
Branko Čibej
2018-01-02 12:49:35 UTC
Permalink
Post by Bo Berglund
On Tue, 02 Jan 2018 09:59:15 +0000, Daniel Shahaf
Post by Daniel Shahaf
Post by Branko Čibej
Post by Bo Berglund
Is there a command to show the revision when an item (directory or
file) was actually created in svn?
Currently the only hack to do this is by using 'svn log --stop-on-copy'
in a working copy.
Wouldn't 'svn log --stop-on-copy URL' work?
There's also this (not immediately obvious) command for showing the
svn log -r 0:HEAD -q -v --stop-on-copy --limit=1 -- TARGET
I believe this only works in a working copy, not on the server in a
hook...
Yes it does work on the server in a hook if TARGET is an URL.

$ svn log -r 0:HEAD -q -v --stop-on-copy --limit=1 https://svn.apache.org/repos/asf/subversion/branches/1.10.x
------------------------------------------------------------------------
r1817773 | julianfoad | 2017-12-11 14:22:31 +0100 (Mon, 11 Dec 2017)
Changed paths:
A /subversion/branches/1.10.x (from /subversion/trunk:1817772)
------------------------------------------------------------------------


Of course, on the server, you can use a file:// URL to avoid looping
through HTTP(S).

-- Brane
Bo Berglund
2018-01-02 12:27:32 UTC
Permalink
Post by Branko Čibej
Post by Bo Berglund
I am trying to use svnlook to find the revision when a directory was
created. I want to use this to dig out the timestamps of tags and
branches. My svn version is 1.9.7 (both server and client).
... and the list continues in *trunk* for about 50 lines ...
Yes, that is correct. You asked for the history of the item; it was
copied (branched) from trunk in r103, and svnlook is showing the whole
history.
I noted this and asked if there is a way to get the revision when the
directory was actually ADDED thus making it possible to extract the
timestamp. I should probably have asked in the subject for the
*revision* it was added and that would have given me the tool to get
the other info...
Post by Branko Čibej
Post by Bo Berglund
Is there a command to show the revision when an item (directory or
file) was actually created in svn?
Currently the only hack to do this is by using 'svn log --stop-on-copy'
in a working copy.
This is not going to work on the server using svnlook then....
Post by Branko Čibej
Post by Bo Berglund
D:\>svnlook changed -r 699 D:\SVN\test\bosse --copy-info
A + CVSMailer/tags/Rel_1-5-2-50_20060422/
(from CVSMailer/trunk/:r698)
But lacking the revision number when it was added I cannot find the
extra info like the date...
"The date" is a revision property.
But I am looking for a way to find the revision so this timestamp I am
after can be extracted...
Post by Branko Čibej
What are you actually trying to achieve?
Apart from the timestamp I want for other purposes I am also after the
revision for a changed file when it was last changed (forgot this when
posting).
So I want to create a commit email including info that we are used to
having in the emails we get from our earlier system.
This includes a list with the following for each changed item:

-Item that was changed (dir or file, available in svnlook changed)
-revision it was changed (i.e. the commit revision - simple)
-revision it was last changed before this commit (how to do this?)
-a command to diff the new file version with the previous

So my mail will contain this tabular list:
Op Item rev previous_rev diff_revs

(Op is D U _U or UU from svnlook changed)

All but the two last items are simple....
Post by Branko Čibej
Post by Bo Berglund
There's a good chance that
whatever you're trying to use svnlook for has already been implemented
half a dozen times, using an existing tool might get you to your goal
quite a bit faster.
Not for me because all the hook scripts I have looked at are either
too simplistic (basically pushing svnlook info and svnlook changed
into the mail body) or they are written in a language I do not
master...

I am almost done now, only lacking a way to find the revision of the
last change before the current for all file items in the list of
changes.

I will skip the diff-revs link for now because it relied on the ViewVc
service for the CVS repository where a diff was available and I only
had to calculate the url of the proper diff to put into the email.

Now I first have to install and make working the ViewVc version which
is able to work with svn....
--
Bo Berglund
Developer in Sweden
Branko Čibej
2018-01-02 12:51:48 UTC
Permalink
Post by Bo Berglund
Post by Branko Čibej
Post by Bo Berglund
I am trying to use svnlook to find the revision when a directory was
created. I want to use this to dig out the timestamps of tags and
branches. My svn version is 1.9.7 (both server and client).
... and the list continues in *trunk* for about 50 lines ...
Yes, that is correct. You asked for the history of the item; it was
copied (branched) from trunk in r103, and svnlook is showing the whole
history.
I noted this and asked if there is a way to get the revision when the
directory was actually ADDED thus making it possible to extract the
timestamp. I should probably have asked in the subject for the
*revision* it was added and that would have given me the tool to get
the other info...
Post by Branko Čibej
Post by Bo Berglund
Is there a command to show the revision when an item (directory or
file) was actually created in svn?
Currently the only hack to do this is by using 'svn log --stop-on-copy'
in a working copy.
This is not going to work on the server using svnlook then....
Post by Branko Čibej
Post by Bo Berglund
D:\>svnlook changed -r 699 D:\SVN\test\bosse --copy-info
A + CVSMailer/tags/Rel_1-5-2-50_20060422/
(from CVSMailer/trunk/:r698)
But lacking the revision number when it was added I cannot find the
extra info like the date...
"The date" is a revision property.
But I am looking for a way to find the revision so this timestamp I am
after can be extracted...
Post by Branko Čibej
What are you actually trying to achieve?
Apart from the timestamp I want for other purposes I am also after the
revision for a changed file when it was last changed (forgot this when
posting).
So I want to create a commit email including info that we are used to
having in the emails we get from our earlier system.
-Item that was changed (dir or file, available in svnlook changed)
-revision it was changed (i.e. the commit revision - simple)
-revision it was last changed before this commit (how to do this?)
-a command to diff the new file version with the previous
Oh for goodness' sake, please use an existing mailer script that already
does all of that. Don't reinvent the wheel. The mailer we have in the
Subversion repository shows the log message, what changed in the commit
and the complete diff; you could easily adapt it for your needs.

("revision it was last changed before this commit ... I'm not sure why
you need this info; you don't need it to generate the diff.)
Post by Bo Berglund
Not for me because all the hook scripts I have looked at are either
too simplistic (basically pushing svnlook info and svnlook changed
into the mail body) or they are written in a language I do not
master...
Well here I can't help you other than to suggest that "mastering" a
language is not a prerequisite to customizing a script. Python isn't
that hard to understand.

Alternatively, you could investigate some existing freely (or not so
freely) available development tools that have all this integrated. I
won't post links to commercial offers on this list, but they're just one
search away.

-- Brane

Loading...