You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Bo Berglund <bo...@gmail.com> on 2018/05/18 16:00:21 UTC

How to check out a project based on commit time rather than rev?

Obviously this is a "for dummies" question but I *have* looked at the
svnbook but I cannot still find how to do this:

An old project suite has been converted from CVS to SVN and now we
need to go back in time in SVN and get a version that was current at a
time like 2017-01-01.
There are several project directories that have been modified at
different times because they hold different software components.

But AFAICS there is no checkout alternative that makes it possible to
use a timestamp, only revision numbers....
For svn log I found that one can use -r {2017-01-01}, is that possible
also for svn co?
But unfortunately even for log it returns an empty dataset when I do:
svn log -r {2017-01-01}

I have no idea how to find a relevant revision number for a date
inbetween two commit dates so I can use it as a revision to define the
state of the projects. And if I found one, what happens if a file was
not committed in that revision, will it still appear in the checkout?

Alternately I could also copy the state at this time to a tag, but I
still need to know a revision number for that and all I can say is
that it should be before a certain time.

I use svn 1.9.7 on both client and server.


-- 
Bo Berglund
Developer in Sweden


Re: How to check out a project based on commit time rather than rev?

Posted by Paul Hammant <pa...@hammant.org>.
Ooops, my apologies for top posting, folks.

Re: How to check out a project based on commit time rather than rev?

Posted by Paul Hammant <pa...@hammant.org>.
You have Linux Subsystem for Windows* installed?  If yes, I see a bash
oneliner coming :)

- Paul

* yes yes, some genius in MS named it Windows Subsystem for Linux (WSL).

On Fri, May 18, 2018 at 12:35 PM, Bo Berglund <bo...@gmail.com> wrote:

> On Fri, 18 May 2018 18:00:21 +0200, Bo Berglund
> <bo...@gmail.com> wrote:
>
> >Obviously this is a "for dummies" question but I *have* looked at the
> >svnbook but I cannot still find how to do this:
>
> I did not read good enough!
> This worked fine to get the information I needed concerning active
> revision numbers:
> svn log -v -r {2012-05-06}:{2017-01-01} <URL to server side directory>
> > log.txt
>
> So now I can use this to compare the files and add what is lacking to
> the wc I have checked out to make it be current at the date I need.
>
> Sorry for the noise!
>
> --
> Bo Berglund
> Developer in Sweden
>
>


-- 
Paul Hammant DevOps <https://devops.paulhammant.com> Let me give your
enterprise a step by step plan to get out of the hell of crazy branching
models (ClearCase maybe?) and into the world of high-throughput CD on
DevOps foundations.

Re: How to check out a project based on commit time rather than rev?

Posted by Daniel Shahaf <d....@daniel.shahaf.name>.
Ryan Schmidt wrote on Fri, 18 May 2018 18:55 -0500:
> There is no need for a separate command because any command that takes a 
> revision number can also accept a date and time. If no time is 
> specified, the time is midnight. Subversion then uses the newest 
> revision that precedes the given date and time.

To be more precise, dates are resolved to revision numbers using binary
search on the revisions space, comparing by the svn:date revprop's
value; that process can give different answers over time (as HEAD
increases) if the sequence of svn:date values isn't monotonically
increasing, which can happen, for instance, when doing 'svnadmin load'
into an existing repository.

Re: How to check out a project based on commit time rather than rev?

Posted by Ryan Schmidt <su...@ryandesign.com>.
On May 18, 2018, at 14:14, Nathan Hartman wrote:
> On Fri, May 18, 2018 at 12:35 PM Bo Berglund wrote:
>> On Fri, 18 May 2018 18:00:21 +0200, Bo Berglund wrote:
>> 
>>> Obviously this is a "for dummies" question but I *have* looked at the
>>> svnbook but I cannot still find how to do this:
>> 
>> I did not read good enough!
>> This worked fine to get the information I needed concerning active
>> revision numbers:
>> svn log -v -r {2012-05-06}:{2017-01-01} <URL to server side directory>
>> > log.txt
>> 
>> So now I can use this to compare the files and add what is lacking to
>> the wc I have checked out to make it be current at the date I need.
> 
> I've wondered why there isn't a checkout or update command that takes a date and time but usually I look in the log to figure out what is the revision number.

