Retrieve a specific file from some revision.

Ben Finney ben+bazaar at benfinney.id.au
Tue Mar 16 22:48:14 GMT 2010


Harry Putnam <reader at 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.

> 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




More information about the bazaar mailing list