How to checkout a single file without checking out the entire branch

Asked by Adamantium

I am wanting to do a checkout of a single file without taking the entire branch.
so if I have my branch as myproject.
and on the server repository I have a variety of files for example : abc.txt, test.txt, newfile.txt
In my myproject working branch I want to only checkout say abc.txt, is this possible to do without taking the rest of the branch.

Any ideas would be great.

Thanks.

Question information

Language:
English Edit question
Status:
Answered
For:
Bazaar Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Michael Hudson-Doyle (mwhudson) said :
#1

You can use bzr cat for this, eg bzr cat $branch_url/abc.txt > abc.txt

Revision history for this message
mzunino (emezeta) said :
#2

And if I need to get the entire folder instead? Tks!

Revision history for this message
Martin Pool (mbp) said :
#3

'bzr checkout $branch_url'

Revision history for this message
mzunino (emezeta) said :
#4

It is not the first time this happens to me

mkdir acc_v6_rb
cd acc_v6_rb
bzr branch lp:openobject-addons/extra-trunk/account_v6_reports_backport
bzr: ERROR: Permission denied: "Cannot create 'account_v6_reports_backport'. Only Bazaar branches are allowed."

and of course I have write permissions on brand new acc_v6_rb folder.
what am i doing wrong?
thank you, again.

Revision history for this message
Martin Pool (mbp) said :
#5

There is no branch called
lp:openobject-addons/extra-trunk/account_v6_reports_backport on the
server. It's a known bug you get a confusing message here.

Revision history for this message
Martin Pool (mbp) said :
#6

Please keep talking through the question, rather than mailing me directly.

The simplest thing is to just get a checkout of the whole branch then
copy the directory you need.

On 14 December 2010 14:29, Marcelo Zunino <email address hidden> wrote:
> ---------- Forwarded message ----------
> From: Martin Pool <email address hidden>
> Date: 2010/12/14
> Subject: Re: [Question #120210]: How to checkout a single file without
> checking out the entire branch
> To: <email address hidden>
>
>
> Question #120210 on Bazaar changed:
> https://answers.launchpad.net/bzr/+question/120210
>
> Martin Pool proposed the following answer:
> There is no branch called
> lp:openobject-addons/extra-trunk/account_v6_reports_backport on the
> server.  It's a known bug you get a confusing message here.
>
> ------------------
>
> Sorry about my confusion. Also I mailing you by private to not add
> more noise at Bazaar Questions.
>
> The branch I mentioned is called "lp:openobject-addons/extra-trunk"
> [0] and the directory I need to get is "account_v6_reports_backport"
> from here my original question ¿how can I obtain
> "account_v6_reports_backport" only, instead of the entire branch?
>
> Anyway, it's just one example, I have the same issue on many others  branches.
>
> Please consider my fault, if is there something I misunderstood. I 'm
> not English speaking native.
> Thank you very much.
>
> [0] https://code.launchpad.net/~openerp-commiter/openobject-addons/trunk-extra-addons
>
>

--
Martin

Revision history for this message
mzunino (emezeta) said :
#7

Thanks for your answer.
But exactly that, getting off the entire branch is what I'm trying to avoid.
I'm just starting with bzr, perhaps my knowledge would be too small.

Revision history for this message
Vincent Ladeuil (vila) said :
#8

bzr versions trees, getting only part of them is not possible (yet).

Revision history for this message
Richard Klein (kleinric) said :
#9

This would be a very useful feature. Source code for a large project is kept on a server over the internet. I work from home but my internet is very limited. I'd like to be able to checkout/branch
just the folder on which I'm working to save large downloads.

Imagine Project/plugin1
Currently I find we can kinda of do this through:
=======ON SERVER=================================
cd Project
bzr split plugin1
bzr commit -m "Split plugin1 out"
cd plugin1
bzr commit -m "Split from Main Tree"
======ON MY COMPUTER============================
bzr branch url/to/Project/plugin1
#Changes in plugin1
bzr update
bzr push url/to/Project/plugin1
======ON SERVER==================================
cd Project/plugin1
bzr join .
bzr commit -m "Join in Changes from plugin 1"
==================================================
It seems to get the job done, but its a real mission though :/ And can cause problems with people checking out the project while a split is there... To be able to checkout/branch just a folder transparently would be an absolutely super awesome feature... narrow/partial clones would make a huge difference. Even if its just doing these kind of commands underneath, but in a way that keeps everything consistent for other people?

We are not too keen on splitting the project into too many smaller repos, as we still want to be able to branch/checkout/diff/status/etc... on a project wide basis. Is there possibly a better way to do this?

Revision history for this message
Martin Pool (mbp) said :
#10

I agree it would be awesome. For the moment you can use bzr view to
restrict the size of the working tree, but that doesn't help much with
the download.

Revision history for this message
Richard Klein (kleinric) said :
#11

Cool thanks, I'll look into that. Although the important part is only really the Download due to bandwidth limitations, it can take up as much space as it wants when its here.

Is this feature in the pipeline at the moment or is it just a dream at this stage?

Revision history for this message
Martin Pool (mbp) said :
#12

On 17 February 2011 23:09, Richard Klein
<email address hidden> wrote:
> Question #120210 on Bazaar changed:
> https://answers.launchpad.net/bzr/+question/120210
>
> Richard Klein posted a new comment:
> Cool thanks, I'll look into that. Although the important part is only
> really the Download due to bandwidth limitations, it can take up as much
> space as it wants when its here.
>
> Is this feature in the pipeline at the moment or is it just a dream at
> this stage?

There is some code to build on but nobody's actively working on it.
If you're interested in doing it we can help you.

Revision history for this message
Richard Klein (kleinric) said :
#13

Thats cool, I'd be happy to put some time into this. I don't actually know anything about the structure of bzr under the hood, so it'd probably be better for me to understand all of that first before I dive into this, could you point me in the right direction to orientate myself with the workings of bzr and then when I'm comfortable with that, give me some guidance on how to solve this problem?

Revision history for this message
Martin Pool (mbp) said :
#14

Hi Richard,

There are some developer docs on <http://doc.bazaar.canonical.com/>.
As far as approach:

1- Probably a good way to begin is by looking at the amount of network
traffic we do to get a lightweight checkout of the whole tree, and
push that down. Run bzr with -Dhpss and it will record what network
IO it does.

2- Then we could add a 'checkout --view' or similar option that only
builds part of the tree.

3- Finally we can only fetch the things that are needed to build the
interesting parts of the tree.

But, most of all, talk to us on irc (or the list) about what to do.\

Can you help with this problem?

Provide an answer of your own, or ask Adamantium for more information if necessary.

To post a message you must log in.