You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Jason Rust <jr...@rustyparts.com> on 2003/11/04 22:21:35 UTC

Determining previous revision number

Is there any way from the command line to determine what the previous
revision number is, given an a specific revision number.  The problem is
that I have a list of files changed in a specific commit from svn log -v
(I'm writing a program to display the patchset of a commit).
However, I need to know what the previous revision of each of those
files is so that I can link to that revision.  I would think using some
combination of svn log -r "PREV":X would work, but no luck yet.
Obviously I could get the complete log for the file and iterate over
that until I find it, but it seems there should be an easier way.

Thanks,
-Jason

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Determining previous revision number

Posted by Jason Rust <jr...@rustyparts.com>.
> 1.  Well, that might not be the *actual* revision in which the file
> was last changed, but the contents should be the same (suitable for
> diffing purposes).

That was the key!  I didn't realize that the version numbers were
arbitrary in the sense that they don't need to be exact to get the
diffs between two versions.

Thanks,
-Jason

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Determining previous revision number

Posted by "C. Michael Pilato" <cm...@collab.net>.
Jason Rust <jr...@rustyparts.com> writes:

> Is there any way from the command line to determine what the previous
> revision number is, given an a specific revision number.  The problem is
> that I have a list of files changed in a specific commit from svn log -v
> (I'm writing a program to display the patchset of a commit).
> However, I need to know what the previous revision of each of those
> files is so that I can link to that revision.  I would think using some
> combination of svn log -r "PREV":X would work, but no luck yet.
> Obviously I could get the complete log for the file and iterate over
> that until I find it, but it seems there should be an easier way.

Given the output from 'svn log -r REV -v', you should have all you need.  

For modified paths, the previous version of any changed file is REV -
1.  Well, that might not be the *actual* revision in which the file
was last changed, but the contents should be the same (suitable for
diffing purposes).  For deleted paths, same game.  Added and replaced
paths have no previous version.

We this gets tricky is in light of copies, but it's still doable.  Say
you have:

   A  /trunk/copied-thing (from /trunk/thing, rev 4)
   M  /trunk/copied-thing/file

The data above is sufficient for noting that the previous incarnation
for /trunk/copied-thing/file lives at /trunk/thing, revision 4.

Of course, if your program is running on the same machine as the
repository, I'd consider looking into the Python bindings,
specifically the RevisionChangeCollector class in repos.py.  See
Subversion's mailer.py or ViewCVS for example usages of this class.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org