Merge lp:~chy-causer/bzr-bookmarks/short-form into lp:bzr-bookmarks

Proposed by ChrisCauser
Status: Work in progress
Proposed branch: lp:~chy-causer/bzr-bookmarks/short-form
Merge into: lp:bzr-bookmarks
Diff against target: 11 lines (+3/-0)
1 file modified
__init__.py (+3/-0)
To merge this branch: bzr merge lp:~chy-causer/bzr-bookmarks/short-form
Reviewer Review Type Date Requested Status
Jelmer Vernooij (community) Needs Fixing
Review via email: mp+73352@code.launchpad.net

Description of the change

This is a very small change that I find useful. Basically if I issue the command,

$ bzr bookmark wibble .

I expect the bookmark wibble to refer to the branch at $PWD at the time of inserting the bookmark, rather than at the time of dereferencing it.

Like before, the plugin makes no check for the presence of a branch at the location, but I think this new behaviour is more intuitive and useful to others.

This will not do anything for people who have already bookmarked "." or for example "../../trunk", although it may be potentially confusing if they bookmark something again in future expecting the same result (which incidentally, in the case of the latter example is a silly usecase because the dereferencing command would have to be given in the same directory as when the bookmark insertion was made.) I'm not sure what to do about that.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Hi Chris,

Rather than doing this in just one of the backends, I think this should be handled by the caller of .set_location.

review: Needs Fixing
Revision history for this message
ChrisCauser (chy-causer) wrote :

> Rather than doing this in just one of the backends, I think this should be
> handled by the caller of .set_location.

I am happy to do this, but I fear that a backward-incompatible change like this may not sit well with other plugins, although I can't say that with any authority. What's your take on it? Should it be passed as an option, for example .set_location(..., make_absolute=True)?

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

On 31/08/11 18:15, ChrisCauser wrote:
>> Rather than doing this in just one of the backends, I think this should be
>> handled by the caller of .set_location.
> I am happy to do this, but I fear that a backward-incompatible change like this may not sit well with other plugins, although I can't say that with any authority. What's your take on it? Should it be passed as an option, for example .set_location(..., make_absolute=True)?
bzr-bookmarks is the only plugin that writes to that location so I don't
think there is a problem with writing an absolete location now. Can you
think of reasons why users might not want an absolute location there?

I do wonder if rather than *storing* a absolute location if it would
make sense to always interpret locations relative to the URL of the path
against which they're set.

Cheers,

Jelmer

21. By Chris Causer <email address hidden>

Update last commit so that absolute urls are stored for branch configs as well as global

Revision history for this message
ChrisCauser (chy-causer) wrote :

> bzr-bookmarks is the only plugin that writes to that location so I don't
> think there is a problem with writing an absolete location now. Can you
> think of reasons why users might not want an absolute location there?

Sorry, I'm going to have to rewind here. I thought set_location was part of bzrlib core but I've just realized that it doesn't exist. What function are we talking about here? Is it cmd_bookmark.run? If so I've just made another commit reflecting that.

>
> I do wonder if rather than *storing* a absolute location if it would
> make sense to always interpret locations relative to the URL of the path
> against which they're set.
>
Interesting. This would involve storing both the bookmark and the place where the bookmark was set. This might allow bookmarks to be cloned with a repository clone, although the number of people requiring that functionality would be pretty small, and I'm sure people coming back to this plugin in years' time would think "now why did they do that?" !

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Hi Chris,

On 01/09/11 10:39, ChrisCauser wrote:
>> bzr-bookmarks is the only plugin that writes to that location so I don't
>> think there is a problem with writing an absolete location now. Can you
>> think of reasons why users might not want an absolute location there?
> Sorry, I'm going to have to rewind here. I thought set_location was part of bzrlib core but I've just realized that it doesn't exist. What function are we talking about here? Is it cmd_bookmark.run? If so I've just made another commit reflecting that.
Yeah, cmd_bookmark.run.
>> I do wonder if rather than *storing* a absolute location if it would
>> make sense to always interpret locations relative to the URL of the path
>> against which they're set.
>>
> Interesting. This would involve storing both the bookmark and the place where the bookmark was set. This might allow bookmarks to be cloned with a repository clone, although the number of people requiring that functionality would be pretty small, and I'm sure people coming back to this plugin in years' time would think "now why did they do that?" !
>
Aren't some of the bookmarks set in the repository itself rather than in
the global configuration? I'm not very familiar with the bookmarks
plugin. If there is just the global configuration, then I think
defaulting to absolute paths always makes sense.

Cheers,

Jelmer

Revision history for this message
ChrisCauser (chy-causer) wrote :

> Hi Chris,
> Aren't some of the bookmarks set in the repository itself rather than in
> the global configuration? I'm not very familiar with the bookmarks
> plugin. If there is just the global configuration, then I think
> defaulting to absolute paths always makes sense.

Yes, you are correct that bookmarks can be both repo and global in scope. Hopefully this new diff saves the absolute path for both cases. People who have already saved bookmarks will notice no change in functionality until they create a new bookmark.

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

On 06/09/11 17:32, ChrisCauser wrote:
>> Hi Chris,
>> Aren't some of the bookmarks set in the repository itself rather than in
>> the global configuration? I'm not very familiar with the bookmarks
>> plugin. If there is just the global configuration, then I think
>> defaulting to absolute paths always makes sense.
> Yes, you are correct that bookmarks can be both repo and global in scope. Hopefully this new diff saves the absolute path for both cases. People who have already saved bookmarks will notice no change in functionality until they create a new bookmark.
Hmm, interesting. I don't really want to bikeshed about this, but I
wonder if we should do the following:

For per-repo bookmarks, allow relative paths and absolute paths and
resolve those paths relative to the repository path.

For global bookmarks, allow only absolute paths, and always store
absolute paths.

Does that make sense?

Cheers,

Jelmer

Revision history for this message
ChrisCauser (chy-causer) wrote :

On 06/09/11 20:21, Jelmer Vernooij wrote:
> Does that make sense?
Yup, perfect sense. I'll update the merge proposal when I've done that.

Unmerged revisions

21. By Chris Causer <email address hidden>

Update last commit so that absolute urls are stored for branch configs as well as global

20. By Chris Causer <email address hidden>

Absolute paths are generated from relative ones

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '__init__.py'
2--- __init__.py 2011-02-04 11:40:36 +0000
3+++ __init__.py 2011-09-01 08:36:25 +0000
4@@ -197,6 +197,9 @@
5 if not location:
6 raise errors.BzrCommandError(
7 'no location provided for bookmark "%s"' % (name,))
8+ if location.startswith('.'):
9+ import os.path
10+ location = os.path.abspath(location)
11 provider.set_bookmark(name, location)
12
13

Subscribers

People subscribed via source and target branches

to all changes: