You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Stephen Butler <sb...@elego.de> on 2008/01/21 17:52:30 UTC

Repo API -- finding the "last revision" of a file

Hi folks, especially the repository experts,

On the tree-conflicts branch, we'd like to use the repository history
to rule out some false positives during merge.  It's not clear (to us)
how to ask the repo certain questions, such as "Did file Foo.c ever
exist in the current branch, and if so, which revision was the last one
to include Foo.c?".

Suppose Foo.c is to be edited by a merge, but Foo.c does not exist in
the BASE revision of the current working copy.  Use case 4 in
notes/tree-conflicts/detection.txt says we should mark this as a tree
conflict if all of the following are true.

   1. The files at path Foo.c in merge-left and and in merge-right have
      a common ancestor.

   2. A file Foo.c used to exist in the branch the working copy was
      checked out from.

   3. The "last surviving" Foo.c in the working copy's branch has an ancestor
      in common with the Foo.c in the branch that is the source of the
      merge.

To make the example more concrete, suppose the user executed the
following command to merge some changes from their trunk to a working
copy of branches/mybranch.  Foo.c has been modified on trunk, and it does
not exist in the BASE revision of the working copy of branches/mybranch.

   $ svn merge -r20:25 $trunk_url $mybranch_wc

We have a tree conflict if the following are true:

   1. $trunk_url/Foo.c@20 and $trunk_url/Foo.c@25 have a youngest common
      ancestor revision YCA1 (most likely r20).

   2. There is a "last revision" of Foo.c in $mybranch_url (e.g., if r16
      deletes $mybranch_url/Foo.c, then the last revision would be r15).

   3. YCA1 and the last revision of $mybranch_url/Foo.c have a
      youngest common ancestor YCA2.

Our question is, how to we find the last revision at which Foo.c
existed in branches/mybranch?  Can we simply call
svn_client__repos_location_segments() with the following args?

    path: "Foo.c"
    peg_revision: SVN_INVALID_REVNUM
    start_rev: BASE
    end_rev: SVN_INVALID_REVNUM

Thanks,
Steve

-- 
Stephen Butler | Software Developer

elego Software Solutions GmbH
Gustav-Meyer-Allee 25 | 13355 Berlin | Germany

fon: +49 30 2345 8696 | mobile: +49 163 25 45 015
fax: +49 30 2345 8695 | http://www.elegosoft.com

Geschäftsführer: Olaf Wagner | Sitz der Gesellschaft: Berlin
Amtsgericht Charlottenburg HRB 77719 | USt-IdNr: DE163214194



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


RE: Repo API -- finding the "last revision" of a file

Posted by Paul Burba <pb...@collab.net>.
> -----Original Message-----
> From: Mark Phippard [mailto:markphip@gmail.com] 
> Sent: Monday, January 21, 2008 2:28 PM
> To: Michael Pilato
> Cc: Stephen Butler; dev@subversion.tigris.org; Paul Burba
> Subject: Re: Repo API -- finding the "last revision" of a file
> 
> On Jan 21, 2008 2:12 PM, C. Michael Pilato 
> <cm...@collab.net> wrote:
> > Stephen Butler wrote:
> > > Our question is, how to we find the last revision at which Foo.c 
> > > existed in branches/mybranch?  Can we simply call
> > > svn_client__repos_location_segments() with the following args?
> > >
> > >    path: "Foo.c"
> > >    peg_revision: SVN_INVALID_REVNUM
> > >    start_rev: BASE
> > >    end_rev: SVN_INVALID_REVNUM
> >
> > That won't work.
> >
> > And there currently is no easy to answer the question.  Remember, 
> > Subversion models the deletion of an item as the removal of 
> its entry 
> > in its parent directory.  So there is record attached to a 
> given line 
> > of history of the end of that line of history.
> >
> > Applications like ViewVC use a binary search to answer this 
> question, 
> > but ViewVC has the advantage of being server-side already.  
> Ideally, 
> > we'd have an RA API that answered the question, which would 
> allow the 
> > server side to become more optimal as we enhanced the 
> knowledge housed in the repository.
> > Today, though, no such RA API exists.
> 
> I recall that Paul Burba added some code that does something, 
> somewhat like what is wanted.  When you run svn status -u, 
> and you have a file in your WC that has been deleted in the 
> repository, we wanted to be able to return the revision it 
> was deleted.

That would be svn_repos_deleted_rev().  Though, as Mark says, it doesn't
do exactly what you are looking for.  Rather than finding the last
revision in which a path existed, it finds the first revision in which
it was deleted.

Paul

> The code does do this now.  I believe it does a 
> binary search within the fs.
> 
> This was done over a year ago, but after 1.4 was released.
> 
> --
> Thanks
> 
> Mark Phippard
> http://markphip.blogspot.com/
> 
> 

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


Re: Repo API -- finding the "last revision" of a file

Posted by Mark Phippard <ma...@gmail.com>.
On Jan 21, 2008 2:12 PM, C. Michael Pilato <cm...@collab.net> wrote:
> Stephen Butler wrote:
> > Our question is, how to we find the last revision at which Foo.c
> > existed in branches/mybranch?  Can we simply call
> > svn_client__repos_location_segments() with the following args?
> >
> >    path: "Foo.c"
> >    peg_revision: SVN_INVALID_REVNUM
> >    start_rev: BASE
> >    end_rev: SVN_INVALID_REVNUM
>
> That won't work.
>
> And there currently is no easy to answer the question.  Remember, Subversion
> models the deletion of an item as the removal of its entry in its parent
> directory.  So there is record attached to a given line of history of the
> end of that line of history.
>
> Applications like ViewVC use a binary search to answer this question, but
> ViewVC has the advantage of being server-side already.  Ideally, we'd have
> an RA API that answered the question, which would allow the server side to
> become more optimal as we enhanced the knowledge housed in the repository.
> Today, though, no such RA API exists.

I recall that Paul Burba added some code that does something, somewhat
like what is wanted.  When you run svn status -u, and you have a file
in your WC that has been deleted in the repository, we wanted to be
able to return the revision it was deleted.  The code does do this
now.  I believe it does a binary search within the fs.

This was done over a year ago, but after 1.4 was released.

-- 
Thanks

Mark Phippard
http://markphip.blogspot.com/

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

Re: Repo API -- finding the "last revision" of a file

Posted by "C. Michael Pilato" <cm...@collab.net>.
Stephen Butler wrote:
> Our question is, how to we find the last revision at which Foo.c
> existed in branches/mybranch?  Can we simply call
> svn_client__repos_location_segments() with the following args?
> 
>    path: "Foo.c"
>    peg_revision: SVN_INVALID_REVNUM
>    start_rev: BASE
>    end_rev: SVN_INVALID_REVNUM

That won't work.

And there currently is no easy to answer the question.  Remember, Subversion 
models the deletion of an item as the removal of its entry in its parent 
directory.  So there is record attached to a given line of history of the 
end of that line of history.

Applications like ViewVC use a binary search to answer this question, but 
ViewVC has the advantage of being server-side already.  Ideally, we'd have 
an RA API that answered the question, which would allow the server side to 
become more optimal as we enhanced the knowledge housed in the repository. 
Today, though, no such RA API exists.

-- 
C. Michael Pilato <cm...@collab.net>
CollabNet   <>   www.collab.net   <>   Distributed Development On Demand