pull overwrite does not always find revisions after bind

Bug #165215 reported by Dave Brueck
2
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
Undecided
Unassigned

Bug Description

Due to some external tools and applications, I am using a fixed location on my local disk for a heavyweight checkout and need to be able to switch between branches. It typically works well using:

bzr bind $BZR/branchname
bzr pull --overwrite $BZR/branchname

If, however, I mistakenly forget to include the location in the pull command, my working directory gets into a state where bzr always reports 'No revisions to pull', regardless of what steps I do after that:

~/dev/work$ bzr bind $BZR/trunk/bug1234
~/dev/work$ bzr pull --overwrite # oops! forgot to specifiy the location
Using saved location: /Users/dave/repo/trunk/
No revisions to pull.
~/dev/work$ bzr pull --overwrite $BZR/trunk/bug1234 # specifying it here is too late
No revisions to pull.

Even if I try to get a new checkout, the problem persists:

~/dev/work$ cd ..
~/dev$ rm -Rf work
~/dev$ bzr co $BZR/trunk ./work
~/dev$ cd work
~/dev/work$ bzr bind $BZR/trunk/bug1234
~/dev/work$ bzr pull --overwrite $BZR/trunk/bug1234
No revisions to pull.

Maybe it's just a documentation bug - I just have no idea how to recover without nuking my .bzr directory and creating my entire local working tree from scratch.

The problem occurs both in 0.92 and bzr.dev 3020.

Below are the steps I used to reproduce the problem:

1) Create a tree-less shared repository (created it locally for simplicity) with a "trunk" project inside it:

bzr init-repo --no-trees ~/repo
bzr init ~/repo/trunk
export BZR=~/repo

2) Obtain a checkout of the project and add a file to it:

~$ cd dev
~/dev$ bzr co $BZR/trunk ./work
~/dev$ cd work
~/dev/work$ echo some file > file.txt
~/dev/work$ bzr add file.txt
added file.txt
~/dev/work$ bzr commit -m "added"
Committing revision 1 to "/Users/dave/repo/trunk/".
added file.txt
Committed revision 1.

3) Branch the project and commit a change to the file:

~/dev/work$ cd ..
~/dev$ rm -Rf work
~/dev$ bzr branch $BZR/trunk $BZR/trunk/bug1234
Branched 1 revision(s).
~/dev$ bzr co $BZR/trunk/bug1234 ./work

~/dev/work$ echo a change >> file.txt
~/dev/work$ bzr commit -m "changed it"
Committing revision 2 to "/Users/dave/repo/trunk/bug1234/".
modified file.txt
Committed revision 2.

4) Verify that switching branches works if I remember to include the location in the pull command:

~/dev/work$ bzr bind $BZR/trunk
~/dev/work$ bzr pull --overwrite $BZR/trunk
 M file.txt
All changes applied successfully.
Now on revision 1.
~/dev/work$ cat file.txt
some file

5) Omit the location in the pull command and get into the stuck state:

~/dev/work$ bzr bind $BZR/trunk/bug1234
~/dev/work$ bzr pull --overwrite
Using saved location: /Users/dave/repo/trunk/
No revisions to pull.
~/dev/work$ bzr pull --overwrite $BZR/trunk/bug1234
No revisions to pull.
~/dev/work$ bzr bind $BZR/trunk
~/dev/work$ bzr pull --overwrite $BZR/trunk
No revisions to pull.

Revision history for this message
Alexander Belchenko (bialix) wrote : Re: [Bug 165215] pull overwrite does not always find revisions after bind

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dave Brueck пишет:
> Public bug reported:
>
> Due to some external tools and applications, I am using a fixed location
> on my local disk for a heavyweight checkout and need to be able to
> switch between branches. It typically works well using:
>
> bzr bind $BZR/branchname
> bzr pull --overwrite $BZR/branchname

I usually do

bzr unbind
bzr pull --overwrite $BZR/branchname
bzr bind $BZR/branchname

