Merge lp://staging/~vila/bzr/646961-attr-error into lp://staging/bzr/2.2

Proposed by Vincent Ladeuil
Status: Merged
Approved by: Vincent Ladeuil
Approved revision: no longer in the source branch.
Merged at revision: 5108
Proposed branch: lp://staging/~vila/bzr/646961-attr-error
Merge into: lp://staging/bzr/2.2
Diff against target: 171 lines (+67/-14)
5 files modified
NEWS (+4/-0)
bzrlib/conflicts.py (+3/-4)
bzrlib/tests/blackbox/test_conflicts.py (+45/-0)
bzrlib/tests/test_workingtree.py (+7/-7)
bzrlib/transform.py (+8/-3)
To merge this branch: bzr merge lp://staging/~vila/bzr/646961-attr-error
Reviewer Review Type Date Requested Status
Andrew Bennetts Needs Fixing
Review via email: mp+39852@code.staging.launchpad.net

Commit message

Properly refuse to obey --take-this and --take-other for text conflicts.

Description of the change

The root cause of bug #646961 is that --take-this and
--take-other are not implemented for text conflicts (and the
reason for this is that users may be misunderstanding the
feature, see
http://wiki.bazaar.canonical.com/VincentLadeuil/ConflictResolution
for details).

This patch fixes the most urgent issue targeted to 2.2 without
adding a new feature (since 2.2 is stable) by fixing several
issues (whack-a-mole entertainment ahead):

- the TextConflict class was inheriting from PathConflict instead
  of Conflict. There was a FIXME about that but I didn't realize
  at the time that this was inheriting action_take_this and
  action_take_other and doing so, pretending to implement
  --take-this and --take-other leading to the bug,

- the _duplicate_entries conflict detection was trying to take
  deleted files into account which makes no sense since they
  don't have a name anymore (while the code path shouldn't have
  been triggered, this is worth fixing anyway).

The TextConflict doesn't inherit from PathConflict anymore which
makes the test complete without resolving the conflict at
all. It's unfortunate that we succeed silently here but fixing
that is out of scope as it's related to several other bugs.
The added test will fail when --take-other is implemented.

To post a comment you must log in.
Revision history for this message
Andrew Bennetts (spiv) wrote :

I have some tweak requests, so:

 review needs-fixing

But basically this looks like a good incremental improvement, thanks!

Details follow.

Vincent Ladeuil wrote:
[...]
> The TextConflict doesn't inherit from PathConflict anymore which
> makes the test complete without resolving the conflict at
> all. It's unfortunate that we succeed silently here but fixing
> that is out of scope as it's related to several other bugs.
> The added test will fail when --take-other is implemented.

That's a shame, but at least it's an improvement over crashing.

How hard is it to emit a warning that not all conflicts were resolved?

> --
> https://code.launchpad.net/~vila/bzr/646961-attr-error/+merge/39852
> Your team bzr-core is requested to review the proposed merge of lp:~vila/bzr/646961-attr-error into lp:bzr/2.2.

> === modified file 'NEWS'
> --- NEWS 2010-10-30 06:59:55 +0000
> +++ NEWS 2010-11-02 14:35:59 +0000
> @@ -19,6 +19,9 @@
> Bug Fixes
> *********
>
> +* ``bzr resolve --take--other <file>`` will not crash anymore if ``<file>`` is
> + involved in a text conflict. (Vincent Ladeuil, #646961)

Typo: should be “--take-other” (three hyphens, not four).

If I understand the cover letter correctly, in this scenario
--take-other still won't resolve the conflict. It might be worth saying
so in the NEWS entry.

[...]
> +++ bzrlib/conflicts.py 2010-11-02 14:35:59 +0000
> @@ -600,12 +600,9 @@
> self._resolve_with_cleanups(tree, 'THIS')
>
>
> -# FIXME: TextConflict is about a single file-id, there never is a conflict_path
> -# attribute so we shouldn't inherit from PathConflict but simply from Conflict
> -
> # TODO: There should be a base revid attribute to better inform the user about
> # how the conflicts were generated.
> -class TextConflict(PathConflict):
> +class TextConflict(Conflict):

Sounds good. Does this mean that PathConflict.as_stanza no longer needs this
logic:

        if self.conflict_path is not None:
            s.add('conflict_path', self.conflict_path)

?

> === modified file 'bzrlib/tests/blackbox/test_conflicts.py'
[...]
> +class TestResolveSilentlyIgnore(script.TestCaseWithTransportAndScript):
> +
> + def test_bug_646961(self):
[...]
> + # The following wil fail when --take-other is implemented
> + # for text conflicts

Shouldn't this test be a KnownFailure, then?

-Andrew.

review: Needs Fixing
Revision history for this message
Vincent Ladeuil (vila) wrote :

>>>>> Andrew Bennetts <email address hidden> writes:

<snip/>

    > How hard is it to emit a warning that not all conflicts were
    > resolved?

Tedious more than hard, there is a code path that already mentions how
many conflicts were resolved :-/

This is certainly a feature worth generalizing, but it's not trivial
(yet).

Something like 'n conflicts resolved, m remaining conflicts' can be
added to the other code path. I'll look into adding it to a further
submission against trunk.

<snip/>

    > Typo: should be “--take-other” (three hyphens, not four).

Fixed.

    > If I understand the cover letter correctly, in this scenario
    > --take-other still won't resolve the conflict. It might be worth saying
    > so in the NEWS entry.

You're right, this is *still* not resolving the conflict but at least
two users missed this fact, so it's time to implement it but worth
reminding the lack of the feature in the NEWS.

<snip/>

    > Sounds good. Does this mean that PathConflict.as_stanza no longer needs this
    > logic:

    > if self.conflict_path is not None:
    > s.add('conflict_path', self.conflict_path)

    > ?

Probably, I have a note about it, I'll add tests to ensure this is true
in my next proposal.

    >> === modified file 'bzrlib/tests/blackbox/test_conflicts.py'
    > [...]
    >> +class TestResolveSilentlyIgnore(script.TestCaseWithTransportAndScript):
    >> +
    >> + def test_bug_646961(self):
    > [...]
    >> + # The following wil fail when --take-other is implemented
    >> + # for text conflicts

    > Shouldn't this test be a KnownFailure, then?

Well, I used a script test because 1) the bug reporter had written in a
way that I could reuse with only little tweaks 2) to help track the bug by
reproducing it and ensure my patch was fixing it.

But I plan to get rid of it in the next submission so all I wanted was a
guarantee that it will fail once the feature is implemented and the
conflict resolved. So trying to inject a KnownFailure there sounded less
interesting than documenting that the conflict wasn't resolved.

Thanks for the prompt review !

Revision history for this message
Vincent Ladeuil (vila) wrote :

So, I will consider that some tweaks being addressed I can land this for 2.2 and will follow-up with a submission against *trunk* for the others (report conflicts resolved and as_stanza).

I'll make yet another submission to *implement* --take-this/--take-other for text conflicts (but I'd like to also add --prefer-this/--prefer-other/--take-both for that and it's a bit more work).

Revision history for this message
Vincent Ladeuil (vila) wrote :

sent to pqm by email

Revision history for this message
Vincent Ladeuil (vila) wrote :

sent to pqm by email

Revision history for this message
Vincent Ladeuil (vila) wrote :

sent to pqm by email

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches