threads / discuss / 23041

Retrieve a specific file from some revision.

Subject: Retrieve a specific file from some revision.

## tl;dr

3 messages between Mar 16, 2010 and Mar 16, 2010.

replies: 2people: 3as markdown or json

Harry Putnam· Mar 16, 2010, 18:55 UTC · lore

First, let me just make sure this group is the general question/discussion group for the versioning tool `bazaar' on the web at: http://bazaar.canonical.com/en/

I asked this question on a mercurial group too. Probably should have just crossposted so as not to have two different messgae-ids involved. I have done that with this post on bazarre-ng and git groups.

I'm not just jerking around but want to know how this would be done. Just reading docu doesn't usually really help me until wade into something but this time I want to choose a versioning tool that I can readily do things I've learned to rely on.

Reprint: ------- --------- ---=--- --------- --------

I've never used any versioning tool but cvs. Something I do often with cvs is retrieve a previous state of a single file..

Say I wanted to use the hosts file as it was at revision 1.23.
Not just a diff, but the actual file.
(I would)
  cd cvsrepo
    cvs update -p -r1.23 <HOST>/etc/hosts > ~/hosts_HOST_r1.23
  Would create the file as it was at rev. 1.23 for host HOST.
How would I do that in bazaar/git? (which ever newsgroup this is on)
 
Martin Langhoff· Mar 16, 2010, 21:59 UTC · re: Harry Putnam · lore

Re: Retrieve a specific file from some revision.

On Tue, Mar 16, 2010 at 2:55 PM, Harry Putnam <reader@newsguy.com> wrote:
> How would I do that in bazaar/git?
The easiests, most convenient is:
   git show <revision>:path/to/file.c
git show can do various other things -- like show you a commit.

You should really follow a tutorial for git (and/or bazaar) to get "the basics". Any good tutorial will cover git show (but may not touch this specific point) and a few others.

It is safe to say that bazaar, git and hg have a good command for something clear and basic like this. Asking these questions probably won't help you decide what you want to decide ;-) --

m
-- 
 martin.langhoff@gmail.com
 martin@laptop.org -- School Server Architect
 - ask interesting questions
 - don't get distracted with shiny stuff  - working code first
 - http://wiki.laptop.org/go/User:Martinlanghoff
Ben Finney· Mar 16, 2010, 22:48 UTC · re: Harry Putnam · lore

Re: Retrieve a specific file from some revision.

Harry Putnam <reader@newsguy.com> writes:
> I've never used any versioning tool but cvs.  Something I do often
> with cvs is retrieve a previous state of a single file..
>
> Say I wanted to use the hosts file as it was at revision 1.23.

I'll assume, from the Bazaar perspective, that this means “revno 123 of the branch”. Bazaar tracks snapshot revisions of the working tree as a whole, unlike CVS's per-file tracking.

Show 8 quoted lines
> Not just a diff, but the actual file.
> (I would)
>   cd cvsrepo
>     cvs update -p -r1.23 <HOST>/etc/hosts > ~/hosts_HOST_r1.23
>
>   Would create the file as it was at rev. 1.23 for host HOST.
>
> How would I do that in bazaar/git? (which ever newsgroup this is on)

To get the file at revno 123 in the working tree for the branch (the most normal place for it to appear):

    $ cd bzrbranch/
    $ bzr revert --revision 123 HOST/etc/hosts
You could then copy the file to wherever you actually want to use it.

Alternatively, if you really do want something that emits the file contents to stdout rather than recreating the file:

    $ cd bzrbranch/
    $ bzr cat --revision 123 HOST/etc/hosts > ~/hosts_HOST_r123
The ‘--revision 123’ option is the verbose spelling of ‘-r 123’.
-- 
 \              “Whatever you do will be insignificant, but it is very |
  `\                    important that you do it.” —Mohandas K. Gandhi |
_o__)                                                                  |
Ben Finney

← back to recent threads