url lookups should be able to use the same heuristic switch does

Bug #243386 reported by Robert Collins
4
Affects Status Importance Assigned to Milestone
Bazaar
Confirmed
Wishlist
Unassigned

Bug Description

bzr init left && bzr commit left -m foo --unchanged
bzr branch left right
bzr commit right --unchanged -m bar
bzr checkout --lightweight right working
cd working
bzr switch left # finds ../left
bzr merge right # finds '.' and errors ('nothing to do')

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

Revision history for this message
Aaron Bentley (abentley) wrote : Re: [Bug 243386] [NEW] url lookups should be able to use the same heuristic switch does

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

Robert Collins wrote:
> Public bug reported:
>
> bzr init left && bzr commit left -m foo --unchanged
> bzr branch left right
> bzr commit right --unchanged -m bar
> bzr checkout --lightweight right working
> cd working
> bzr switch left # finds ../left
> bzr merge right # finds '.' and errors ('nothing to do')

So if you have a branch named "down" in a subdirectory, "bzr merge down"
wouldn't work. Would we do "bzr merge ./down" for that?

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

iD8DBQFIZPpD0F+nu1YWqI0RAopIAJ0eV6lahgdd3D8BzfRoVSsEkq0z3QCfQuRs
hprH6ImAysXl94k4cgKie94=
=tsZM
-----END PGP SIGNATURE-----

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

Well, 'bzr switch' is a bit different than "merge" in that it doesn't allow you to give the path to a subdirectory of a branch.
So it first tries the path as a relative path, and if it doesn't find anything, it falls back to relative to the current "other" branch.

So, for example:

 bzr switch foo

Is './foo' a branch, if so, switch to that
elif cur_target + '../foo' is a branch, switch to that
else fail

'bzr merge' is going to have a harder time, because it has to say:

if './foo' is a branch, use that
elif './foo' is an existing file inside a containing tree, use the containing tree
elif cur_target + '../foo' is a branch, switch to that
elif cur_target + '../foo' is a file inside of a containing tree # we could probably ignore this one
else fail

However, this seems fairly easy to extract into a helper function. The next problem is to know exactly when it would be active. Only in a checkout, all the time, etc.

John A Meinel (jameinel)
Changed in bzr:
importance: Undecided → Wishlist
status: New → Triaged
Revision history for this message
Robert Collins (lifeless) wrote : Re: [Bug 243386] [NEW] url lookups should be able to use the same heuristic switch does

On Fri, 2008-06-27 at 14:33 +0000, Aaron Bentley wrote:

> So if you have a branch named "down" in a subdirectory, "bzr merge down"
> wouldn't work. Would we do "bzr merge ./down" for that?

So given three trees:
.
./down
../down

what should 'bzr merge down' do - should it grab ./down or ../down? I
think that ./down is going to be a nested branch - either that or its a
very rare layout. So grabbing ../down is actually more appropriate than
the current behaviour of grabbing down as we do today. But we could
think of this as a search path:
find_branch_heuristic(branch, branchname)
  if is_abs(branchname):
    # probe directly
  else:
    for prefix in lookup_locations(branch):
      # probe for prefix + '/' + branchname
      # and then ...
      if branchname != '.' and found_branch.base == branch.base:
          continue

If we chose to look in ['.', branch.base + '..'] we'd fine ./down
before ../down, still find ../down if there was no ./down that is a
branch.

-Rob

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

Martin Pool (mbp)
Changed in bzr:
status: Triaged → Confirmed
Jelmer Vernooij (jelmer)
tags: added: check-for-breezy
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.