Detecting out of date checkouts, plus bind without arguments

John Arbash Meinel john at arbash-meinel.com
Tue Jun 20 15:43:55 BST 2006


Adeodato Simó wrote:
> Hello!
> 
> I have a simple question, see below for the full story. I'd like to
> reliably detect when a branch has its working tree out of date, and
> needs `bzr update`. I'm doing it like this, but I'd like a word about if
> this will always work, or not. Thanks in advance.
> 
>   for d in `list_of_branches`; do
>     if [ "$d/.bzr/repository/revisions.kndx" -nt \
>          "$d/.bzr/checkout/last-revision" ]; then
>       bzr update "$d"
>     fi
>   done
> 
> The story: I have in my desktop a number of branches under ~/code
> (normal branches, no repository involved), which I regularly rsync to my
> webserver. Then, in my laptop, I have a checkout of each of those
> branches, so that each commit in the laptop goes to the desktop as well
> (unless there's no network, and I play with unbind and bind afterwards).
> 
> The issue is, of course, that the working trees in the desktop branches
> don't get updated after receiving a commit from the laptop, so I've
> included in my rsync-script a snippet like the above to make sure that
> the webserver has not only the repository up to date, but the working
> tree as well (so that people browising it do get the latest version).
> 
> That's it.
> 
> P.S.: I don't know if it has been proposed before, but would you think
> it'd make sense for `bzr bind $foo` to record $foo as the default bind
> location (a-la-pull), so that `bzr unbind; bzr bind` works and is a
> noop? I guess you can see the usefulness of it in a scenario like the
> above, when the location to bind to is always the same (a pretty common
> scenario, I'd say?)
> 

Well, you can re-issue 'bzr bind' without having to 'unbind' first. Is
that good enough?
I really don't know what you are doing trying to read 'revisions.kndx',
considering it may not contain anything you actually care about updating
(yet).

You may look into doing:

if [ tail -n1 .bzr/branch/revision-history != cat
.bzr/checkout/last-revision ]; then
...


That is the actual markers for the branch's last revision, versus the
checkouts last revision.

Another possibility is to just always issue 'bzr update'. If it is a
local branch, it is very cheap, and just does the above check before
returning.

John
=:->



-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 254 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060620/410d0589/attachment.pgp 


More information about the bazaar mailing list