and it works.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHSxCQzYr338mxwCURAhoSAJ9CM+h/10XxZguiDVgMM9IJMTZAdQCcDZJR
2bPFHABbzivZb4efj+yZdcM=
=wzUc
-----END PGP SIGNATURE-----

Revision history for this message
Aaron Bentley (abentley) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dave Brueck wrote:
> Public bug reported:
>
> Due to some external tools and applications, I am using a fixed location
> on my local disk for a heavyweight checkout and need to be able to
> switch between branches. It typically works well using:
>
> bzr bind $BZR/branchname
> bzr pull --overwrite $BZR/branchname

It seems like you would want to do "bzr update", not pull. Is there a
reason you're not doing that?

Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHSxJ+0F+nu1YWqI0RAqQsAKCE8IG2VHC+IV97IB3VBj94omB0DwCeITJk
Hn/UNl2GnV3tD5x04JcRGxI=
=w0Mm
-----END PGP SIGNATURE-----

Revision history for this message
Dave Brueck (dbrueck) wrote :

Alexander, it usually works for me fine until I accidentally forget the pull location, and then I get into the stuck state. I tried your method, and it seems like a good alternative since it seems to consistently avoid the problem (since the pull command refuses to run if the location is omitted). Thanks!

Aaron, using update doesn't seem like the right fit - when switching from the trunk to the bugfix branch, update does indeed bring in the change to the file, but if I then try to switch back to the trunk, that change remains in my local copy and is treated as a merge (which is not the desired behavior at all):

~/dev$ bzr co $BZR/trunk ./work
~/dev$ cd work
~/dev/work$ bzr bind $BZR/trunk/bug1234
~/dev/work$ bzr update
 M file.txt
All changes applied successfully.
Updated to revision 2.

That seemed to work ok, but switching back:

~/dev/work$ bzr bind $BZR/trunk
~/dev/work$ bzr update
 M file.txt
All changes applied successfully.
 M file.txt
All changes applied successfully.
Updated to revision 1.
Your local commits will now show as pending merges with 'bzr status', and can be committed with 'bzr commit'.

I had previously talked to Ian Clatworthy and he pointed me at the 'pull --overwrite' command instead of 'update', and then asked that I file a bug when I ran into the 'No revisions to pull' problem.

Thanks very much for responding so quickly.
-Dave

Revision history for this message
Aaron Bentley (abentley) wrote : Re: [Bug 165215] Re: pull overwrite does not always find revisions after bind

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dave Brueck wrote:
> I had previously talked to Ian Clatworthy and he pointed me at the 'pull
> --overwrite' command instead of 'update', and then asked that I file a
> bug when I ran into the 'No revisions to pull' problem.

Well, Ian is working on making the "switch" command work for heavyweight
checkouts. So this workflow should be directly supported soon.

I consider the current behavior to be a bug-- it shouldn't work at all
for you. Pulling in a checkout should pull into the master branch, and
update the local tree (and branch) to match it. This is already the
behavior for lightweight checkouts.

Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHSyCT0F+nu1YWqI0RAuzGAJ9vCbDvpp9p7tygoG42YMrQIarMZQCfbeUn
PB5B8k1nesVvc/gbn+A+5Dc=
=Nx3P
-----END PGP SIGNATURE-----

Revision history for this message
Robert Collins (lifeless) wrote : Re: [Bug 165215] pull overwrite does not always find revisions after bind

On Mon, 2007-11-26 at 18:29 +0000, Alexander Belchenko wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Dave Brueck пишет:
> > Public bug reported:
> >
> > Due to some external tools and applications, I am using a fixed location
> > on my local disk for a heavyweight checkout and need to be able to
> > switch between branches. It typically works well using:
> >
> > bzr bind $BZR/branchname
> > bzr pull --overwrite $BZR/branchname
>
> I usually do
>
> bzr unbind
> bzr pull --overwrite $BZR/branchname
> bzr bind $BZR/branchname
>
> and it works.

if you have a checkout,
bzr update ; bzr revert is guaranteed to put you back to an unmodified
state.

