Merge lp:~vila/bzr/323111-orphan-config-option into lp:bzr
| Status: | Merged |
|---|---|
| Approved by: | Vincent Ladeuil on 2010-10-15 |
| Approved revision: | 5432 |
| Merged at revision: | 5504 |
| Proposed branch: | lp:~vila/bzr/323111-orphan-config-option |
| Merge into: | lp:bzr |
| Prerequisite: | lp:~vila/bzr/323111-deprecate-get-backup-name |
| Diff against target: |
588 lines (+275/-90) (has conflicts) 8 files modified
bzrlib/help_topics/en/conflict-types.txt (+63/-44) bzrlib/ignores.py (+1/-0) bzrlib/tests/per_workingtree/test_pull.py (+2/-0) bzrlib/tests/test_bzrdir.py (+3/-0) bzrlib/tests/test_transform.py (+59/-12) bzrlib/transform.py (+125/-25) doc/en/release-notes/bzr-2.3.txt (+13/-5) doc/en/whats-new/whats-new-in-2.3.txt (+9/-4) Text conflict in doc/en/whats-new/whats-new-in-2.3.txt |
| To merge this branch: | bzr merge lp:~vila/bzr/323111-orphan-config-option |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Martin Pool | 2010-09-16 | Needs Fixing on 2010-09-17 | |
|
Review via email:
|
|||
Commit Message
Provides a ``bzr.transform
Description of the Change
This introduces a ``bzrlib.
variable that control whether orphans are created or not during a
tree transform and how.
The accepted values are:
- never: The previous behaviour, no orphans are ever created
leaving the directory in a conflicted state that the user has
to resolve.
- always: The new behaviour, unversioned files are moved into a
``bzr-orphans`` directory at the root of the working tree. The
user is expected to look at the content and remove the
bzr-orphans directory (the orphans will accumulate otherwise).
There is now an ``orphaning_
is used to centralise the various ways to manage orphans and as
the source of valid values for the config variable.
The default value (``always``) is also the fallback if a bogus
value is provided (and a warning emitted in this case).
I made the factory accept a simple callable as requiring a
TreeTransform method would require using a getattr (since we will
have to use the name in the registry to get the bound method
later) for no good reasons. This also leave more room for exotic
implementations (as in alien to TreeTransform, requiring more
house-keeping, etc).
| Andrew Bennetts (spiv) wrote : | # |
Martin Pool wrote:
[...]
> I think the always/never distinction is not the right dimension though,
> because it seems to assume there is one thing that we want to have either on
> or off. But I think what we want is, well, actually different policies, which
> might include:
>
> * conflict: mark the directory conflicted and don't remove it
> * unversion: mark the containing directory unversioned, but leave it in the tree
> * move: move them to a bzr-orphans directory in the root of the tree
> * delete: just immediately delete them
This is a great way to put it, that's what I was thinking too.
For example, I'm imagining plugins adding support for:
orphans = vary_by_file_ext
orphan_policies = pyc:delete,*:move
(as a not very carefully designed strawman...)
Similarly, it would be lovely if support for 'precious' files could be done
initially by a plugin...
> > I made the factory accept a simple callable as requiring a TreeTransform method
>
> I think, generally, I'm against any interface taking a pure callable. (I was
> just regretting one I added myself in Launchpad feature flags.) So often it
> turns out that you also want to ask the thing passed in for a description of
> itself, or something like that. Passing an object with a well-known method
> name gives a bit more room to move.
See also our hook registration API, which asks for a description for its
callables :)
| Marius Kruger (amanica) wrote : | # |
On 17 September 2010 10:01, Andrew Bennetts For example, I'm imagining
plugins adding support for:
>
>
> orphans = vary_by_file_ext
> orphan_policies = pyc:delete,*:move
>
wouldn't it be more suitable to go in ~/.bazaar/rules then?
| Martin Pool (mbp) wrote : | # |
On 17 September 2010 18:01, Andrew Bennetts
<email address hidden> wrote:
> Martin Pool wrote:
> [...]
>> I think the always/never distinction is not the right dimension though,
>> because it seems to assume there is one thing that we want to have either on
>> or off. But I think what we want is, well, actually different policies, which
>> might include:
>>
>> * conflict: mark the directory conflicted and don't remove it
>> * unversion: mark the containing directory unversioned, but leave it in the tree
>> * move: move them to a bzr-orphans directory in the root of the tree
>> * delete: just immediately delete them
>
> This is a great way to put it, that's what I was thinking too.
>
> For example, I'm imagining plugins adding support for:
>
> orphans = vary_by_file_ext
> orphan_policies = pyc:delete,*:move
>
> (as a not very carefully designed strawman...)
Mm, or better I'd like to see the rules file group them in to classes
of 'precious', 'junk', etc, then perhaps different orphan policies
depending on class.
--
Martin
| Vincent Ladeuil (vila) wrote : | # |
>>>>> Martin Pool <email address hidden> writes:
<snip/>
> Mm, or better I'd like to see the rules file group them in to classes
> of 'precious', 'junk', etc, then perhaps different orphan policies
> depending on class.
That exactly what I feared, you're trying to fit precious/junk handling
into this bug fix which, while related, will not allow addressing the
whole problem.
I am *not* trying to handle precious files here not delete junk files,
I'm just putting unversioned file away when they block deleting a
directory.
That's only *one* aspect and people are suffering from this *today*.
| Vincent Ladeuil (vila) wrote : | # |
>>>>> Marius Kruger <email address hidden> writes:
> On 17 September 2010 10:01, Andrew Bennetts For example, I'm imagining
> plugins adding support for:
>>
>>
>> orphans = vary_by_file_ext
>> orphan_policies = pyc:delete,*:move
>>
> wouldn't it be more suitable to go in ~/.bazaar/rules then?
It would be even more suitable to mirror what is done for ignored files
(junk file, .bzrjunk files and so on) and modify all the commands that
should take care of that.
Then we can have:
- versioned files
- unversioned files
- junk
- the rest, which include precious files and maybe nothing else
But again, that vastly out-of-scope with this bugfix.
| Martin Pool (mbp) wrote : | # |
On 17 September 2010 22:37, Vincent Ladeuil <email address hidden> wrote:
>>>>>> Martin Pool <email address hidden> writes:
>
> <snip/>
>
> > Mm, or better I'd like to see the rules file group them in to classes
> > of 'precious', 'junk', etc, then perhaps different orphan policies
> > depending on class.
>
> That exactly what I feared, you're trying to fit precious/junk handling
> into this bug fix which, while related, will not allow addressing the
> whole problem.
>
> I am *not* trying to handle precious files here not delete junk files,
> I'm just putting unversioned file away when they block deleting a
> directory.
>
> That's only *one* aspect and people are suffering from this *today*.
Sorry, I didn't mean to imply this is part of this bug, it was a
discussion of follow-on changes. I think you are quite right to
change just this before bringing in a junk category. However, I do
think you should change the option values.
--
Martin
| Vincent Ladeuil (vila) wrote : | # |
Forwarding to <email address hidden> to get a larger feedback.
>>>>> Martin Pool <email address hidden> writes:
> On 17 September 2010 22:37, Vincent Ladeuil <email address hidden> wrote:
>>>>>>> Martin Pool <email address hidden> writes:
>>
>> <snip/>
>>
>> > Mm, or better I'd like to see the rules file group them in to classes
>> > of 'precious', 'junk', etc, then perhaps different orphan policies
>> > depending on class.
>>
>> That exactly what I feared, you're trying to fit precious/junk handling
>> into this bug fix which, while related, will not allow addressing the
>> whole problem.
>>
>> I am *not* trying to handle precious files here not delete junk files,
>> I'm just putting unversioned file away when they block deleting a
>> directory.
>>
>> That's only *one* aspect and people are suffering from this *today*.
> Sorry, I didn't mean to imply this is part of this bug, it was a
> discussion of follow-on changes.
Ha ok, right, I completely misunderstood then.
> I think you are quite right to change just this before bringing in
> a junk category. However, I do think you should change the option
> values.
So, for this submission, and trying to take all applicable remarks into
account, I will:
- rename 'always' to 'move'
- rename 'never' to 'conflict'
- add 'bzr-orphans' to the default ignore list
- delay turning callables into full-fledged ones until the impact of the
junk/repcious files handling make it clearer what this fix is really
suppposed to provide (I kind of suspect it won't have to make a
decision anymore if the unversioned files are handled higher in the
stack).
and:
- make 'conflict' the default, so people impacted by this bug can turn
it to 'move' and all the other will remained un-impacted until the
follow-on changes are implemented properly.
For the follow-on changes, we need a bit more analysis to:
- check which commands should now take the junk files into account (at
least pull/merge/switch should delete them even before the orphaning
triggered, clean-tree should handle them appropriately, but they may
be other. Thoughts ?)
- discuss a bit more what a 'precious' file is.
I'm not clear about what a precious but *unversioned* file is... either
it's really precious and it's versioned or it can be generated but I
dont quite see why it should be called precious then or... what ?
What kind of file should bzr never delete, yet, don't handle (or even
ignore) ? A project settings file ? But in this case such a file
shouldn't be in a directory that don't exist anymore for a given tree
revision no ?
Vincent
- 5427. By Vincent Ladeuil on 2010-09-21
-
Merge deprecate-
get-backup- name into orphan- config- option - 5428. By Vincent Ladeuil on 2010-09-21
-
Move NEWS entry to 2.3b2
- 5429. By Vincent Ladeuil on 2010-09-21
-
Revert to 'conflict' being the default orphaning policy and fix fallouts.
- 5430. By Vincent Ladeuil on 2010-09-22
-
Add 'bzr-orphans' to USER_DEFAULTS in bzrlib/ignores.py.
| Martin Pool (mbp) wrote : | # |
On 22 September 2010 18:57, Vincent Ladeuil <email address hidden> wrote:
> What kind of file should bzr never delete, yet, don't handle (or even
> ignore) ? A project settings file ? But in this case such a file
> shouldn't be in a directory that don't exist anymore for a given tree
> revision no ?
Let's talk about it on the list?
I could guess:
* project settings
* build products that are super expensive to produce
* per-tree configuration (similar things seem to come up a lot from
people running apps within a source tree)
* for that matter the database produced by a running app
--
Martin
| Vincent Ladeuil (vila) wrote : | # |
> On 22 September 2010 18:57, Vincent Ladeuil <email address hidden> wrote:
>
> > What kind of file should bzr never delete, yet, don't handle (or even
> > ignore) ? A project settings file ? But in this case such a file
> > shouldn't be in a directory that don't exist anymore for a given tree
> > revision no ?
>
> Let's talk about it on the list?
>
> I could guess:
> * project settings
> * build products that are super expensive to produce
> * per-tree configuration (similar things seem to come up a lot from
> people running apps within a source tree)
> * for that matter the database produced by a running app
Clear enough for me, thanks. This hints at 'precious' being clearly: unversioned but not junk.
| Vincent Ladeuil (vila) wrote : | # |
Hmm, someone mentioned an interesting twist: when switching a tree from one branch to another, you want *some* precious files to follow and *some* other to stay:
<zyga_> vila, I just noticed bzr switch-pipe does not store local changes
<zyga_> vila, perhaps the version I'm using is not compatible with bzr (on 10.10)
<vila> zyga_: by store local changes you mean shelve ?
<vila> zyga_: keeping uncommitted changes in the working tree while switching is a feature, I often need to commit code I just wrote while not being in the "right" thread (or pipe)
<zyga> vila, no I mean bzr switch-pipeline
<zyga> vila, I found the issue
<zyga> vila, bzr-pipeline is _fantastic_
<zyga> vila, the issue was, untracked files are _not_ stored/restored by the pipeline
<zyga> vila, so if you add a new file and start hacking on it (but not bzr add it) it will not be hidden by bzr switch-pipeline
<vila> zyga: that's a bzr issue then, there are still unversioned files that you want to keep with you (even if there are unversioned files that you want to hide)
<vila> zyga: examples at https:/
<vila> zyga: comments or bugs with your use case welcome
| Martin Pool (mbp) wrote : | # |
On 4 October 2010 21:53, Vincent Ladeuil <email address hidden> wrote:
> Hmm, someone mentioned an interesting twist: when switching a tree from one branch to another, you want *some* precious files to follow and *some* other to stay:
Well, the obvious answer there is that he should add but not commit
them, and then they'll dtrt.
Perhaps user feedback comments would be better kept on a bug than
here... (but here's better than nowhere.)
--
Martin
| Martin Pool (mbp) wrote : | # |
> orhaning
typo
Perhaps there should be user docs for this?
The NEWS entry ought to explain what an orphan is
+orphaning_registry = registry.Registry()
+orphaning_
+ 'Never create orphans.')
+orphaning_
+ 'Move orphans into the bzr-orphans directory.')
+orphaning_
I think in explaining 'conflict' it's not so much never create them - the transform situtation forces the existence of orphans. Rather, we'll leave them in place and mark the directory conflicted.
def new_orphan(self, trans_id, parent_id):
- """See TreeTransformBa
- # Add the orphan dir if it doesn't exist
- orphan_dir = 'bzr-orphans'
- od_id = self.trans_
- if self.final_
- self.create_
- parent_path = self._tree_
- # Find a name that doesn't exist yet in the orphan dir
- actual_name = self.final_
- new_name = self._available
- self.adjust_
- trace.warning('%s has been orphaned in %s'
- % (joinpath(
+ # FIXME: There is no tree config, so we use the branch one (it's weird
+ # to define it this way as orphaning can only occur in a working tree,
+ # but that's all we have (for now). It will find the option in
+ # locations,conf or bazaar.conf though) -- vila 20100916
+ conf = self._tree.
+ conf_var_name = 'bzrlib.
+ orphan_policy = conf.get_
+ default_policy = orphaning_
+ if orphan_policy is None:
+ orphan_policy = default_policy
+ if orphan_policy not in orphaning_registry:
+ trace.warning('%s (from %s) is not a known policy, defaulting to %s'
+ % (orphan_policy, conf_var_name, default_policy))
+ orphan_policy = default_policy
+ handle_orphan = orphaning_
+ handle_orphan(self, trans_id, parent_id)
+
You have a comma in 'locations,conf'.
Won't checking this here mean that you get one warning per orphaned file? Perhaps not necessarily a big deal but it suggests you should check this somewhere earlier, and then hold onto the handler?
otherwise I think this is ok. Perhaps we should file some followon bugs.
I might like a 'just kill them' policy.
- 5431. By Vincent Ladeuil on 2010-10-15
-
Merge deprecate-
get-backup- name into orphan- config- option resolving conflicts - 5432. By Vincent Ladeuil on 2010-10-15
-
Add more doc and fix rst typos
- 5433. By Vincent Ladeuil on 2010-10-15
-
Rename bzrlib.
transform. orphan_ policy to bzr.transform. orphan_ policy.
| Vincent Ladeuil (vila) wrote : | # |
> Perhaps there should be user docs for this?
Added in bzrlib/
>
> The NEWS entry ought to explain what an orphan is
Done
>
> +orphaning_registry = registry.Registry()
> +orphaning_
> + 'Never create orphans.')
> +orphaning_
> + 'Move orphans into the bzr-orphans directory.')
> +orphaning_
>
> I think in explaining 'conflict' it's not so much never create them - the
> transform situtation forces the existence of orphans. Rather, we'll leave
> them in place and mark the directory conflicted.
Fixed.
> You have a comma in 'locations,conf'.
Fixed.
>
> Won't checking this here mean that you get one warning per orphaned file?
Yes, but only if the user set a wrong value so I think it's ok.
> Perhaps not necessarily a big deal but it suggests you should check this
> somewhere earlier, and then hold onto the handler?
That would be overkill just avoid multiple valid warnings that the user should fixed.
>
> otherwise I think this is ok. Perhaps we should file some followon bugs.
>
I think we have some for junk/precious handling no ?
> I might like a 'just kill them' policy.
That's what junk file handling should render useless.
I'll land with the fixes mentioned above.
- 5434. By Vincent Ladeuil on 2010-10-15
-
Better docs.
| Vincent Ladeuil (vila) wrote : | # |
sent to pqm by email

You should add something to the user guide: aside from being needed, reading how we describe it to users will help us know if we've got it right. Starting from the text for whatsnew will be ok.
I think the always/never distinction is not the right dimension though, because it seems to assume there is one thing that we want to have either on or off. But I think what we want is, well, actually different policies, which might include:
* conflict: mark the directory conflicted and don't remove it
* unversion: mark the containing directory unversioned, but leave it in the tree
* move: move them to a bzr-orphans directory in the root of the tree
* delete: just immediately delete them
> I made the factory accept a simple callable as requiring a TreeTransform method
I think, generally, I'm against any interface taking a pure callable. (I was just regretting one I added myself in Launchpad feature flags.) So often it turns out that you also want to ask the thing passed in for a description of itself, or something like that. Passing an object with a well-known method name gives a bit more room to move.
I agree it shouldn't be bound to treetransform details.
188 + # FIXME: There is no tree config, so we use the branch one (it's weird branch. get_config( )
189 + # to define it this way as orphaning can only occur in a working tree,
190 + # but that's all we have (for now). It will find the option in
191 + # locations,conf or bazaar.conf though) -- vila 20100916
192 + conf = self._tree.
Perhaps there should be a bug for that.