There is no need for a separate command because any command that takes a revision number can also accept a date and time. If no time is specified, the time is midnight. Subversion then uses the newest revision that precedes the given date and time. For example, if I request to check out MacPorts code from midnight October 10, 2002:

$ cd /tmp
$ svn co https://svn.macports.org/repository/macports/trunk -r '{2002-10-10}'
$ cd trunk
$ svn info
Path: .
Working Copy Root Path: /private/tmp/trunk
URL: https://svn.macports.org/repository/macports/trunk
Relative URL: ^/trunk
Repository Root: https://svn.macports.org/repository/macports
Repository UUID: d073be05-634f-4543-b044-5fe20cf6d1d6
Revision: 1025
Node Kind: directory
Schedule: normal
Last Changed Author: jpm
Last Changed Rev: 1025
Last Changed Date: 2002-10-09 22:38:38 -0500 (Wed, 09 Oct 2002)

I get revision 1025, the newest revision that is not after midnight October 10, 2002.

Re: How to check out a project based on commit time rather than rev?

Posted by Ryan Schmidt <su...@ryandesign.com>.
On May 18, 2018, at 17:01, Bo Berglund wrote:

> So now I know what has happened and I found the revision numbers for
> two revisions that were committed erroneously last December when I was
> preparing for the CVS -> SVN migration.
> These revisions are 4309 and 4310
> 
> Now my problem is in finding the correct svn command to restore the
> trunk files to the state they were in prior to commit r4309.
> 
> I have googled a lot tonight and read the svnbook too but I am none
> the wiser (not so that I dare run a command and risk screwing up the
> repository).
> I have some candidates within the top dir of a WC of the
> project/trunk:
> 
> svn merge -c 4308:HEAD .
> 
> svn merge -r 4308:HEAD .
> 
> svn merge -r 4309:HEAD .
> 
> svn merge -c COMMITTED:PREV .
> 
> Questions:
> ----------
> 1) Use -c or -r?
> 
> 2) Which order of revision numbers?
> 
> 3) What to do to restore to two revisions back?

When merging:

"-c 500" is a shorthand synonym for "-r 499:500".

"-r 499:500" means "the set of steps to turn r499 into r500".

You'll use this if you want to repeat what you did in a revision, for example to make the same change on another branch.

If instead you want to undo a change you already committed, then you'll want to merge in the reverse order: "-r 500:499" to turn 500 back into 499, or using the shorthand: "-c -500".

If you want to do two revisions at once, just extend the range, e.g. "-r 498:500" is the steps to turn r498 into r500.

So if you want to undo what you did in revisions 4309 and 4310, you would merge "-r 4310:4308".

http://svnbook.red-bean.com/en/1.7/svn.branchmerge.basicmerging.html#svn.branchmerge.basicmerging.undo


Re: How to check out a project based on commit time rather than rev?

Posted by Bo Berglund <bo...@gmail.com>.
On Fri, 18 May 2018 15:36:02 -0500, Dane Kantner
<da...@gmail.com> wrote:

> svn log -v -r {2012-05-06}:{2017-01-01} <URL to server side directory>  is
>not reliable though as it doesn't actually consistently return the data
>correctly ;  there has been a past topic on this and it's been explained as
>a known defect due to how it was implemented.  You're better off trying to
>determine the revision number in play at the time of the start, and at the
>time of the end, then using the revision numbers instead.

Thanks, I used this in a WC:
svn log -v -r {2012-10-01}:HEAD URL
And it returned the few commits including affected files that were
involved from the start date. Not so many given that the project is so
old. But it clearly showed the bogus commits I want to recover from.

So now I know what has happened and I found the revision numbers for
two revisions that were committed erroneously last December when I was
preparing for the CVS -> SVN migration.
These revisions are 4309 and 4310

Now my problem is in finding the correct svn command to restore the
trunk files to the state they were in prior to commit r4309.

I have googled a lot tonight and read the svnbook too but I am none
the wiser (not so that I dare run a command and risk screwing up the
repository).
I have some candidates within the top dir of a WC of the
project/trunk:

svn merge -c 4308:HEAD .

svn merge -r 4308:HEAD .

svn merge -r 4309:HEAD .

svn merge -c COMMITTED:PREV .

Questions:
----------
1) Use -c or -r?

2) Which order of revision numbers?

