[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Getting the last changed revision of a file including ancestry

From: Benjamin Fritz <fritzophrenic_at_gmail.com>
Date: Wed, 4 Jun 2014 13:36:38 -0500

At work, when we release our software, we need to record the last time
each file in our project has changed, and compare that to the last
revision where we recorded a peer review of that file. I need to get
the last actual change to a file, ignoring renames and copies that
didn't modify the file content.

For most files, just using "svn info -R" on the tag for the release
works nicely. The output for each file contains a "Last Changed Rev"
which contains the last change made to that file, regardless of how
many times the containing directory has been copied for branches,
forks, or tags in between.

But some files have been copied or renamed. On these files, even if no
changes to the file content occurred in the add-with-history, the
"last changed rev" inside "svn info" reflects the revision where the
add happened. Unlike svn diff or svn log, I do not see any
command-line flags to allow following history.

I thought to use "svn log -v" on the "last changed rev" shown in the
log, to extract the copy-from path, and use "svn info" again on that
path/revision. But, as far as I can tell, "svn log" does not show any
difference between an unmodified copy, and a copy where the file
content was additionally modified in the same commit as the copy was
added.

I see that "svn diff" has a --notice-ancestry option which I can use
to determine whether any changes happened during the copy.
Unfortunately, "svn log --diff" doesn't seem to accept that option, so
it needs to be a separate command.

To sum up, I've come up with the following procedure, which I think
will work, but is WAY to complicated for my tastes:

1. svn info to find last changed revision for each file
2. svn log -v -r on that revision of that file to see what changed
   a. If change was a modification, this is the revision I want
   b. If change was an "add" action with no "from", this is the revision I want
   c. If change was an "add" action with a "from", continue to step (3)
3. svn diff --notice-ancestry -r on the revision with the copy
   a. if there are no differences, start over at step (1) using the "from" path
      and revision
   b. if there are differences, this is the revision I want

Is there an easier way to do this? This will take a fairly complicated
script to accomplish what intuitively should be a very easy task.
Received on 2014-06-04 20:37:33 CEST

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.