Diffs "upside-down"

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Diffs "upside-down"

Tony Garnock-Jones-5
Does it bother anyone else that Squeak prints diffs

 +this line was added
 -this line was removed

while Unix-derived tools (including those influenced by Unix, like
Github) print

 -this line was removed
 +this line was added

?

For a project of mine I added the following to rearrange things more
conventionally:

    diff: diff doIfMatch: matchBlock ifInsert: insertBlock ifRemove:
removeBlock
        "Like TextDiffBuilder >>
        patchSequenceDoIfMatch:ifInsert:ifRemove:, but with
        insertions/removals in the other order (matching what lots of
        Unix-heritage diff-generation tools do)."

        | pending flush |
        pending := OrderedCollection new.
        flush := [
            pending do: insertBlock.
            pending removeAll].

        diff patchSequenceDoIfMatch: [:line | flush value. matchBlock
value: line]
            ifInsert: [:line | pending add: line]
            ifRemove: removeBlock.

        flush value.

... where `diff` is an instance of TextDiffBuilder.

Tony

Reply | Threaded
Open this post in threaded view
|

Re: Diffs "upside-down"

Tobias Pape


> On 9. Nov 2020, at 15:46, Tony Garnock-Jones <[hidden email]> wrote:
>
> Does it bother anyone else that Squeak prints diffs
>
> +this line was added
> -this line was removed
>
> while Unix-derived tools (including those influenced by Unix, like
> Github) print
>
> -this line was removed
> +this line was added
>
> ?

D'oh!
That explains my constant confusion!

-t

Reply | Threaded
Open this post in threaded view
|

Re: Diffs "upside-down"

Christoph Thiede

Well, personally I have always been used the "+ before -" way, so if you change it, I'll need to adapt. :P

One *could* also argue that the new additions are more relevant than the old removals, so they should appear first in an email or anywhere else.
But, it might be a very subjective question ...

Best,
Christoph

Von: Squeak-dev <[hidden email]> im Auftrag von Tobias Pape <[hidden email]>
Gesendet: Montag, 9. November 2020 15:59:52
An: The general-purpose Squeak developers list
Betreff: Re: [squeak-dev] Diffs "upside-down"
 


> On 9. Nov 2020, at 15:46, Tony Garnock-Jones <[hidden email]> wrote:
>
> Does it bother anyone else that Squeak prints diffs
>
> +this line was added
> -this line was removed
>
> while Unix-derived tools (including those influenced by Unix, like
> Github) print
>
> -this line was removed
> +this line was added
>
> ?

D'oh!
That explains my constant confusion!

-t



Carpe Squeak!
Reply | Threaded
Open this post in threaded view
|

Re: Diffs "upside-down"

timrowledge
In reply to this post by Tony Garnock-Jones-5


> On 2020-11-09, at 6:46 AM, Tony Garnock-Jones <[hidden email]> wrote:
>
> Does it bother anyone else that Squeak prints diffs
>
> +this line was added
> -this line was removed
>
> while Unix-derived tools (including those influenced by Unix, like
> Github) print
>
> -this line was removed
> +this line was added

Yup; it horrifies me that the unix tools get it wrong :-|


tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
Strange OpCodes: MC: Melt down Core



Reply | Threaded
Open this post in threaded view
|

Re: Diffs "upside-down"

codefrau
In reply to this post by Tony Garnock-Jones-5
On Mon, Nov 9, 2020 at 6:58 AM Tony Garnock-Jones <[hidden email]> wrote:
Does it bother anyone else that Squeak prints diffs

 +this line was added
 -this line was removed

Yes, bothers me greatly. Please someone fix this :)

- Vanessa - 


Reply | Threaded
Open this post in threaded view
|

Re: Diffs "upside-down"

marcel.taeumel
Hi all!

It is configurable now via System-mt.1192 in Trunk. The default is (now) remove-before-insert.

Best,
Marcel


Am 10.11.2020 05:59:41 schrieb Vanessa Freudenberg <[hidden email]>:

On Mon, Nov 9, 2020 at 6:58 AM Tony Garnock-Jones <[hidden email]> wrote:
Does it bother anyone else that Squeak prints diffs

 +this line was added
 -this line was removed

Yes, bothers me greatly. Please someone fix this :)

- Vanessa - 


Reply | Threaded
Open this post in threaded view
|

Re: Diffs "upside-down"

Tony Garnock-Jones-5
Love it! Thank you! I'll tweak it now to allow a per-instance
configurability of it, because I need to use it Unix-style
programmatically without overriding the user's image preference.

On 11/10/20 8:58 AM, Marcel Taeumel wrote:

> Hi all!
>
> It is configurable now via System-mt.1192 in Trunk. The default is (now)
> remove-before-insert.
>
> Best,
> Marcel
>
>
>> Am 10.11.2020 05:59:41 schrieb Vanessa Freudenberg <[hidden email]>:
>>
>> On Mon, Nov 9, 2020 at 6:58 AM Tony Garnock-Jones
>> <[hidden email] <mailto:[hidden email]>> wrote:
>>
>>     Does it bother anyone else that Squeak prints diffs
>>
>>      +this line was added
>>      -this line was removed
>>
>>
>> Yes, bothers me greatly. Please someone fix this :)
>>
>> - Vanessa - 
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Diffs "upside-down"

marcel.taeumel
Sure. Maybe take a look at:

Morph class >> #preferredCornerRadius
Morph >> #cornerRadius

There are other examples in the image.

Best,
Marcel

Am 10.11.2020 09:40:24 schrieb Tony Garnock-Jones <[hidden email]>:

Love it! Thank you! I'll tweak it now to allow a per-instance
configurability of it, because I need to use it Unix-style
programmatically without overriding the user's image preference.

On 11/10/20 8:58 AM, Marcel Taeumel wrote:
> Hi all!
>
> It is configurable now via System-mt.1192 in Trunk. The default is (now)
> remove-before-insert.
>
> Best,
> Marcel
>
>
>> Am 10.11.2020 05:59:41 schrieb Vanessa Freudenberg :
>>
>> On Mon, Nov 9, 2020 at 6:58 AM Tony Garnock-Jones
>> > wrote:
>>
>> Does it bother anyone else that Squeak prints diffs
>>
>>  +this line was added
>>  -this line was removed
>>
>>
>> Yes, bothers me greatly. Please someone fix this :)
>>
>> - Vanessa - 
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Diffs "upside-down"

Tony Garnock-Jones-5
Aha - hm. I went with an instance variable. Do you think I should change
it to use a property instead?

On 11/10/20 9:42 AM, Marcel Taeumel wrote:

> Sure. Maybe take a look at:
>
> Morph class >> #preferredCornerRadius
> Morph >> #cornerRadius
>
> There are other examples in the image.
>
> Best,
> Marcel
>>
>> Am 10.11.2020 09:40:24 schrieb Tony Garnock-Jones
>> <[hidden email]>:
>>
>> Love it! Thank you! I'll tweak it now to allow a per-instance
>> configurability of it, because I need to use it Unix-style
>> programmatically without overriding the user's image preference.
>>
>> On 11/10/20 8:58 AM, Marcel Taeumel wrote:
>> > Hi all!
>> >
>> > It is configurable now via System-mt.1192 in Trunk. The default is
>> (now)
>> > remove-before-insert.
>> >
>> > Best,
>> > Marcel
>> >
>> >
>> >> Am 10.11.2020 05:59:41 schrieb Vanessa Freudenberg :
>> >>
>> >> On Mon, Nov 9, 2020 at 6:58 AM Tony Garnock-Jones
>> >> > wrote:
>> >>
>> >> Does it bother anyone else that Squeak prints diffs
>> >>
>> >>  +this line was added
>> >>  -this line was removed
>> >>
>> >>
>> >> Yes, bothers me greatly. Please someone fix this :)
>> >>
>> >> - Vanessa - 
>> >
>> >

Reply | Threaded
Open this post in threaded view
|

Re: Diffs "upside-down"

marcel.taeumel
inst var is fine. I just pointed you to a roughly equivalent example. I would avoid reading the preference in #initialize but keep the inst var "nil" until overwritten.

Am 10.11.2020 09:59:24 schrieb Tony Garnock-Jones <[hidden email]>:

Aha - hm. I went with an instance variable. Do you think I should change
it to use a property instead?

On 11/10/20 9:42 AM, Marcel Taeumel wrote:
> Sure. Maybe take a look at:
>
> Morph class >> #preferredCornerRadius
> Morph >> #cornerRadius
>
> There are other examples in the image.
>
> Best,
> Marcel
>>
>> Am 10.11.2020 09:40:24 schrieb Tony Garnock-Jones
>> :
>>
>> Love it! Thank you! I'll tweak it now to allow a per-instance
>> configurability of it, because I need to use it Unix-style
>> programmatically without overriding the user's image preference.
>>
>> On 11/10/20 8:58 AM, Marcel Taeumel wrote:
>> > Hi all!
>> >
>> > It is configurable now via System-mt.1192 in Trunk. The default is
>> (now)
>> > remove-before-insert.
>> >
>> > Best,
>> > Marcel
>> >
>> >
>> >> Am 10.11.2020 05:59:41 schrieb Vanessa Freudenberg :
>> >>
>> >> On Mon, Nov 9, 2020 at 6:58 AM Tony Garnock-Jones
>> >> > wrote:
>> >>
>> >> Does it bother anyone else that Squeak prints diffs
>> >>
>> >>  +this line was added
>> >>  -this line was removed
>> >>
>> >>
>> >> Yes, bothers me greatly. Please someone fix this :)
>> >>
>> >> - Vanessa - 
>> >
>> >