otherwise, if you are simply switching as you say, just use 'bzr switch
$BZR/branchname.

-Rob

--
GPG key available at: <http://www.robertcollins.net/keys.txt>.

Revision history for this message
John A Meinel (jameinel) wrote : Re: [Bug 165215] Re: pull overwrite does not always find revisions after bind

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dave Brueck wrote:
> Alexander, it usually works for me fine until I accidentally forget the
> pull location, and then I get into the stuck state. I tried your method,
> and it seems like a good alternative since it seems to consistently
> avoid the problem (since the pull command refuses to run if the location
> is omitted). Thanks!
>
> Aaron, using update doesn't seem like the right fit - when switching
> from the trunk to the bugfix branch, update does indeed bring in the
> change to the file, but if I then try to switch back to the trunk, that
> change remains in my local copy and is treated as a merge (which is not
> the desired behavior at all):

My first guess is that doing:

bzr bind $NEW_URL
bzr pull

Is causing NEW_URL to get overridden with the tip of the old parent. So that a
future 'bzr pull $NEW_URL' doesn't have anything to pull, because you have
actually changed its pointer. Just as if you had done:

cd $NEW_URL
bzr pull $OLD_URL

(after all, that is what a bound branch is meant to do.)

At one point "bzr bind" used to do an update for you, but we changed that ui.

I think the best thing is to just get "bzr switch" to do what you want, so you
don't have to worry about pull, etc.

In the short term, probably:

bzr unbind
bzr pull --overwrite $NEW_URL
bzr bind $NEW_URL

is the best route to go.

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHSy1qJdeBCYSNAAMRAih2AKC/XUWQQ5DAwBJFRPNxi/PflFeg4ACgmgzi
8qrWf5JM4n/9wZrIcOg6VP8=
=av9L
-----END PGP SIGNATURE-----

Revision history for this message
John A Meinel (jameinel) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Aaron Bentley wrote:
> Dave Brueck wrote:
>> I had previously talked to Ian Clatworthy and he pointed me at the 'pull
>> --overwrite' command instead of 'update', and then asked that I file a
>> bug when I ran into the 'No revisions to pull' problem.
>
> Well, Ian is working on making the "switch" command work for heavyweight
> checkouts. So this workflow should be directly supported soon.
>
> I consider the current behavior to be a bug-- it shouldn't work at all
> for you. Pulling in a checkout should pull into the master branch, and
> update the local tree (and branch) to match it. This is already the
> behavior for lightweight checkouts.
>
> Aaron

If it isn't doing that, it seems to be a bug.

What I'm thinking is that it *is* doing that, and causing his master branch to
be pointed at the tip of the other branch. (especially if he is using --overwrite.)

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHSy3MJdeBCYSNAAMRAoMzAJ9nNS/eFWltTZjBtt8Z8vqjoZxJQACeNh8S
5v/LjK35fLb2NwWSzEKKQfA=
=KmIU
-----END PGP SIGNATURE-----

Revision history for this message
Dave Brueck (dbrueck) wrote :

Thanks for the replies guys.

My original goal was to find out how to switch branches in place when using checkouts. Since 'bzr switch' doesn't support heavyweight checkouts yet, I searched the mailing list and noticed Ian's effort to merge the switch command into bzr from bzrtools. I contacted him and had a short discussion and he suggested I try pull --overwrite, and that's when I ran into this problem and he asked that I file the bug.

From talking to Ian, heavyweight checkout support in the switch command is on the todo list, but I don't know where it fits in priority-wise with other stuff he's doing, so in the meantime it looks like you all have helped me come up with two alternatives, both of which seem to work well:

1) bind-update-revert

2) unbind-pull-bind

Thanks again for the help; I'll be happy to help test the updated switch command when it's done.
-Dave

Revision history for this message
Robert Collins (lifeless) wrote : Re: [Bug 165215] Re: pull overwrite does not always find revisions after bind

