Diff3ExclusiveVisitor.st
author Jan Vrany <jan.vrany@labware.com>
Sat, 30 Sep 2023 22:55:25 +0100
branchjv
changeset 19648 5df52d354504
parent 15566 184cea584be5
permissions -rw-r--r--
`TestRunner2`: do not use `#keysAndValuesCollect:` ...as semantics differ among smalltalk dialects. This is normally not a problem until we use code that adds this as a "compatibility" method. So to stay on a safe side, avoid using this method.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13862
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 Copyright (c) 2007-2012 Tony Garnock-Jones
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
 This code is based on Squeak's DiffMerge package
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
 written by Tony Garnock-Jones. Original project's web site:
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 http://www.squeaksource.com/DiffMerge
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 Permission is hereby granted, free of charge, to any person
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 obtaining a copy of this software and associated documentation
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
 files (the 'Software'), to deal in the Software without
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
 restriction, including without limitation the rights to use,
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
 copy, modify, merge, publish, distribute, sublicense, and/or sell
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
 copies of the Software, and to permit persons to whom the
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
 Software is furnished to do so, subject to the following
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
 conditions:
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
 The above copyright notice and this permission notice shall be
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
 included in all copies or substantial portions of the Software.
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
 THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
 OTHER DEALINGS IN THE SOFTWARE.
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
"
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
"{ Package: 'stx:libtool' }"
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
Diff3InclusiveVisitor subclass:#Diff3ExclusiveVisitor
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
	instanceVariableNames:''
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
	classVariableNames:''
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
	poolDictionaries:''
14007
4b0a7bbd5f25 documentation
Claus Gittinger <cg@exept.de>
parents: 13862
diff changeset
    36
	category:'Collections-Sequenceable-Diff'
13862
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
!
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
Diff3ExclusiveVisitor comment:'A Diff3ExclusiveVisitor is used by Diff3 to construct a three-way SequenceableCollection merge that resolves "false conflicts" (a.k.a "accidental clean merges") by accepting the changed text as a non-conflict in the merge result.
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
-- 
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
Copyright (c) 2008 Tony Garnock-Jones <tonyg@lshift.net>
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
Copyright (c) 2008 LShift Ltd. <query@lshift.net>
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction,including without limitation the rights to use, copy, modify, merge,publish, distribute, sublicense, and/or sell copies of the Software,and to permit persons to whom the Software is furnished to do so,subject to the following conditions:
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
'
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
!
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
!Diff3ExclusiveVisitor class methodsFor:'documentation'!
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
copyright
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
"
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
 Copyright (c) 2007-2012 Tony Garnock-Jones
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
 This code is based on Squeak's DiffMerge package
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
 written by Tony Garnock-Jones. Original project's web site:
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
 http://www.squeaksource.com/DiffMerge
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
 Permission is hereby granted, free of charge, to any person
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
 obtaining a copy of this software and associated documentation
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
 files (the 'Software'), to deal in the Software without
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
 restriction, including without limitation the rights to use,
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
 copy, modify, merge, publish, distribute, sublicense, and/or sell
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
 copies of the Software, and to permit persons to whom the
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
 Software is furnished to do so, subject to the following
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
 conditions:
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
 The above copyright notice and this permission notice shall be
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
 included in all copies or substantial portions of the Software.
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
 THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
 OTHER DEALINGS IN THE SOFTWARE.
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
"
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
!
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
documentation
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
"
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
    A Diff3ExclusiveVisitor is used by Diff3 to construct a three-way SequenceableCollection 
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
    merge that resolves 'false conflicts' (a.k.a 'accidental clean merges') by accepting the 
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
    changed text as a non-conflict in the merge result.
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
    [author:]
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
        Tony Garnock-Jones <tonyg@lshift.com>
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
    [instance variables:]
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
    [class variables:]
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
    [see also:]
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
"
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
! !
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
!Diff3ExclusiveVisitor methodsFor:'as yet unclassified'!
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
isTrueConflictBetween: left and: right
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
	"A conflict is 'false' when, from a particular ancestral snippet, both the left and right branches have changed to have the same contents. In some circumstances this can be treated as a clean merge; in others, it's actually an exception that needs to be dealt with. See http://revctrl.org/AccidentalCleanMerge."
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
	left length = right length ifFalse: [^true].
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
	(left extractFrom: (files at: #left)) = (right extractFrom: (files at: #right)) ifFalse: [^true].
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
	^false
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
!
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
left: left original: original right: right
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
	(self isTrueConflictBetween: left and: right)
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
		ifTrue: [super left: left original: original right: right]
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
		ifFalse: [self side: #left chunk: left]
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
! !
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
!Diff3ExclusiveVisitor class methodsFor:'documentation'!
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
version
14007
4b0a7bbd5f25 documentation
Claus Gittinger <cg@exept.de>
parents: 13862
diff changeset
   120
    ^ '$Header: /cvs/stx/stx/libtool/Diff3ExclusiveVisitor.st,v 1.2 2014-02-25 07:00:15 cg Exp $'
13862
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
!
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
version_CVS
14007
4b0a7bbd5f25 documentation
Claus Gittinger <cg@exept.de>
parents: 13862
diff changeset
   124
    ^ '$Header: /cvs/stx/stx/libtool/Diff3ExclusiveVisitor.st,v 1.2 2014-02-25 07:00:15 cg Exp $'
13862
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
! !
ca103e9fc5f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126