Merge lp:~vila/bzr/323111-backup-names into lp:bzr
| Status: | Merged |
|---|---|
| Merged at revision: | 5504 |
| Proposed branch: | lp:~vila/bzr/323111-backup-names |
| Merge into: | lp:bzr |
| Diff against target: |
301 lines (+109/-34) 10 files modified
bzrlib/bzrdir.py (+16/-13) bzrlib/osutils.py (+20/-0) bzrlib/tests/per_workingtree/__init__.py (+8/-0) bzrlib/tests/per_workingtree/test_merge_from_branch.py (+0/-8) bzrlib/tests/test_bzrdir.py (+11/-2) bzrlib/tests/test_osutils.py (+31/-0) bzrlib/tests/test_transform.py (+15/-8) bzrlib/transform.py (+1/-1) bzrlib/workingtree.py (+3/-2) doc/en/release-notes/bzr-2.3.txt (+4/-0) |
| To merge this branch: | bzr merge lp:~vila/bzr/323111-backup-names |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Martin Pool | Approve on 2010-10-13 | ||
| Andrew Bennetts | 2010-09-10 | Needs Fixing on 2010-09-16 | |
|
Review via email:
|
|||
Description of the Change
This introduces a new ``osutils.
to produce <file>.~#~ paths where we need them.
With my next submissions there will be 3 such use cases, enough
to triangulate: they are all protected by a lock so we don't have
to care about race conditions.
The case at hand is ``BzrDir.
future we may try to avoid LBYL, but that's out-of-scope for this
submissions and the following ones (and I don't think we really
care here and I'm sure we don't for the 2 other cases (1 in
memory, the other on local fs).
I changed the name from 'generate' to 'available' as I felt it
was better describing: nothing is created but a check is
performed (and this fit well for the other cases too).
| Vincent Ladeuil (vila) wrote : | # |
| Andrew Bennetts (spiv) wrote : | # |
Regarding jam's comments: we aren't consistent about whether leading underscores indicates private to bzrlib, private to that module, or even private to that class. So you have to look at stuff case-by-case in my experience (unless the code somehow makes it clear via comments/
In this case workingtree.py already calls self._bzrdir.
A related issue is that _available_
in test_transform:
240 + # Since the directory doesn't exist it's seen as missing to resolve
241 + # create a conflict asking for it to be created.
That comment doesn't parse for me, and I don't understand how the test_transform changes are related to the rest of the patch.
So:
* +1 on refactoring to create the function in osutils
* I'm unconvinced on the change to BzrDir's API. I'm open to be convinced, but first I need to understand the intent of changing it :)
* I don't understand the comment in the test_transform change. It's small enough that I don't mind too much that it appears to be mixed into an unrelated patch, but the comment does need to make sense.
| Vincent Ladeuil (vila) wrote : | # |
>>>>> Andrew Bennetts <email address hidden> writes:
> Review: Needs Fixing
> Regarding jam's comments: we aren't consistent about whether
> leading underscores indicates private to bzrlib, private to that
> module, or even private to that class. So you have to look at
> stuff case-by-case in my experience (unless the code somehow makes
> it clear via comments/
> In this case workingtree.py already calls
> self._bzrdir.
> precedent...
> but it seems odd to me to make it private, because presumably if
> it's a useful method on bzrdir (and it must be, you're using it),
> then couldn't 3rd-party code like plugins have a use for it too?
I don't know.
That's why I make private :)
Th rationale is that maintaining compatibility is guaranteed for the
public methods. Despite this, plugin authors use private methods.
It seems more adequate then to drive the maintenance effort based on
real use cases rather than 'potential' use cases.
Since I couldn't see *obvious* cases where bzrdir.
can be used, I made it private (moreover, as jam pointed out, it may be
better located on wt instead but I wanted to limit my cleanups to the
code duplication and added the deprecations as I felt things weren't
that clear in this area so going private will help in the future if we
need to change).
The only bits I thought were worth publicizing were the backup name
policy, so I put that in osutils for lack of a better place (osutils
(as a module) must die ! (and become a package ;)).
> After all the method you are deprecating,
> BzrDir.
> for that (perhaps not, but it's worth asking)?
It has been recently introduced and duplicated the existing code in
transform, see
https:/
which use 'get_backup_name' instead of 'generate_
> Given that the behaviour appears to be exactly the same what's the
> purpose of changing the method name here?
Hinting at the race condition which wasn't clear with 'generate' (or
get_backup_name in transform, see following submissions) and make it a
method.
I thought I explained that in the cover letter:
,----
| With my next submissions there will be 3 such use cases, enough
| to triangulate: they are all protected by a lock so we don't have
| to care about race conditions.
|
| The case at hand is ``BzrDir.
| future we may try to avoid LBYL, but that's out-of-scope for this
| submissions and the following ones (and I don't think we really
| care here and I'm sure we don't for the 2 other cases (1 in
| memory, the other on local fs).
|
| I changed the name from 'generate' to 'available' as I felt it
| was better describing: nothing is created but a check is
| performed (and this fit well for the other cases too).
`----
> Is it that you consider generate_
> shouldn't be used?
Well 'generate_
misleading, hopefully '...
- 5418. By Vincent Ladeuil on 2010-09-16
-
Merge cleanup into backup-names
- 5419. By Vincent Ladeuil on 2010-09-16
-
Be more explicit about race conditions and LBYL being discouraged
- 5420. By Vincent Ladeuil on 2010-09-21
-
Merge cleanup into backup-names
- 5421. By Vincent Ladeuil on 2010-09-21
-
Move NEWS entry to 2.3b2
| Vincent Ladeuil (vila) wrote : | # |
Updated, please review.
| Martin Pool (mbp) wrote : | # |
It looks basically OK to me; I'll let Andrew check if you've sufficiently addressed his points.
- 5422. By Vincent Ladeuil on 2010-10-15
-
Merge cleanup into backup-names resolving conflicts

>>>>> John Arbash Meinel <email address hidden> writes:
> On 9/10/2010 9:40 AM, Vincent Ladeuil wrote: conflicts_ missing_ parent( self):
>> + def test_resolve_
> The available_ backup_ name seems ok. I'm not a big fan of 'transport.has' you-leap in general, but we were already doing it.
> or the look-before-
> I don't really understand what this is doing here, though: conflicts_ missing_ parent( self):
> + def test_resolve_
> It seems unrelated. Also why remove: no_parent( self):
> - def test_resolve_
I've replaced it by test_resolve_ conflicts_ missing_ parent clarifying it
while I was there.
> === modified file 'bzrlib/ workingtree. py' workingtree. py 2010-08-20 19:07:17 +0000 workingtree. py 2010-09-10 14:39:52 +0000 backup. append( path[1] )
> --- bzrlib/
> +++ bzrlib/
> @@ -2078,9 +2078,10 @@
> files_to_
> def backup( file_to_ backup) : generate_ backup_ name(file_ to_backup) _available_ backup_ name(file_ to_backup)
> - backup_name =
> self.bzrdir.
> + backup_name =
> self.bzrdir.
> ^- IMO: WorkingTree shouldn't be calling an '_' method on BzrDir,
Wow, we do that a lot already, what's the problem ?
The public methods or attributes are for bzrlib users while the private
ones are for bzrlib internal needs, we never say this applies to inter
class calls.
> so we should probably be making it public.
IMHO, methods should be public if there is a need for them outside of
bzrlib and we guarantee some stability and backward compatibility.
If there is no need, the maintenance cost is lowered.
> Then again, why is *BzrDir* finding the available name, and not
> working tree itself?
Well, I just touched this method lightly, I didn't research the
rationale in the corresponding merge proposal.