3) What to do to restore to two revisions back?


-- 
Bo Berglund
Developer in Sweden


Re: How to check out a project based on commit time rather than rev?

Posted by Dane Kantner <da...@gmail.com>.
 svn log -v -r {2012-05-06}:{2017-01-01} <URL to server side directory>  is
not reliable though as it doesn't actually consistently return the data
correctly ;  there has been a past topic on this and it's been explained as
a known defect due to how it was implemented.  You're better off trying to
determine the revision number in play at the time of the start, and at the
time of the end, then using the revision numbers instead.

On Fri, May 18, 2018 at 2:14 PM, Nathan Hartman <ha...@gmail.com>
wrote:

> On Fri, May 18, 2018 at 12:35 PM Bo Berglund <bo...@gmail.com>
> wrote:
>
>> On Fri, 18 May 2018 18:00:21 +0200, Bo Berglund
>> <bo...@gmail.com> wrote:
>>
>> >Obviously this is a "for dummies" question but I *have* looked at the
>> >svnbook but I cannot still find how to do this:
>>
>> I did not read good enough!
>> This worked fine to get the information I needed concerning active
>> revision numbers:
>> svn log -v -r {2012-05-06}:{2017-01-01} <URL to server side directory>
>> > log.txt
>>
>> So now I can use this to compare the files and add what is lacking to
>> the wc I have checked out to make it be current at the date I need.
>>
>> Sorry for the noise!
>>
>> --
>> Bo Berglund
>> Developer in Sweden
>
>
> I've wondered why there isn't a checkout or update command that takes a
> date and time but usually I look in the log to figure out what is the
> revision number.
>
> I don't know how CVS works but with Subversion, when you checkout an old
> revision, you get the directories and files exactly as they looked in that
> revision (including files that were not changed in that revision). Think of
> it as a snapshot of how everything looked at that moment. Just make sure
> each time you commit that Subversion knows about all the files you intend
> to keep -- ie that svn st in the working copy directory does not show '?'
> on files that should be under version control. You're allowed to have
> unversioned files alongside versioned ones, eg for intermediate build
> artifacts, editor bak files, and other junk.
>
>
>>

Re: How to check out a project based on commit time rather than rev?

Posted by Nathan Hartman <ha...@gmail.com>.
On Fri, May 18, 2018 at 12:35 PM Bo Berglund <bo...@gmail.com> wrote:

> On Fri, 18 May 2018 18:00:21 +0200, Bo Berglund
> <bo...@gmail.com> wrote:
>
> >Obviously this is a "for dummies" question but I *have* looked at the
> >svnbook but I cannot still find how to do this:
>
> I did not read good enough!
> This worked fine to get the information I needed concerning active
> revision numbers:
> svn log -v -r {2012-05-06}:{2017-01-01} <URL to server side directory>
> > log.txt
>
> So now I can use this to compare the files and add what is lacking to
> the wc I have checked out to make it be current at the date I need.
>
> Sorry for the noise!
>
> --
> Bo Berglund
> Developer in Sweden


I've wondered why there isn't a checkout or update command that takes a
date and time but usually I look in the log to figure out what is the
revision number.

I don't know how CVS works but with Subversion, when you checkout an old
revision, you get the directories and files exactly as they looked in that
revision (including files that were not changed in that revision). Think of
it as a snapshot of how everything looked at that moment. Just make sure
each time you commit that Subversion knows about all the files you intend
to keep -- ie that svn st in the working copy directory does not show '?'
on files that should be under version control. You're allowed to have
unversioned files alongside versioned ones, eg for intermediate build
artifacts, editor bak files, and other junk.


>

Re: How to check out a project based on commit time rather than rev?

Posted by Bo Berglund <bo...@gmail.com>.
On Fri, 18 May 2018 18:00:21 +0200, Bo Berglund
<bo...@gmail.com> wrote:

>Obviously this is a "for dummies" question but I *have* looked at the
>svnbook but I cannot still find how to do this:

I did not read good enough!
This worked fine to get the information I needed concerning active
revision numbers:
svn log -v -r {2012-05-06}:{2017-01-01} <URL to server side directory>
> log.txt

So now I can use this to compare the files and add what is lacking to
the wc I have checked out to make it be current at the date I need.

Sorry for the noise!

-- 
Bo Berglund
Developer in Sweden