more for merging (classes which have no valid revision string)
authorClaus Gittinger <cg@exept.de>
Wed, 13 Dec 1995 17:21:31 +0100
changeset 151 2ecdebacc512
parent 150 54b6185e9aa7
child 152 56747cda83bd
more for merging (classes which have no valid revision string)
CVSSCMgr.st
CVSSourceCodeManager.st
--- a/CVSSCMgr.st	Wed Dec 13 16:10:39 1995 +0100
+++ b/CVSSCMgr.st	Wed Dec 13 17:21:31 1995 +0100
@@ -253,11 +253,11 @@
 
     "/ search for ,v
     idx := originalVersionString indexOfSubCollection:'.st,v'.
-    idx == 0 ifTrue:[^ false].
+    idx == 0 ifTrue:[^ nil].
     leftPart := originalVersionString copyTo:(idx - 1 + 5).
     rightPart := (originalVersionString copyFrom:(idx + 5)) withoutSpaces.
     idx := rightPart indexOfSeparator.
-    idx == 0 ifTrue:[^ false].
+    idx == 0 ifTrue:[^ nil].
     vsnString := rightPart copyTo:idx - 1.
     rightPart := rightPart copyFrom:idx + 1.
 
@@ -265,7 +265,7 @@
         (vsnString endsWith:'m') ifTrue:[
              "/ alread a modified class
 "/            ('already modified: ' , vsnString) printNL.
-            ^ false
+            ^ nil
         ].
         newVsn := vsnString , 'm'
     ] ifFalse:[
@@ -274,7 +274,7 @@
     ^ leftPart , ' ' , newVsn , ' ' , rightPart
 
     "Created: 7.12.1995 / 20:23:38 / cg"
-    "Modified: 12.12.1995 / 11:30:29 / cg"
+    "Modified: 13.12.1995 / 17:13:45 / cg"
 ! !
 
 !CVSSourceCodeManager class methodsFor:'source code access'!
@@ -286,7 +286,8 @@
 
     |tempdir cmd checkoutDir checkoutName logMsg revision merge revisionArg
      cmdOut whatHappened f s entry idx changeLog changesAsLogged l 
-     newRevision newString binRevision className msg answer didMerge|
+     newRevision newString binRevision className msg answer didMerge
+     mySource mergedSource|
 
 merge := false. "/ for now ....
 merge := true. "/ for now ....
@@ -296,8 +297,11 @@
     merge ifTrue:[
         revision := cls revision.
         revision isNil ifTrue:[ 
-            'CVSMGR: class ' , className, ' has no revision string' errorPrintNL.
-            ^ false.
+            ('CVSMGR: class ' , className, ' has no revision string') errorPrintNL.
+            (self confirm:('class ' , className, ' has no (usable) revision string.\\check in as newest ?') withCRs)
+            ifFalse:[
+                ^ false.
+            ].
         ].
         (binRevision := cls binaryRevision) notNil ifTrue:[
             revision ~= binRevision ifTrue:[
@@ -334,7 +338,7 @@
     checkoutDir :=  moduleDir , '/' , packageDir.
     checkoutName :=  checkoutDir , '/' , classFileName.
 
-    merge ifTrue:[
+    (merge and:[revision notNil]) ifTrue:[
         revisionArg := ' -r ' , revision.
     ] ifFalse:[
         revisionArg := ''.
@@ -356,7 +360,7 @@
 
     cmdOut remove.
 
-    merge ifTrue:[
+    (merge and:[revision notNil]) ifTrue:[
         "/
         "/ fake CVS/Entries to make CVS think we checked that version at a time it was the most recent.
         "/ otherwise, commit creates a branch which is not what we want here.
@@ -439,7 +443,11 @@
         ^ true
     ].
 
-    changeLog := self revisionLogOf:cls fromRevision:(self revisionAfter:revision) toRevision:nil.
+    revision isNil ifTrue:[
+        changeLog := self revisionLogOf:cls.
+    ] ifFalse:[
+        changeLog := self revisionLogOf:cls fromRevision:(self revisionAfter:revision) toRevision:nil.
+    ].
     s := WriteStream on:String new.
     self writeRevisionLogMessagesFrom:changeLog withHeader:false to:s.
     changesAsLogged := s contents.
@@ -462,34 +470,58 @@
             didMerge := true.
             changesAsLogged := changesAsLogged asCollectionOfLines.
 
-            msg := 'The source of ' , className , ' has been changed in the meanwhile as listed below.
+            s := WriteStream on:String new.
+            cls fileOutOn:s withTimeStamp:false.
+            mySource := s contents asString.
+            mergedSource := (tempdir name , '/' , checkoutName) asFilename readStream contents asString.
+
+            mySource = mergedSource ifTrue:[
+                msg := 'The source of ' , className , ' has been changed in the meanwhile as listed below.
+
+I have merged your version with the newest repository version, 
+and found no differences between the result and your current version
+(i.e. your version seemed up-to-date).'.
 
-If you continue, your new changes (based upon rev. ' , revision , ') will be MERGED
+                self checkinTroubleDialog:'Merging versions'
+                               message:msg 
+                               log:changesAsLogged
+                               abortable:false 
+                               option:nil.
+                didMerge := false.
+            ] ifFalse:[
+                msg := 'The source of ' , className , ' has been changed in the meanwhile as listed below.
+
+If you continue, your new changes (based upon rev. ' , revision printString , ') will be MERGED
 into the newest revision. This will combine the other version with your changes
-into a new common revision which is different from both. 
-Although convenient, it may fail to create the expected result in certain situations. 
+into a new common revision which may be different from both. 
+Although this is a nice feature, it may fail to create the expected result in certain situations. 
 
 You should carefully check the result - by comparing the current version with the
 most recent version in the repository. If that does not contain an acceptable version,
-change methods as required and check in again. Be aware, that the actual repository version
-is different from your current classes.
+change methods as required and check in again. 
+Be aware, that after that, the actual repository version is different from your current classes,
+and you should update your class from the repository.
 
 Continue ?'.
 
-            answer := self checkinTroubleDialog:'Merging versions'
-                           message:msg 
-                           log:changesAsLogged
-                           abortable:true
-                           option:'stop - see first'.
-            answer ~~ true ifTrue:[
-                answer == #option ifTrue:[
-                    TextView 
-                        openWith:(tempdir name , '/' , checkoutName) asFilename readStream contents
-                        title:'conflicts'.
+                answer := self checkinTroubleDialog:'Merging versions'
+                               message:msg 
+                               log:changesAsLogged
+                               abortable:true
+                               option:'stop - see first'.
+                answer ~~ true ifTrue:[
+                    answer == #option ifTrue:[
+                        DiffTextView 
+                            openOn:mySource
+                            label:'current version'
+                            and:mergedSource
+                            label:'merged version'.
+                            
+                    ].
+                    Transcript showCr:'checkin aborted - (no merge; repository unchanged)'.
+                    tempdir recursiveRemove.
+                    ^ false.
                 ].
-                Transcript showCr:'checkin aborted - (no merge; repository unchanged)'.
-                tempdir recursiveRemove.
-                ^ false.
             ].
 
 "/                changesAsLogged := (changesAsLogged asStringCollection collect:[:line | line withTabsExpanded]) asString.
@@ -525,7 +557,7 @@
 
             msg := 'The source of ' , className , ' has been changed in the meanwhile as listed below.
 
-Your new changes (based upon rev. ' , revision , ') CONFLICT with those changes.
+Your new changes (based upon rev. ' , revision printString , ') CONFLICT with those changes.
 
 You should fix things by comparing your class with the most recent repository version
 and change your methods avoiding conflicts. The checkin again.
@@ -669,7 +701,7 @@
      SourceCodeManager checkinClass:Array logMessage:'testing only'
     "
 
-    "Modified: 12.12.1995 / 13:12:32 / cg"
+    "Modified: 13.12.1995 / 17:15:33 / cg"
 !
 
 streamForClass:cls fileName:classFileName revision:revision directory:packageDir module:moduleDir cache:cacheIt
@@ -793,7 +825,7 @@
     "/ simply check if that CVS file exists.
     "/ in order to support server mode, we have to do more than that ...
 
-    ^ (CVSRoot , '/' , moduleDir , '/' , packageDir , '/' , fileName) asFilename exists.
+    ^ (CVSRoot , '/' , moduleDir , '/' , packageDir , '/' , fileName , ',v') asFilename exists.
 
 
     "/
@@ -814,7 +846,7 @@
     ^ false
 
     "Created: 9.12.1995 / 19:13:37 / cg"
-    "Modified: 9.12.1995 / 19:42:14 / cg"
+    "Modified: 13.12.1995 / 16:15:46 / cg"
 !
 
 checkForExistingModule:moduleDir
@@ -1384,6 +1416,6 @@
 !CVSSourceCodeManager class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic3/Attic/CVSSCMgr.st,v 1.61 1995-12-13 10:25:20 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic3/Attic/CVSSCMgr.st,v 1.62 1995-12-13 16:21:31 cg Exp $'
 ! !
 CVSSourceCodeManager initialize!
--- a/CVSSourceCodeManager.st	Wed Dec 13 16:10:39 1995 +0100
+++ b/CVSSourceCodeManager.st	Wed Dec 13 17:21:31 1995 +0100
@@ -253,11 +253,11 @@
 
     "/ search for ,v
     idx := originalVersionString indexOfSubCollection:'.st,v'.
-    idx == 0 ifTrue:[^ false].
+    idx == 0 ifTrue:[^ nil].
     leftPart := originalVersionString copyTo:(idx - 1 + 5).
     rightPart := (originalVersionString copyFrom:(idx + 5)) withoutSpaces.
     idx := rightPart indexOfSeparator.
-    idx == 0 ifTrue:[^ false].
+    idx == 0 ifTrue:[^ nil].
     vsnString := rightPart copyTo:idx - 1.
     rightPart := rightPart copyFrom:idx + 1.
 
@@ -265,7 +265,7 @@
         (vsnString endsWith:'m') ifTrue:[
              "/ alread a modified class
 "/            ('already modified: ' , vsnString) printNL.
-            ^ false
+            ^ nil
         ].
         newVsn := vsnString , 'm'
     ] ifFalse:[
@@ -274,7 +274,7 @@
     ^ leftPart , ' ' , newVsn , ' ' , rightPart
 
     "Created: 7.12.1995 / 20:23:38 / cg"
-    "Modified: 12.12.1995 / 11:30:29 / cg"
+    "Modified: 13.12.1995 / 17:13:45 / cg"
 ! !
 
 !CVSSourceCodeManager class methodsFor:'source code access'!
@@ -286,7 +286,8 @@
 
     |tempdir cmd checkoutDir checkoutName logMsg revision merge revisionArg
      cmdOut whatHappened f s entry idx changeLog changesAsLogged l 
-     newRevision newString binRevision className msg answer didMerge|
+     newRevision newString binRevision className msg answer didMerge
+     mySource mergedSource|
 
 merge := false. "/ for now ....
 merge := true. "/ for now ....
@@ -296,8 +297,11 @@
     merge ifTrue:[
         revision := cls revision.
         revision isNil ifTrue:[ 
-            'CVSMGR: class ' , className, ' has no revision string' errorPrintNL.
-            ^ false.
+            ('CVSMGR: class ' , className, ' has no revision string') errorPrintNL.
+            (self confirm:('class ' , className, ' has no (usable) revision string.\\check in as newest ?') withCRs)
+            ifFalse:[
+                ^ false.
+            ].
         ].
         (binRevision := cls binaryRevision) notNil ifTrue:[
             revision ~= binRevision ifTrue:[
@@ -334,7 +338,7 @@
     checkoutDir :=  moduleDir , '/' , packageDir.
     checkoutName :=  checkoutDir , '/' , classFileName.
 
-    merge ifTrue:[
+    (merge and:[revision notNil]) ifTrue:[
         revisionArg := ' -r ' , revision.
     ] ifFalse:[
         revisionArg := ''.
@@ -356,7 +360,7 @@
 
     cmdOut remove.
 
-    merge ifTrue:[
+    (merge and:[revision notNil]) ifTrue:[
         "/
         "/ fake CVS/Entries to make CVS think we checked that version at a time it was the most recent.
         "/ otherwise, commit creates a branch which is not what we want here.
@@ -439,7 +443,11 @@
         ^ true
     ].
 
-    changeLog := self revisionLogOf:cls fromRevision:(self revisionAfter:revision) toRevision:nil.
+    revision isNil ifTrue:[
+        changeLog := self revisionLogOf:cls.
+    ] ifFalse:[
+        changeLog := self revisionLogOf:cls fromRevision:(self revisionAfter:revision) toRevision:nil.
+    ].
     s := WriteStream on:String new.
     self writeRevisionLogMessagesFrom:changeLog withHeader:false to:s.
     changesAsLogged := s contents.
@@ -462,34 +470,58 @@
             didMerge := true.
             changesAsLogged := changesAsLogged asCollectionOfLines.
 
-            msg := 'The source of ' , className , ' has been changed in the meanwhile as listed below.
+            s := WriteStream on:String new.
+            cls fileOutOn:s withTimeStamp:false.
+            mySource := s contents asString.
+            mergedSource := (tempdir name , '/' , checkoutName) asFilename readStream contents asString.
+
+            mySource = mergedSource ifTrue:[
+                msg := 'The source of ' , className , ' has been changed in the meanwhile as listed below.
+
+I have merged your version with the newest repository version, 
+and found no differences between the result and your current version
+(i.e. your version seemed up-to-date).'.
 
-If you continue, your new changes (based upon rev. ' , revision , ') will be MERGED
+                self checkinTroubleDialog:'Merging versions'
+                               message:msg 
+                               log:changesAsLogged
+                               abortable:false 
+                               option:nil.
+                didMerge := false.
+            ] ifFalse:[
+                msg := 'The source of ' , className , ' has been changed in the meanwhile as listed below.
+
+If you continue, your new changes (based upon rev. ' , revision printString , ') will be MERGED
 into the newest revision. This will combine the other version with your changes
-into a new common revision which is different from both. 
-Although convenient, it may fail to create the expected result in certain situations. 
+into a new common revision which may be different from both. 
+Although this is a nice feature, it may fail to create the expected result in certain situations. 
 
 You should carefully check the result - by comparing the current version with the
 most recent version in the repository. If that does not contain an acceptable version,
-change methods as required and check in again. Be aware, that the actual repository version
-is different from your current classes.
+change methods as required and check in again. 
+Be aware, that after that, the actual repository version is different from your current classes,
+and you should update your class from the repository.
 
 Continue ?'.
 
-            answer := self checkinTroubleDialog:'Merging versions'
-                           message:msg 
-                           log:changesAsLogged
-                           abortable:true
-                           option:'stop - see first'.
-            answer ~~ true ifTrue:[
-                answer == #option ifTrue:[
-                    TextView 
-                        openWith:(tempdir name , '/' , checkoutName) asFilename readStream contents
-                        title:'conflicts'.
+                answer := self checkinTroubleDialog:'Merging versions'
+                               message:msg 
+                               log:changesAsLogged
+                               abortable:true
+                               option:'stop - see first'.
+                answer ~~ true ifTrue:[
+                    answer == #option ifTrue:[
+                        DiffTextView 
+                            openOn:mySource
+                            label:'current version'
+                            and:mergedSource
+                            label:'merged version'.
+                            
+                    ].
+                    Transcript showCr:'checkin aborted - (no merge; repository unchanged)'.
+                    tempdir recursiveRemove.
+                    ^ false.
                 ].
-                Transcript showCr:'checkin aborted - (no merge; repository unchanged)'.
-                tempdir recursiveRemove.
-                ^ false.
             ].
 
 "/                changesAsLogged := (changesAsLogged asStringCollection collect:[:line | line withTabsExpanded]) asString.
@@ -525,7 +557,7 @@
 
             msg := 'The source of ' , className , ' has been changed in the meanwhile as listed below.
 
-Your new changes (based upon rev. ' , revision , ') CONFLICT with those changes.
+Your new changes (based upon rev. ' , revision printString , ') CONFLICT with those changes.
 
 You should fix things by comparing your class with the most recent repository version
 and change your methods avoiding conflicts. The checkin again.
@@ -669,7 +701,7 @@
      SourceCodeManager checkinClass:Array logMessage:'testing only'
     "
 
-    "Modified: 12.12.1995 / 13:12:32 / cg"
+    "Modified: 13.12.1995 / 17:15:33 / cg"
 !
 
 streamForClass:cls fileName:classFileName revision:revision directory:packageDir module:moduleDir cache:cacheIt
@@ -793,7 +825,7 @@
     "/ simply check if that CVS file exists.
     "/ in order to support server mode, we have to do more than that ...
 
-    ^ (CVSRoot , '/' , moduleDir , '/' , packageDir , '/' , fileName) asFilename exists.
+    ^ (CVSRoot , '/' , moduleDir , '/' , packageDir , '/' , fileName , ',v') asFilename exists.
 
 
     "/
@@ -814,7 +846,7 @@
     ^ false
 
     "Created: 9.12.1995 / 19:13:37 / cg"
-    "Modified: 9.12.1995 / 19:42:14 / cg"
+    "Modified: 13.12.1995 / 16:15:46 / cg"
 !
 
 checkForExistingModule:moduleDir
@@ -1384,6 +1416,6 @@
 !CVSSourceCodeManager class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic3/CVSSourceCodeManager.st,v 1.61 1995-12-13 10:25:20 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic3/CVSSourceCodeManager.st,v 1.62 1995-12-13 16:21:31 cg Exp $'
 ! !
 CVSSourceCodeManager initialize!