On Mon, 2007-11-26 at 20:51 +0000, Dave Brueck wrote:
> Thanks for the replies guys.
>
> My original goal was to find out how to switch branches in place when
> using checkouts. Since 'bzr switch' doesn't support heavyweight
> checkouts yet,

AIUI in bzr.dev it does. You may need to uninstall bzrtools to get at
the bzr.dev switch.

-Rob
--
GPG key available at: <http://www.robertcollins.net/keys.txt>.

Revision history for this message
Alexander Belchenko (bialix) wrote : Re: [Bug 165215] Re: pull overwrite does not always find revisions after bind

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dave Brueck пишет:
> Thanks for the replies guys.
>
> My original goal was to find out how to switch branches in place when
> using checkouts. Since 'bzr switch' doesn't support heavyweight
> checkouts yet, I searched the mailing list and noticed Ian's effort to
> merge the switch command into bzr from bzrtools. I contacted him and had
> a short discussion and he suggested I try pull --overwrite, and that's
> when I ran into this problem and he asked that I file the bug.
>
>>From talking to Ian, heavyweight checkout support in the switch command
> is on the todo list, but I don't know where it fits in priority-wise
> with other stuff he's doing, so in the meantime it looks like you all
> have helped me come up with two alternatives, both of which seem to work
> well:
>
> 1) bind-update-revert
>
> 2) unbind-pull-bind

I'd like to note that second variant preferable if your working tree has uncommitted changes.
Firs variant is simpler to use, because you need to type bind location only once (in bind
command actually), but second variant is safer in regards of uncommitted changes.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHSza4zYr338mxwCURAsd1AJsGbxZ8zYJi92mJfZtvGOYBMFsgxACeO3CW
okfDW/ftQC17qxycUTQAQ+E=
=s+dG
-----END PGP SIGNATURE-----

Revision history for this message
Dave Brueck (dbrueck) wrote :

Rob, I think heavyweight checkout support in 'switch' isn't in there quite yet:

~/dev/work$ bzr switch $BZR/trunk/bug1234
bzr: ERROR: The switch command can only be used on a lightweight checkout.
Expected branch reference, found Bazaar Branch Format 6 (bzr 0.15) at file:///Users/dave/dev/work/

~/dev/work$ bzr version
Bazaar (bzr) 0.93.0.dev.0
  from bzr checkout /Users/dave/oss/bzr.dev
    revision: 3028
    revid: <email address hidden>
    branch nick: bzr.dev
  ...

I'll keep checking back though. Thanks!

Revision history for this message
Aaron Bentley (abentley) wrote : Re: [Bug 165215] Re: pull overwrite does not always find revisions after bind

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Robert Collins wrote:
> On Mon, 2007-11-26 at 20:51 +0000, Dave Brueck wrote:
>> Thanks for the replies guys.
>>
>> My original goal was to find out how to switch branches in place when
>> using checkouts. Since 'bzr switch' doesn't support heavyweight
>> checkouts yet,
>
> AIUI in bzr.dev it does.

No, Ian hasn't submitted that yet:

abentley@balrog:~/bzr$ bzr checkout --no-lightweight
~/bzrplugins/bzrtools foo
abentley@balrog:~/bzr$ cd foo
abentley@balrog:~/bzr/foo$ bzr switch ../bzr.dev
bzr: ERROR: The switch command can only be used on a lightweight checkout.
Expected branch reference, found Bazaar Branch Format 6 (bzr 0.15) at
file:///home/abentley/bzr/foo/

> You may need to uninstall bzrtools to get at
> the bzr.dev switch.

As of revno 588, bzrtools no longer includes switch, so you can upgrade
instead of uninstalling.

Aaron

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHS0fI0F+nu1YWqI0RAoHlAJ9B6NfJPtSXG5ZCr8qnkYiAngTHrwCfZ10s
7yauNzYhIBigUjrz851bSLY=
=YMYG
-----END PGP SIGNATURE-----

Revision history for this message
Martin Pool (mbp) wrote :

There is now a 'bzr switch' command in core.

Changed in bzr:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.