FileVersionDiffBrowser.st
changeset 3676 319c68f831df
child 3686 501ea259b6a8
equal deleted inserted replaced
3675:caafc519b235 3676:319c68f831df
       
     1 "
       
     2  COPYRIGHT (c) 2019 by eXept Software AG
       
     3               All Rights Reserved
       
     4 
       
     5  This software is furnished under a license and may be used
       
     6  only in accordance with the terms of that license and with the
       
     7  inclusion of the above copyright notice.   This software may not
       
     8  be provided or otherwise made available to, or used by, any
       
     9  other person.  No title to or ownership of the software is
       
    10  hereby transferred.
       
    11 "
       
    12 "{ Package: 'stx:libtool2' }"
       
    13 
       
    14 "{ NameSpace: Smalltalk }"
       
    15 
       
    16 ApplicationModel subclass:#FileVersionDiffBrowser
       
    17 	instanceVariableNames:'diffTextView diffTextLabelA diffTextLabelB versionAHolder
       
    18 		versionBHolder infoHolder isMultipleVersionBrowser
       
    19 		versionInfoList versionList versionEntriesList
       
    20 		selectedVersionHolder symbolicVersionList symbolicVersionNameList
       
    21 		selectedSymbolicVersionHolder selectedSymbolicVersionIndexHolder
       
    22 		symbolicToVersionMapping selectedVersionIndexHolder
       
    23 		isMultipleFilesVersionBrowser fileListHolder
       
    24 		selectedFileIndexHolder fileHolder diffTextHolder
       
    25 		versionAIfSingleFileDiff versionBIfSingleFileDiff
       
    26 		fileIfSingleFileDiff'
       
    27 	classVariableNames:''
       
    28 	poolDictionaries:''
       
    29 	category:'Interface-Tools-File'
       
    30 !
       
    31 
       
    32 !FileVersionDiffBrowser class methodsFor:'documentation'!
       
    33 
       
    34 copyright
       
    35 "
       
    36  COPYRIGHT (c) 2019 by eXept Software AG
       
    37               All Rights Reserved
       
    38 
       
    39  This software is furnished under a license and may be used
       
    40  only in accordance with the terms of that license and with the
       
    41  inclusion of the above copyright notice.   This software may not
       
    42  be provided or otherwise made available to, or used by, any
       
    43  other person.  No title to or ownership of the software is
       
    44  hereby transferred.
       
    45 "
       
    46 !
       
    47 
       
    48 documentation
       
    49 "
       
    50     A quickly hacked up browser to show differences between file versions,
       
    51     allowing easy comparison; will also eventually add capabilities
       
    52     to checkIn / load files into / from the repository.
       
    53 
       
    54     [usages:]
       
    55         FileVersionDiffBrowser openOnAllVersionsOfFile:'Make.proto'.
       
    56         FileVersionDiffBrowser openOnAllFilesChangedSince:(Date today - 7 days) in:('../../libbasic' asFilename).
       
    57         
       
    58     [see also:]
       
    59 
       
    60     [instance variables:]
       
    61 
       
    62     [class variables:]
       
    63 "
       
    64 ! !
       
    65 
       
    66 !FileVersionDiffBrowser class methodsFor:'interface specs'!
       
    67 
       
    68 windowSpec
       
    69     "This resource specification was automatically generated
       
    70      by the UIPainter of ST/X."
       
    71 
       
    72     "Do not manually edit this!! If it is corrupted,
       
    73      the UIPainter may not be able to read the specification."
       
    74 
       
    75     "
       
    76      UIPainter new openOnClass:FileVersionDiffBrowser andSelector:#windowSpec
       
    77      FileVersionDiffBrowser new openInterface:#windowSpec
       
    78      FileVersionDiffBrowser open
       
    79     "
       
    80 
       
    81     <resource: #canvas>
       
    82 
       
    83     ^ 
       
    84     #(FullSpec
       
    85        name: windowSpec
       
    86        uuid: '34d3baee-a108-11e9-a652-b8f6b1108e05'
       
    87        window: 
       
    88       (WindowSpec
       
    89          label: 'Version DiffBrowser'
       
    90          name: 'Version DiffBrowser'
       
    91          uuid: '90e45e00-7175-11e9-a23a-b8f6b1108e05'
       
    92          min: (Point 10 10)
       
    93          bounds: (Rectangle 0 0 865 504)
       
    94          menu: mainMenu
       
    95        )
       
    96        component: 
       
    97       (SpecCollection
       
    98          collection: (
       
    99           (VariableVerticalPanelSpec
       
   100              name: 'VariableVerticalPanel1'
       
   101              layout: (LayoutFrame 0 0.0 0 0.0 0 1.0 -25 1.0)
       
   102              uuid: '90e460c6-7175-11e9-a23a-b8f6b1108e05'
       
   103              component: 
       
   104             (SpecCollection
       
   105                collection: (
       
   106                 (ViewSpec
       
   107                    name: 'DiffOrSingleMethodCodeBox'
       
   108                    uuid: '90e471a6-7175-11e9-a23a-b8f6b1108e05'
       
   109                    component: 
       
   110                   (SpecCollection
       
   111                      collection: (
       
   112                       (ViewSpec
       
   113                          name: 'diffTextViewBox'
       
   114                          layout: (LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
       
   115                          uuid: '90e47264-7175-11e9-a23a-b8f6b1108e05'
       
   116                          component: 
       
   117                         (SpecCollection
       
   118                            collection: (
       
   119                             (LabelSpec
       
   120                                label: 'A'
       
   121                                name: 'DiffTextLabelA'
       
   122                                layout: (LayoutFrame 0 0 0 0 0 0.5 20 0)
       
   123                                uuid: '90e47318-7175-11e9-a23a-b8f6b1108e05'
       
   124                                translateLabel: true
       
   125                                labelChannel: diffTextLabelA
       
   126                              )
       
   127                             (LabelSpec
       
   128                                label: 'B'
       
   129                                name: 'DiffTextLabelB'
       
   130                                layout: (LayoutFrame 0 0.5 0 0 0 1 20 0)
       
   131                                uuid: '90e47412-7175-11e9-a23a-b8f6b1108e05'
       
   132                                translateLabel: true
       
   133                                labelChannel: diffTextLabelB
       
   134                              )
       
   135                             (ArbitraryComponentSpec
       
   136                                name: 'diffTextView'
       
   137                                layout: (LayoutFrame 0 0.0 20 0.0 0 1.0 0 1.0)
       
   138                                uuid: '90e47502-7175-11e9-a23a-b8f6b1108e05'
       
   139                                hasBorder: false
       
   140                                component: diffTextView
       
   141                              )
       
   142                             )
       
   143                           
       
   144                          )
       
   145                        )
       
   146                       )
       
   147                     
       
   148                    )
       
   149                  )
       
   150                 )
       
   151               
       
   152              )
       
   153              handles: (Any 1.0)
       
   154            )
       
   155           (LabelSpec
       
   156              name: 'InfoLabel'
       
   157              layout: (LayoutFrame 0 0 -25 1 0 1 0 1)
       
   158              uuid: '90e47868-7175-11e9-a23a-b8f6b1108e05'
       
   159              level: -1
       
   160              translateLabel: true
       
   161              labelChannel: infoHolder
       
   162              adjust: left
       
   163            )
       
   164           )
       
   165         
       
   166        )
       
   167      )
       
   168 !
       
   169 
       
   170 windowSpecForMultipleFiles
       
   171     "This resource specification was automatically generated
       
   172      by the UIPainter of ST/X."
       
   173 
       
   174     "Do not manually edit this!! If it is corrupted,
       
   175      the UIPainter may not be able to read the specification."
       
   176 
       
   177     "
       
   178      UIPainter new openOnClass:FileVersionDiffBrowser andSelector:#windowSpecForMultipleFiles
       
   179      FileVersionDiffBrowser new openInterface:#windowSpecForMultipleFiles
       
   180     "
       
   181 
       
   182     <resource: #canvas>
       
   183 
       
   184     ^ 
       
   185     #(FullSpec
       
   186        name: windowSpecForMultipleFiles
       
   187        uuid: '3c5c60f4-a108-11e9-a652-b8f6b1108e05'
       
   188        window: 
       
   189       (WindowSpec
       
   190          label: 'Version DiffBrowser'
       
   191          name: 'Version DiffBrowser'
       
   192          uuid: '2b3f2546-d4fd-11e7-af82-c42c033b4871'
       
   193          min: (Point 10 10)
       
   194          bounds: (Rectangle 0 0 865 504)
       
   195          menu: mainMenu
       
   196        )
       
   197        component: 
       
   198       (SpecCollection
       
   199          collection: (
       
   200           (VariableVerticalPanelSpec
       
   201              name: 'VariableVerticalPanel1'
       
   202              layout: (LayoutFrame 0 0.0 0 0.0 0 1.0 -25 1.0)
       
   203              uuid: '2b3f297e-d4fd-11e7-af82-c42c033b4871'
       
   204              component: 
       
   205             (SpecCollection
       
   206                collection: (
       
   207                 (VariableHorizontalPanelSpec
       
   208                    name: 'FileAndVersionAndTagPanel'
       
   209                    uuid: '17c6805c-7184-11e9-a23a-b8f6b1108e05'
       
   210                    component: 
       
   211                   (SpecCollection
       
   212                      collection: (
       
   213                       (SequenceViewSpec
       
   214                          name: 'List2'
       
   215                          uuid: '2b3f2d20-d4fd-11e7-af82-c42c033b4871'
       
   216                          model: selectedFileIndexHolder
       
   217                          menu: fileListMenu
       
   218                          hasHorizontalScrollBar: true
       
   219                          hasVerticalScrollBar: true
       
   220                          useIndex: true
       
   221                          sequenceList: fileNameListHolder
       
   222                        )
       
   223                       (VariableHorizontalPanelSpec
       
   224                          name: 'VersionAndTagPanel'
       
   225                          uuid: '2b3f2c08-d4fd-11e7-af82-c42c033b4871'
       
   226                          component: 
       
   227                         (SpecCollection
       
   228                            collection: (
       
   229                             (SequenceViewSpec
       
   230                                name: 'VersionList'
       
   231                                uuid: '2b3f2d20-d4fd-11e7-af82-c42c033b4871'
       
   232                                model: selectedVersionIndexHolder
       
   233                                menu: versionsMenu
       
   234                                hasHorizontalScrollBar: true
       
   235                                hasVerticalScrollBar: true
       
   236                                useIndex: true
       
   237                                sequenceList: versionEntriesList
       
   238                              )
       
   239                             (SequenceViewSpec
       
   240                                name: 'List1'
       
   241                                uuid: '2b3f3086-d4fd-11e7-af82-c42c033b4871'
       
   242                                model: selectedSymbolicVersionIndexHolder
       
   243                                menu: symbolicVersionsMenu
       
   244                                hasHorizontalScrollBar: true
       
   245                                hasVerticalScrollBar: true
       
   246                                useIndex: true
       
   247                                sequenceList: symbolicVersionNameList
       
   248                              )
       
   249                             )
       
   250                           
       
   251                          )
       
   252                          handles: (Any 0.5 1.0)
       
   253                        )
       
   254                       )
       
   255                     
       
   256                    )
       
   257                    handles: (Any 0.5 1.0)
       
   258                  )
       
   259                 (ViewSpec
       
   260                    name: 'DiffBox'
       
   261                    uuid: '2b3f408a-d4fd-11e7-af82-c42c033b4871'
       
   262                    component: 
       
   263                   (SpecCollection
       
   264                      collection: (
       
   265                       (ViewSpec
       
   266                          name: 'diffTextViewBox'
       
   267                          layout: (LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
       
   268                          uuid: '2b3f415c-d4fd-11e7-af82-c42c033b4871'
       
   269                          component: 
       
   270                         (SpecCollection
       
   271                            collection: (
       
   272                             (LabelSpec
       
   273                                label: 'A'
       
   274                                name: 'DiffTextLabelA'
       
   275                                layout: (LayoutFrame 0 0 0 0 0 0.5 20 0)
       
   276                                uuid: '2b3f426a-d4fd-11e7-af82-c42c033b4871'
       
   277                                translateLabel: true
       
   278                                labelChannel: diffTextLabelA
       
   279                              )
       
   280                             (LabelSpec
       
   281                                label: 'B'
       
   282                                name: 'DiffTextLabelB'
       
   283                                layout: (LayoutFrame 0 0.5 0 0 0 1 20 0)
       
   284                                uuid: '2b3f43d2-d4fd-11e7-af82-c42c033b4871'
       
   285                                translateLabel: true
       
   286                                labelChannel: diffTextLabelB
       
   287                              )
       
   288                             (ArbitraryComponentSpec
       
   289                                name: 'diffTextView'
       
   290                                layout: (LayoutFrame 0 0.0 20 0.0 0 1.0 0 1.0)
       
   291                                uuid: '2b3f4508-d4fd-11e7-af82-c42c033b4871'
       
   292                                hasBorder: false
       
   293                                component: diffTextView
       
   294                              )
       
   295                             )
       
   296                           
       
   297                          )
       
   298                        )
       
   299                       )
       
   300                     
       
   301                    )
       
   302                  )
       
   303                 )
       
   304               
       
   305              )
       
   306              handles: (Any 0.5 1.0)
       
   307            )
       
   308           (LabelSpec
       
   309              name: 'InfoLabel'
       
   310              layout: (LayoutFrame 0 0 -25 1 0 1 0 1)
       
   311              uuid: '2b3f4a44-d4fd-11e7-af82-c42c033b4871'
       
   312              level: -1
       
   313              translateLabel: true
       
   314              labelChannel: infoHolder
       
   315              adjust: left
       
   316            )
       
   317           )
       
   318         
       
   319        )
       
   320      )
       
   321 !
       
   322 
       
   323 windowSpecForMultipleVersions
       
   324     "This resource specification was automatically generated
       
   325      by the UIPainter of ST/X."
       
   326 
       
   327     "Do not manually edit this!! If it is corrupted,
       
   328      the UIPainter may not be able to read the specification."
       
   329 
       
   330     "
       
   331      UIPainter new openOnClass:FileVersionDiffBrowser andSelector:#windowSpecForMultipleVersions
       
   332      FileVersionDiffBrowser new openInterface:#windowSpecForMultipleVersions
       
   333     "
       
   334 
       
   335     <resource: #canvas>
       
   336 
       
   337     ^ 
       
   338     #(FullSpec
       
   339        name: windowSpecForMultipleVersions
       
   340        uuid: '441c0448-a108-11e9-a652-b8f6b1108e05'
       
   341        window: 
       
   342       (WindowSpec
       
   343          label: 'Version DiffBrowser'
       
   344          name: 'Version DiffBrowser'
       
   345          uuid: '2b3f2546-d4fd-11e7-af82-c42c033b4871'
       
   346          min: (Point 10 10)
       
   347          bounds: (Rectangle 0 0 865 504)
       
   348          menu: mainMenu
       
   349        )
       
   350        component: 
       
   351       (SpecCollection
       
   352          collection: (
       
   353           (VariableVerticalPanelSpec
       
   354              name: 'VariableVerticalPanel1'
       
   355              layout: (LayoutFrame 0 0.0 0 0.0 0 1.0 -25 1.0)
       
   356              uuid: '2b3f297e-d4fd-11e7-af82-c42c033b4871'
       
   357              component: 
       
   358             (SpecCollection
       
   359                collection: (
       
   360                 (VariableHorizontalPanelSpec
       
   361                    name: 'VersionAndTagBox'
       
   362                    uuid: '2b3f2c08-d4fd-11e7-af82-c42c033b4871'
       
   363                    component: 
       
   364                   (SpecCollection
       
   365                      collection: (
       
   366                       (SequenceViewSpec
       
   367                          name: 'VersionList'
       
   368                          uuid: '2b3f2d20-d4fd-11e7-af82-c42c033b4871'
       
   369                          model: selectedVersionIndexHolder
       
   370                          menu: versionsMenu
       
   371                          hasHorizontalScrollBar: true
       
   372                          hasVerticalScrollBar: true
       
   373                          useIndex: true
       
   374                          sequenceList: versionEntriesList
       
   375                        )
       
   376                       (SequenceViewSpec
       
   377                          name: 'List1'
       
   378                          uuid: '2b3f3086-d4fd-11e7-af82-c42c033b4871'
       
   379                          model: selectedSymbolicVersionIndexHolder
       
   380                          menu: symbolicVersionsMenu
       
   381                          hasHorizontalScrollBar: true
       
   382                          hasVerticalScrollBar: true
       
   383                          useIndex: true
       
   384                          sequenceList: symbolicVersionNameList
       
   385                        )
       
   386                       )
       
   387                     
       
   388                    )
       
   389                    handles: (Any 0.5 1.0)
       
   390                  )
       
   391                 (ViewSpec
       
   392                    name: 'DiffBox'
       
   393                    uuid: '2b3f408a-d4fd-11e7-af82-c42c033b4871'
       
   394                    component: 
       
   395                   (SpecCollection
       
   396                      collection: (
       
   397                       (ViewSpec
       
   398                          name: 'diffTextViewBox'
       
   399                          layout: (LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
       
   400                          uuid: '2b3f415c-d4fd-11e7-af82-c42c033b4871'
       
   401                          component: 
       
   402                         (SpecCollection
       
   403                            collection: (
       
   404                             (LabelSpec
       
   405                                label: 'A'
       
   406                                name: 'DiffTextLabelA'
       
   407                                layout: (LayoutFrame 0 0 0 0 0 0.5 20 0)
       
   408                                uuid: '2b3f426a-d4fd-11e7-af82-c42c033b4871'
       
   409                                translateLabel: true
       
   410                                labelChannel: diffTextLabelA
       
   411                              )
       
   412                             (LabelSpec
       
   413                                label: 'B'
       
   414                                name: 'DiffTextLabelB'
       
   415                                layout: (LayoutFrame 0 0.5 0 0 0 1 20 0)
       
   416                                uuid: '2b3f43d2-d4fd-11e7-af82-c42c033b4871'
       
   417                                translateLabel: true
       
   418                                labelChannel: diffTextLabelB
       
   419                              )
       
   420                             (ArbitraryComponentSpec
       
   421                                name: 'diffTextView'
       
   422                                layout: (LayoutFrame 0 0.0 20 0.0 0 1.0 0 1.0)
       
   423                                uuid: '2b3f4508-d4fd-11e7-af82-c42c033b4871'
       
   424                                hasBorder: false
       
   425                                component: diffTextView
       
   426                              )
       
   427                             )
       
   428                           
       
   429                          )
       
   430                        )
       
   431                       )
       
   432                     
       
   433                    )
       
   434                  )
       
   435                 )
       
   436               
       
   437              )
       
   438              handles: (Any 0.5 1.0)
       
   439            )
       
   440           (LabelSpec
       
   441              name: 'InfoLabel'
       
   442              layout: (LayoutFrame 0 0 -25 1 0 1 0 1)
       
   443              uuid: '2b3f4a44-d4fd-11e7-af82-c42c033b4871'
       
   444              level: -1
       
   445              translateLabel: true
       
   446              labelChannel: infoHolder
       
   447              adjust: left
       
   448            )
       
   449           )
       
   450         
       
   451        )
       
   452      )
       
   453 ! !
       
   454 
       
   455 !FileVersionDiffBrowser class methodsFor:'menu specs'!
       
   456 
       
   457 mainMenu
       
   458     "This resource specification was automatically generated
       
   459      by the MenuEditor of ST/X."
       
   460 
       
   461     "Do not manually edit this!! If it is corrupted,
       
   462      the MenuEditor may not be able to read the specification."
       
   463 
       
   464 
       
   465     "
       
   466      MenuEditor new openOnClass:FileVersionDiffBrowser andSelector:#mainMenu
       
   467      (Menu new fromLiteralArrayEncoding:(FileVersionDiffBrowser mainMenu)) startUp
       
   468     "
       
   469 
       
   470     <resource: #menu>
       
   471 
       
   472     ^ 
       
   473      #(Menu
       
   474         (
       
   475          (MenuItem
       
   476             label: 'File'
       
   477             submenu: 
       
   478            (Menu
       
   479               (
       
   480                (MenuItem
       
   481                   label: 'Create PatchFile...'
       
   482                   itemValue: createPatchFile
       
   483                 )
       
   484                (MenuItem
       
   485                   label: '-'
       
   486                 )
       
   487                (MenuItem
       
   488                   label: 'Exit'
       
   489                   itemValue: closeRequest
       
   490                 )
       
   491                )
       
   492               nil
       
   493               nil
       
   494             )
       
   495           )
       
   496          (MenuItem
       
   497             label: 'View'
       
   498             submenuChannel: viewMenu
       
   499           )
       
   500          (MenuItem
       
   501             label: 'MENU_Help'
       
   502             startGroup: conditionalRight
       
   503             submenu: 
       
   504            (Menu
       
   505               (
       
   506                (MenuItem
       
   507                   label: 'Documentation'
       
   508                   itemValue: openDocumentation
       
   509                 )
       
   510                (MenuItem
       
   511                   label: '-'
       
   512                 )
       
   513                (MenuItem
       
   514                   label: 'About this Application...'
       
   515                   itemValue: openAboutThisApplication
       
   516                 )
       
   517                )
       
   518               nil
       
   519               nil
       
   520             )
       
   521           )
       
   522          )
       
   523         nil
       
   524         nil
       
   525       )
       
   526 !
       
   527 
       
   528 versionsMenu
       
   529     "This resource specification was automatically generated
       
   530      by the MenuEditor of ST/X."
       
   531 
       
   532     "Do not manually edit this!! If it is corrupted,
       
   533      the MenuEditor may not be able to read the specification."
       
   534 
       
   535 
       
   536     "
       
   537      MenuEditor new openOnClass:VersionDiffBrowser andSelector:#mainMenu
       
   538      (Menu new fromLiteralArrayEncoding:(VersionDiffBrowser mainMenu)) startUp
       
   539     "
       
   540 
       
   541     <resource: #menu>
       
   542 
       
   543     ^ 
       
   544      #(Menu
       
   545               (
       
   546                (MenuItem
       
   547                   label: 'Compare against Previous (Older) Version'
       
   548                   nameKey: CompareAgainstPreviousVersion
       
   549                   itemValue: versionMenuCompareAgainstPreviousVersion
       
   550                   enabled: hasPreviousVersionInVersionList
       
   551                 )
       
   552                (MenuItem
       
   553                   label: 'Compare against Next (Younger) Version'
       
   554                   nameKey: CompareAgainstNextVersion
       
   555                   itemValue: versionMenuCompareAgainstNextVersion
       
   556                   enabled: hasNextVersionInVersionList
       
   557                 )
       
   558 
       
   559                )
       
   560               nil
       
   561               nil
       
   562             )
       
   563 
       
   564     "Created: / 05-02-2017 / 11:11:30 / cg"
       
   565     "Modified: / 06-02-2017 / 09:27:22 / cg"
       
   566 !
       
   567 
       
   568 viewMenu
       
   569     "This resource specification was automatically generated
       
   570      by the MenuEditor of ST/X."
       
   571 
       
   572     "Do not manually edit this!! If it is corrupted,
       
   573      the MenuEditor may not be able to read the specification."
       
   574 
       
   575 
       
   576     "
       
   577      MenuEditor new openOnClass:FileVersionDiffBrowser andSelector:#viewMenu
       
   578      (Menu new fromLiteralArrayEncoding:(FileVersionDiffBrowser viewMenu)) startUp
       
   579     "
       
   580 
       
   581     <resource: #menu>
       
   582 
       
   583     ^ 
       
   584      #(Menu
       
   585         (
       
   586          (MenuItem
       
   587             label: 'Show Log Messages'
       
   588             itemValue: showLogMessages
       
   589           )
       
   590          )
       
   591         nil
       
   592         nil
       
   593       )
       
   594 ! !
       
   595 
       
   596 !FileVersionDiffBrowser class methodsFor:'startup'!
       
   597 
       
   598 openOnAllFilesChangedSince:aDateOrTimestamp in:aSetOfFilesOrADirectoryFilename
       
   599     "create a FileVersionDiffBrowser instance and set the list of files.
       
   600      When a file is selected, the version list is extracted,
       
   601      and the diff list is generated from the file's current version against
       
   602      the selected version in the top selection list"
       
   603 
       
   604     |setOfFiles theBrowser filesChangedSince sinceTimestamp|
       
   605 
       
   606     sinceTimestamp := aDateOrTimestamp asTimestamp.
       
   607 
       
   608     setOfFiles := aSetOfFilesOrADirectoryFilename.
       
   609     setOfFiles isFilename ifTrue:[
       
   610         setOfFiles := setOfFiles directoryContentsAsFilenames.
       
   611     ].
       
   612     
       
   613     filesChangedSince := setOfFiles 
       
   614         select:[:fn | fn modificationTime > sinceTimestamp].
       
   615     filesChangedSince sort:[:a :b | a name < b name].
       
   616     
       
   617     theBrowser := self new.
       
   618     theBrowser allButOpenInterface:#windowSpecForMultipleFiles.
       
   619     theBrowser beMultipleFilesVersionBrowser.
       
   620     theBrowser fileList:filesChangedSince.
       
   621     
       
   622     "/ theBrowser classHolder:(ValueHolder with:aClass).
       
   623     "/ theBrowser setupForClass:aClass againstVersion:nil.
       
   624     theBrowser window label:(self resources string:'Versions of %1 files' with:setOfFiles size).
       
   625     theBrowser openWindow.
       
   626     ^ theBrowser.
       
   627 
       
   628     "
       
   629      FileVersionDiffBrowser 
       
   630         openOnAllFilesChangedSince:(Date today - 7 days) 
       
   631         in:('../../libbasic' asFilename files).
       
   632     "
       
   633 
       
   634     "Created: / 07-07-2019 / 18:58:01 / Claus Gittinger"
       
   635     "Modified: / 08-07-2019 / 01:36:01 / Claus Gittinger"
       
   636 !
       
   637 
       
   638 openOnAllVersionsOfFile:aFilename
       
   639     "create a VersionDiffBrowser instance and set the file. 
       
   640      The diff is generated from aFilename's current version against
       
   641      the selected version in the top selection list"
       
   642 
       
   643     |theBrowser|
       
   644 
       
   645     theBrowser := self new.
       
   646     theBrowser allButOpenInterface:#windowSpecForMultipleVersions.
       
   647     theBrowser beMultipleVersionBrowser.
       
   648     theBrowser fileHolder value:aFilename.
       
   649     theBrowser setupForAllVersionsOfFile:aFilename.
       
   650     theBrowser window label:(self resources string:'Versions of %1' with:aFilename baseName).
       
   651     theBrowser openWindow.
       
   652     ^ theBrowser.
       
   653 
       
   654     "
       
   655      self openOnAllVersionsOfFile:'Make.proto' asFilename
       
   656      self openOnAllVersionsOfFile:'../../libbasic/Array.st' asFilename
       
   657     "
       
   658 
       
   659     "Created: / 07-07-2019 / 19:26:28 / Claus Gittinger"
       
   660     "Modified: / 07-07-2019 / 22:40:38 / Claus Gittinger"
       
   661     "Modified (comment): / 08-07-2019 / 01:27:03 / Claus Gittinger"
       
   662 !
       
   663 
       
   664 openOnAllVersionsOfFiles:aSetOfFilenames
       
   665     "create a VersionDiffBrowser instance and set the list of files.
       
   666      When a file is selected, the version list is extracted,
       
   667      and the diff set is generated from the file's current version against
       
   668      the selected version in the top selection list"
       
   669 
       
   670     |theBrowser|
       
   671 
       
   672     theBrowser := self new.
       
   673     theBrowser allButOpenInterface:#windowSpecForMultipleFiles.
       
   674     theBrowser beMultipleFilesVersionBrowser.
       
   675     theBrowser beMultipleVersionBrowser.
       
   676     theBrowser fileList:(aSetOfFilenames collect:#asFilename).
       
   677     theBrowser window label:(self resources string:'Versions of %1 files' with:aSetOfFilenames size).
       
   678     theBrowser openWindow.
       
   679     ^ theBrowser.
       
   680 
       
   681     "
       
   682      self openOnAllVersionsOfFiles:#('Make.proto' 'Make.spec')
       
   683     "
       
   684 
       
   685     "Created: / 07-07-2019 / 19:29:38 / Claus Gittinger"
       
   686     "Modified: / 08-07-2019 / 00:30:31 / Claus Gittinger"
       
   687 !
       
   688 
       
   689 openOnFile:aFilename againstVersion:aVersionA
       
   690     "create a VersionDiffBrowser instance and set the diffs of the
       
   691      browser. The diffs are generated from aFilename's current against some version
       
   692      via the source code manager."
       
   693 
       
   694     |theBrowser fn|
       
   695 
       
   696     fn := aFilename asFilename.
       
   697     theBrowser := self new.
       
   698     theBrowser allButOpen.
       
   699     theBrowser setupForFile:fn againstVersion:aVersionA.
       
   700     theBrowser window label:(self resources string:'Diffs of %1 %2 against current' with:fn baseName with:aVersionA).
       
   701     theBrowser openWindow.
       
   702     ^ theBrowser.
       
   703 
       
   704     "
       
   705      self openOnFile:'Make.proto' againstVersion:'1.2'
       
   706      self openOnFile:'Make.proto' againstVersion:#newest        - against the newest repository version
       
   707     "
       
   708 
       
   709     "Created: / 07-07-2019 / 19:31:13 / Claus Gittinger"
       
   710     "Modified: / 08-07-2019 / 00:42:22 / Claus Gittinger"
       
   711 !
       
   712 
       
   713 openOnFile:file1 andFile:file2
       
   714     |fn1 fn2|
       
   715     
       
   716     fn1 := file1 asFilename.
       
   717     fn2 := file2 asFilename.
       
   718     ^ self 
       
   719         openOnFile:fn1 labelA:fn1 baseName andFile:fn2 labelB:fn2 baseName 
       
   720         title:(self resources string:'%1 vs. %2' 
       
   721                                 with:fn1 baseName with:fn2 baseName)
       
   722         ifSame:nil
       
   723 
       
   724     "
       
   725      FileVersionDiffBrowser
       
   726         openOnFile:'../../libbasic/FloatArray.st'
       
   727         andFile:'../../libbasic/DoubleArray.st'
       
   728     "
       
   729 
       
   730     "Created: / 08-07-2019 / 00:52:18 / Claus Gittinger"
       
   731 !
       
   732 
       
   733 openOnFile:fileA labelA:aLabelA andFile:fileB labelB:aLabelB title:title
       
   734     "create a VersionDiffBrowser instance and set the difflist of the
       
   735      browser. The diffs are generated from two files."
       
   736 
       
   737     ^ self
       
   738         openOnFile:fileA labelA:aLabelA
       
   739         andFile:fileB labelB:aLabelB
       
   740         title:title ifSame:nil
       
   741 
       
   742     "
       
   743      self
       
   744         openOnFile:'../../libbasic/FloatArray.st' labelA:'FloatArray'
       
   745         andFile:'../../libbasic/DoubleArray.st' labelB:'DoubleArray'
       
   746         title:'FloatArray vs. DoubleArray'
       
   747     "
       
   748 
       
   749     "Created: / 07-07-2019 / 19:32:07 / Claus Gittinger"
       
   750     "Modified (comment): / 08-07-2019 / 00:37:50 / Claus Gittinger"
       
   751 !
       
   752 
       
   753 openOnFile:fileA labelA:aLabelA andFile:fileB labelB:aLabelB title:title ifSame:sameAction
       
   754     "create a VersionDiffBrowser instance and set the class change set of the
       
   755      browser. The class diff set is generated from two classes."
       
   756 
       
   757     |theBrowser fn1 fn2|
       
   758 
       
   759     fn1 := fileA asFilename.
       
   760     fn2 := fileB asFilename.
       
   761     
       
   762     theBrowser := self new.
       
   763     theBrowser allButOpen.
       
   764     theBrowser setupForFile:fn1 labelA:aLabelA andFile:fn2 labelB:aLabelB.
       
   765     theBrowser window label:title.
       
   766     theBrowser openWindow.
       
   767     ^ theBrowser.
       
   768 
       
   769     "
       
   770      FileVersionDiffBrowser
       
   771         openOnFile:'../../libbasic/FloatArray.st' labelA:'FloatArray'
       
   772         andFile:'../../libbasic/DoubleArray.st' labelB:'DoubleArray'
       
   773         title:'Some diffs' ifSame:nil
       
   774     "
       
   775 
       
   776     "Created: / 07-07-2019 / 20:05:16 / Claus Gittinger"
       
   777     "Modified (comment): / 08-07-2019 / 00:51:29 / Claus Gittinger"
       
   778 !
       
   779 
       
   780 openOnFile:aFilename versionA:versionA versionB:versionB
       
   781     "create a VersionDiffBrowser instance and set the class change set of the
       
   782      browser. The class diff set is generated from two versions of aClass via
       
   783      the source code manager."
       
   784 
       
   785     |theBrowser|
       
   786 
       
   787     theBrowser := self new.
       
   788     theBrowser allButOpen.
       
   789     theBrowser setupForFile:aFilename versionA:versionA versionB:versionB.
       
   790     theBrowser window label:(self resources 
       
   791                                 string:'%1 Versions %2 vs. %3' 
       
   792                                 with:aFilename baseName with:versionA with:versionB).
       
   793     theBrowser openWindow.
       
   794     ^ theBrowser.
       
   795 
       
   796     "
       
   797      self openOnFile:'Make.proto' versionA:'1.1' versionB:'1.2'
       
   798     "
       
   799 
       
   800     "Created: / 07-07-2019 / 20:06:15 / Claus Gittinger"
       
   801 ! !
       
   802 
       
   803 !FileVersionDiffBrowser methodsFor:'accessing'!
       
   804 
       
   805 beMultipleFilesVersionBrowser
       
   806     isMultipleFilesVersionBrowser := true
       
   807 
       
   808     "Created: / 07-07-2019 / 18:58:49 / Claus Gittinger"
       
   809 !
       
   810 
       
   811 beMultipleVersionBrowser
       
   812     isMultipleVersionBrowser := true
       
   813 !
       
   814 
       
   815 isMultipleFilesVersionBrowser
       
   816     ^ isMultipleFilesVersionBrowser
       
   817 
       
   818     "Created: / 07-07-2019 / 19:53:15 / Claus Gittinger"
       
   819 !
       
   820 
       
   821 isMultipleVersionBrowser
       
   822     ^ isMultipleVersionBrowser
       
   823 
       
   824     "Modified: / 08-05-2019 / 10:59:40 / Claus Gittinger"
       
   825 ! !
       
   826 
       
   827 !FileVersionDiffBrowser methodsFor:'aspects'!
       
   828 
       
   829 diffTextHolder
       
   830     diffTextHolder isNil ifTrue:[
       
   831         diffTextHolder := '' asValue
       
   832     ].    
       
   833     ^ diffTextHolder
       
   834 
       
   835     "Created: / 07-07-2019 / 20:04:23 / Claus Gittinger"
       
   836 !
       
   837 
       
   838 diffTextLabelA
       
   839     "aspect for the label for version A"
       
   840 
       
   841     ^ diffTextLabelA.
       
   842 
       
   843     "Modified: / 08-05-2019 / 11:03:23 / Claus Gittinger"
       
   844 !
       
   845 
       
   846 diffTextLabelB
       
   847     "aspect for the label for version B"
       
   848 
       
   849     ^ diffTextLabelB.
       
   850 
       
   851     "Modified: / 08-05-2019 / 11:03:32 / Claus Gittinger"
       
   852 !
       
   853 
       
   854 diffTextView
       
   855     "
       
   856     return the component for the diff text view.
       
   857 
       
   858     <return: HVScrollableView>
       
   859     "
       
   860     |v|
       
   861 
       
   862     diffTextView isNil ifTrue:[
       
   863         v := DiffCodeView new.
       
   864         v textViewClass:CodeView.
       
   865         v initialize.
       
   866         diffTextView := HVScrollableView
       
   867                            forView:v
       
   868                            miniScrollerH:true miniScrollerV:false.
       
   869         diffTextView addNextPreviousButtons.
       
   870     ].
       
   871     ^ diffTextView
       
   872 
       
   873     "Modified: / 06-10-2006 / 14:30:42 / cg"
       
   874 !
       
   875 
       
   876 fileHolder
       
   877     fileHolder isNil ifTrue:[
       
   878         fileHolder := nil asValue
       
   879     ].    
       
   880     ^ fileHolder
       
   881 
       
   882     "Created: / 07-07-2019 / 20:10:47 / Claus Gittinger"
       
   883 !
       
   884 
       
   885 fileList:aList
       
   886     self fileListHolder contents:aList
       
   887 
       
   888     "Created: / 08-07-2019 / 00:28:32 / Claus Gittinger"
       
   889 !
       
   890 
       
   891 fileListHolder
       
   892     "aspect for the 'list of files' list.
       
   893      <return: List>"
       
   894 
       
   895     fileListHolder isNil ifTrue:[
       
   896         fileListHolder := List new
       
   897     ].    
       
   898     ^ fileListHolder
       
   899 
       
   900     "Created: / 07-07-2019 / 19:46:44 / Claus Gittinger"
       
   901 !
       
   902 
       
   903 fileNameListHolder
       
   904     "aspect for the 'list of file' list.
       
   905      <return: List>"
       
   906 
       
   907     ^ BlockValue
       
   908         with:[:l | l collect:#baseName]
       
   909         argument:(self fileListHolder)
       
   910 
       
   911     "Created: / 07-07-2019 / 19:47:13 / Claus Gittinger"
       
   912 !
       
   913 
       
   914 infoHolder
       
   915     ^ infoHolder.
       
   916 
       
   917     "Modified: / 08-05-2019 / 11:05:10 / Claus Gittinger"
       
   918 !
       
   919 
       
   920 selectedFileIndexHolder
       
   921     selectedFileIndexHolder isNil ifTrue:[
       
   922         selectedFileIndexHolder := nil asValue. 
       
   923         selectedFileIndexHolder onChangeSend:#selectedFileIndexHolderChanged to:self.
       
   924     ].
       
   925     ^ selectedFileIndexHolder
       
   926 
       
   927     "Created: / 07-07-2019 / 19:00:13 / Claus Gittinger"
       
   928 !
       
   929 
       
   930 selectedSymbolicVersionHolder
       
   931     ^ selectedSymbolicVersionHolder
       
   932 
       
   933     "Modified: / 08-05-2019 / 11:08:42 / Claus Gittinger"
       
   934 !
       
   935 
       
   936 selectedSymbolicVersionIndexHolder
       
   937     ^ selectedSymbolicVersionIndexHolder
       
   938 
       
   939     "Created: / 28-05-2019 / 15:32:03 / Claus Gittinger"
       
   940 !
       
   941 
       
   942 selectedVersionHolder
       
   943     ^ selectedVersionHolder
       
   944 
       
   945     "Modified: / 08-05-2019 / 11:09:18 / Claus Gittinger"
       
   946 !
       
   947 
       
   948 selectedVersionIndex
       
   949     ^ selectedVersionIndexHolder value ? 0
       
   950 
       
   951     "Created: / 23-05-2018 / 11:35:50 / Claus Gittinger"
       
   952     "Modified: / 08-05-2019 / 11:09:50 / Claus Gittinger"
       
   953 !
       
   954 
       
   955 selectedVersionIndexHolder
       
   956     ^ selectedVersionIndexHolder
       
   957 
       
   958     "Created: / 29-11-2017 / 13:02:49 / cg"
       
   959     "Modified: / 08-05-2019 / 11:09:46 / Claus Gittinger"
       
   960 !
       
   961 
       
   962 symbolicVersionList
       
   963     ^ symbolicVersionList
       
   964 
       
   965     "Modified: / 08-05-2019 / 11:10:23 / Claus Gittinger"
       
   966 !
       
   967 
       
   968 symbolicVersionNameList
       
   969     ^ symbolicVersionNameList
       
   970 
       
   971     "Created: / 28-05-2019 / 15:42:12 / Claus Gittinger"
       
   972 !
       
   973 
       
   974 versionEntriesList
       
   975     ^ versionEntriesList
       
   976 
       
   977     "Created: / 29-11-2017 / 13:06:14 / cg"
       
   978     "Modified: / 08-05-2019 / 11:10:38 / Claus Gittinger"
       
   979 !
       
   980 
       
   981 versionList
       
   982     ^ versionList
       
   983 
       
   984     "Modified: / 08-05-2019 / 11:10:53 / Claus Gittinger"
       
   985 ! !
       
   986 
       
   987 !FileVersionDiffBrowser methodsFor:'aspects-menu'!
       
   988 
       
   989 hasNextVersionInVersionList
       
   990     "versions are sorted youngest first.
       
   991      If the current selected one is the first, there is no next version"
       
   992      
       
   993     ^ (self selectedVersionIndex) > 1.
       
   994 
       
   995     "Modified: / 23-05-2018 / 11:36:33 / Claus Gittinger"
       
   996 !
       
   997 
       
   998 hasPreviousVersionInVersionList 
       
   999     "versions are sorted youngest first.
       
  1000      If the current selected one is the last, there is no previous version"
       
  1001 
       
  1002     ^ (self selectedVersionIndex) < versionList value size.
       
  1003 
       
  1004     "Modified: / 23-05-2018 / 11:36:38 / Claus Gittinger"
       
  1005 !
       
  1006 
       
  1007 versionsMenu
       
  1008     ^ [ 
       
  1009         |m item nextVersion prevVersion|
       
  1010 
       
  1011         m := self class versionsMenu.
       
  1012         m := m decodeAsLiteralArray.
       
  1013         m findGuiResourcesIn:self.
       
  1014 
       
  1015         self hasNextVersionInVersionList ifTrue:[
       
  1016             nextVersion := self versionList at:(self selectedVersionIndex - 1).
       
  1017             item := m atNameKey:#CompareAgainstNextVersion. 
       
  1018             item label:(resources string:(item label,' (%1)') with:nextVersion).
       
  1019         ].
       
  1020         self hasPreviousVersionInVersionList ifTrue:[
       
  1021             prevVersion := self versionList at:(self selectedVersionIndex + 1).
       
  1022             item := m atNameKey:#CompareAgainstPreviousVersion.
       
  1023             item label:(resources string:(item label,'(%1)') with:prevVersion).
       
  1024         ].
       
  1025         m
       
  1026       ]
       
  1027 
       
  1028     "Modified: / 23-05-2018 / 11:36:18 / Claus Gittinger"
       
  1029 ! !
       
  1030 
       
  1031 !FileVersionDiffBrowser methodsFor:'change & update'!
       
  1032 
       
  1033 selectVersion:version
       
  1034     |idx numShownBefore numShownAfter|
       
  1035 
       
  1036     idx := versionList indexOf:version.
       
  1037     "/ if not found, get more version infos
       
  1038     [idx == 0] whileTrue:[
       
  1039         numShownBefore := versionList size.
       
  1040         self updateVersionList.
       
  1041         numShownAfter := versionList size.
       
  1042         idx := versionList indexOf:version.
       
  1043         idx == 0 ifTrue:[
       
  1044             numShownBefore == numShownAfter ifTrue:[
       
  1045                 ^ self
       
  1046             ].
       
  1047         ].
       
  1048     ].    
       
  1049     self selectedVersionIndexHolder value:idx.
       
  1050 
       
  1051     "Created: / 28-05-2019 / 14:58:37 / Claus Gittinger"
       
  1052 !
       
  1053 
       
  1054 selectedFileIndexHolderChanged
       
  1055     |fn|
       
  1056 
       
  1057     fn := self fileListHolder value at:(self selectedFileIndexHolder value).
       
  1058 
       
  1059     self fileHolder value:fn.
       
  1060     (self isMultipleVersionBrowser or:[self isMultipleFilesVersionBrowser]) ifTrue:[
       
  1061         self withWaitCursorDo:[
       
  1062             self updateVersionList.
       
  1063         ]
       
  1064     ]
       
  1065 
       
  1066     "Created: / 07-07-2019 / 19:51:17 / Claus Gittinger"
       
  1067     "Modified: / 08-07-2019 / 00:30:51 / Claus Gittinger"
       
  1068 !
       
  1069 
       
  1070 selectedSymbolicVersionHolderChanged
       
  1071     |symbolicTag version|
       
  1072 
       
  1073     symbolicTag := self selectedSymbolicVersionHolder value.
       
  1074     version := symbolicToVersionMapping at:symbolicTag ifAbsent:nil.
       
  1075     version isNil ifTrue:[
       
  1076         symbolicTag = '-' ifFalse:[
       
  1077             Dialog warn:'No version has this tag ("%1")' with:symbolicTag.
       
  1078         ].
       
  1079         ^ self.
       
  1080     ].
       
  1081     self selectVersion:version
       
  1082 
       
  1083     "Modified: / 28-05-2019 / 14:57:56 / Claus Gittinger"
       
  1084 !
       
  1085 
       
  1086 selectedSymbolicVersionIndexHolderChanged
       
  1087     self selectedSymbolicVersionHolder value:(symbolicVersionList at:self selectedSymbolicVersionIndexHolder value)
       
  1088 
       
  1089     "Created: / 28-05-2019 / 15:32:47 / Claus Gittinger"
       
  1090 !
       
  1091 
       
  1092 selectedVersionHolderChanged
       
  1093 
       
  1094     self withWaitCursorDo:[
       
  1095         |idx|
       
  1096 
       
  1097         "/ possibly expand a contracted list
       
  1098         selectedVersionHolder value = '...' ifTrue:[
       
  1099             idx := self versionList size.
       
  1100             self updateVersionList.
       
  1101             selectedVersionHolder setValue:(self versionList at:idx).
       
  1102         ].
       
  1103 
       
  1104         "/ update the view
       
  1105         self 
       
  1106             setupForFile:fileHolder value 
       
  1107             againstVersion:(selectedVersionHolder value).
       
  1108 
       
  1109         "/ self showVersionInfoIfNothingSelected
       
  1110     ]
       
  1111 
       
  1112     "Modified: / 06-02-2017 / 02:32:24 / cg"
       
  1113     "Modified: / 08-07-2019 / 00:05:30 / Claus Gittinger"
       
  1114 !
       
  1115 
       
  1116 selectedVersionIndexHolderChanged
       
  1117     self selectedVersionHolder value:(versionList at:self selectedVersionIndexHolder value)
       
  1118 
       
  1119     "Created: / 29-11-2017 / 13:04:12 / cg"
       
  1120 !
       
  1121 
       
  1122 showActivity:someMessage
       
  1123     "some activityNotification shalt be communicated to the user."
       
  1124 
       
  1125     infoHolder value:someMessage.
       
  1126 
       
  1127     "Created: / 28-05-2019 / 15:26:34 / Claus Gittinger"
       
  1128 !
       
  1129 
       
  1130 update:something with:parameter from:changedObject
       
  1131     (changedObject == fileHolder
       
  1132     or:[changedObject == versionAHolder
       
  1133     or:[changedObject == versionBHolder]]) ifTrue:[
       
  1134         self setupForFile:(fileHolder value) versionA:(versionAHolder value) versionB:(versionBHolder value).
       
  1135         ^ self
       
  1136     ].
       
  1137     super update:something with:parameter from:changedObject
       
  1138 
       
  1139     "Modified: / 17-07-2012 / 17:48:58 / cg"
       
  1140     "Modified: / 08-07-2019 / 00:09:19 / Claus Gittinger"
       
  1141 !
       
  1142 
       
  1143 updateLists
       
  1144     "walk over the changeSet(s) and setup the 3 lists:
       
  1145      onlyInA, changed, onlyInB,
       
  1146      Optionally filter extensions, categoryChanges and versionMethods,
       
  1147      changes with same semantic (variable renames)
       
  1148      and changes which have been explicitly filtered by the user."
       
  1149 
       
  1150     |listOnlyInA listOnlyInB listChanged
       
  1151      printStringGenerator "sortBlockForChangeLists" filteredList
       
  1152      numIgnoredExtensions numIgnoredVersionMethods 
       
  1153      info needFilter entryIsForCommentOrFormatOnly
       
  1154      isIgnoredChange|
       
  1155 
       
  1156 "/    listOnlyInA := filteredList := self methodsOnlyInA.
       
  1157 "/    listOnlyInA removeAll.
       
  1158 "/    classChangeSet notNil ifTrue:[
       
  1159 "/        "/ classChangeSet methodsOnlyInA sort:sortBlockForChangeLists.
       
  1160 "/        filteredList := classChangeSet methodsOnlyInA reject:isIgnoredChange.
       
  1161 "/        listOnlyInA addAll: (filteredList collect:printStringGenerator).
       
  1162 "/    ].
       
  1163 "/    methodsOnlyInAFiltered := filteredList.
       
  1164 "/
       
  1165 "/    listOnlyInB := filteredList := self methodsOnlyInB.
       
  1166 "/    listOnlyInB removeAll.
       
  1167 "/    classChangeSet notNil ifTrue:[
       
  1168 "/        "/ classChangeSet methodsOnlyInB sort:sortBlockForChangeLists.
       
  1169 "/        filteredList := classChangeSet methodsOnlyInB reject:isIgnoredChange.
       
  1170 "/        listOnlyInB addAll: (filteredList collect:printStringGenerator).
       
  1171 "/    ].
       
  1172 "/    methodsOnlyInBFiltered := filteredList.
       
  1173 
       
  1174 "/    entryIsForCommentOrFormatOnly :=
       
  1175 "/        [:entry |
       
  1176 "/            |commentOnly changeA changeB mthdA mthdB|
       
  1177 "/
       
  1178 "/            commentOnly := false.
       
  1179 "/            
       
  1180 "/            changeA := entry first.
       
  1181 "/            changeB := entry second.
       
  1182 "/            changeA isMethodChange ifTrue:[
       
  1183 "/                changeA isMethodCodeChange ifTrue:[
       
  1184 "/                    RBCodeDuplicationRule notNil ifTrue:[
       
  1185 "/                        mthdA := RBMethod forMethodChange:changeA.
       
  1186 "/                        mthdB := RBMethod forMethodChange:changeB.
       
  1187 "/                        commentOnly := RBCodeDuplicationRule hasMethod:mthdA sameSemanticAs:mthdB.
       
  1188 "/                    ].
       
  1189 "/                ] ifFalse:[
       
  1190 "/                    changeA isMethodCategoryChange ifTrue:[
       
  1191 "/                        commentOnly := true
       
  1192 "/                    ] ifFalse:[    
       
  1193 "/                        self breakPoint:#cg
       
  1194 "/                    ].    
       
  1195 "/                ].    
       
  1196 "/            ] ifFalse:[
       
  1197 "/                changeA isClassDefinitionChange ifTrue:[
       
  1198 "/                    changeA source = changeB source ifTrue:[
       
  1199 "/                        commentOnly := true
       
  1200 "/                    ] ifFalse:[
       
  1201 "/                        self breakPoint:#cg
       
  1202 "/                    ].    
       
  1203 "/                ] ifFalse:[    
       
  1204 "/                    self breakPoint:#cg
       
  1205 "/                ].
       
  1206 "/            ].
       
  1207 "/            commentOnly
       
  1208 "/        ].
       
  1209         
       
  1210 "/    listChanged := filteredList := self methodsChanged.
       
  1211 "/    listChanged removeAll.
       
  1212 "/    classChangeSet notNil ifTrue:[
       
  1213 "/        "/ classChangeSet methodsChanged sort:[:a :b | sortBlockForChangeLists value:a first value:b first].
       
  1214 "/        filteredList := classChangeSet methodsChanged reject:[:entry | isIgnoredChange value:entry first].
       
  1215 "/
       
  1216 "/        (self hideDiffsWithCommentOrFormattingChangeOnly) ifTrue:[
       
  1217 "/            filteredList := filteredList reject:entryIsForCommentOrFormatOnly.
       
  1218 "/            listChanged addAll: (filteredList collect:[:entry| printStringGenerator value:(entry first)]).
       
  1219 "/        ] ifFalse:[
       
  1220 "/            filteredList do:[:entry| 
       
  1221 "/                |string|
       
  1222 "/
       
  1223 "/                string := printStringGenerator value:(entry first).
       
  1224 "/                (entryIsForCommentOrFormatOnly value:entry) ifTrue:[
       
  1225 "/                    string := string withColor:Color grey.
       
  1226 "/                ].    
       
  1227 "/                listChanged add:string
       
  1228 "/            ].
       
  1229 "/        ].    
       
  1230 "/    ].
       
  1231 "/    methodsChangedFiltered := filteredList.
       
  1232 
       
  1233 "/    self boxAVisible value:(listOnlyInA notEmpty).
       
  1234 "/    self boxBVisible value:(listOnlyInB notEmpty).
       
  1235 
       
  1236 "/    self boxMVisible value:(listChanged isEmpty
       
  1237 "/                            and: [(listOnlyInA notEmpty
       
  1238 "/                                  or:[listOnlyInB notEmpty])]) not.
       
  1239 
       
  1240     self information:info
       
  1241 
       
  1242     "Modified (comment): / 06-02-2017 / 10:09:11 / cg"
       
  1243     "Modified (format): / 16-02-2017 / 11:11:49 / stefan"
       
  1244     "Modified: / 07-07-2019 / 19:08:03 / Claus Gittinger"
       
  1245 !
       
  1246 
       
  1247 updateVersionList
       
  1248     "asks the classes source code manager for a list of revisions;
       
  1249      construct versionInfoList (containing the full info), versionList (containing version numbers only)
       
  1250      and tagList (containing symbolic names only).
       
  1251      This is only used when comparing multiple versions."
       
  1252 
       
  1253     |fn sourceCodeManager numShown newNumShown numOverallRevisions
       
  1254      partialLog newestRev revisions revisionEntries symbolicNames
       
  1255      stableRevision releasedRevision tagList logMessages|
       
  1256 
       
  1257     fn := fileHolder value.
       
  1258     fn isNil ifTrue:[
       
  1259         symbolicVersionList contents:#().
       
  1260         symbolicVersionNameList contents:#().
       
  1261         self versionList contents:#().
       
  1262         self versionEntriesList contents:#().
       
  1263         ^ self
       
  1264     ]. 
       
  1265  
       
  1266     sourceCodeManager := CVSSourceCodeManager.
       
  1267 
       
  1268     numShown := versionList size - 1.
       
  1269     newNumShown := (numShown + 50) max:30.
       
  1270 
       
  1271     infoHolder value:'Getting version log...'.
       
  1272     partialLog := sourceCodeManager revisionLogOfFile:fn numberOfRevisions:newNumShown.
       
  1273 
       
  1274     partialLog isNil ifTrue:[
       
  1275         self warn:'Could not find/access the container for ',fn name,' in the repository.
       
  1276 This could be due to:
       
  1277     - invalid/wrong CVS-Root setting
       
  1278     - missing CVS access rights
       
  1279         (no access / not logged in)
       
  1280     - changed CVSRoot after compilation
       
  1281         (i.e. wrong CVS-path in classes version method)
       
  1282 '.
       
  1283         ^ nil
       
  1284     ].
       
  1285 
       
  1286     numOverallRevisions := partialLog at:#numberOfRevisions.
       
  1287     newestRev := partialLog at:#newestRevision.
       
  1288     revisions := partialLog at:#revisions.
       
  1289     
       
  1290     "/ fetch the symbolic (tag) version list
       
  1291     symbolicNames := partialLog at:#symbolicNames ifAbsent:[].
       
  1292     symbolicNames notNil ifTrue:[
       
  1293         stableRevision := symbolicNames at:'stable' ifAbsent:[].
       
  1294         releasedRevision := symbolicNames at:'released' ifAbsent:[].
       
  1295 
       
  1296         tagList := ((symbolicNames associations 
       
  1297                         sort:[:a :b | sourceCodeManager versionString:(a value) isLessThan:(b value)])
       
  1298                             collect:[:assoc | assoc key]) reverse.
       
  1299 "/        tagList := ((symbolicNames associations 
       
  1300 "/                        sort:[:a :b | a key < b key])
       
  1301 "/                            collect:[:assoc | assoc key]) reverse.
       
  1302 
       
  1303         tagList remove:'stable' ifAbsent:[].
       
  1304         stableRevision notNil ifTrue:[
       
  1305             tagList notEmpty ifTrue:[tagList addFirst:'-'].
       
  1306             tagList addFirst:'stable'.
       
  1307         ].
       
  1308     ].
       
  1309     logMessages := Dictionary new.
       
  1310 
       
  1311     versionInfoList := revisions.
       
  1312 
       
  1313 "/    items := versionInfoList collect:[:each | |rev date who flag|
       
  1314 "/                                    rev := each at:#revision.
       
  1315 "/                                    logMessages at:rev put:(each at:#logMessage).
       
  1316 "/                                    date := (each at:#date ifAbsent:nil) ? '?'.
       
  1317 "/                                    who := (each at:#author ifAbsent:nil) ? '?'.
       
  1318 "/                                    rev = stableRevision ifTrue:[
       
  1319 "/                                        flag := ' Stable' allBold.
       
  1320 "/                                    ] ifFalse:[rev = releasedRevision ifTrue:[
       
  1321 "/                                        flag := ' Released' allBold.
       
  1322 "/                                    ] ifFalse:[
       
  1323 "/                                        flag := ' '
       
  1324 "/                                    ]].
       
  1325 "/                                    rev allBold , flag, ' [' , date , ' by ' , who , ']'
       
  1326 "/                               ].
       
  1327 "/
       
  1328 "/    revisions := revisions collect:[:eachItem | eachItem at:#revision].
       
  1329     revisions := OrderedCollection new.
       
  1330     revisionEntries := OrderedCollection new.
       
  1331     versionInfoList do:[:eachVersionInfo |
       
  1332         revisions add:eachVersionInfo revision.
       
  1333         revisionEntries add:(
       
  1334                     (eachVersionInfo revision)
       
  1335                     , ((' (by %2 at %3)' 
       
  1336                         bindWith:(eachVersionInfo revision)
       
  1337                         with:(eachVersionInfo user)
       
  1338                         with:(eachVersionInfo date)) withColor:Color grey)).
       
  1339     ].
       
  1340 
       
  1341     revisions size < numOverallRevisions ifTrue:[
       
  1342         revisions add:'...'.
       
  1343         revisionEntries add:'...'.
       
  1344     ].          
       
  1345 
       
  1346     symbolicToVersionMapping := symbolicNames.
       
  1347 
       
  1348     symbolicVersionList contents:tagList.
       
  1349 
       
  1350     symbolicVersionNameList 
       
  1351         contents:(
       
  1352             tagList 
       
  1353                 collect:[:eachSymbolic |
       
  1354                     |versionsString|
       
  1355 
       
  1356                     eachSymbolic = '-' ifTrue:[
       
  1357                         eachSymbolic.
       
  1358                     ] ifFalse:[    
       
  1359                         versionsString := symbolicToVersionMapping at:eachSymbolic ifAbsent:'<<none>>'.
       
  1360                         eachSymbolic,((' (',versionsString,')') withColor:Color grey)
       
  1361                     ]
       
  1362                 ]).
       
  1363     self versionList contents:revisions.
       
  1364     self versionEntriesList contents:revisionEntries.
       
  1365     infoHolder value:'Done.'.
       
  1366 
       
  1367     "Modified: / 29-11-2017 / 13:06:21 / cg"
       
  1368     "Modified: / 07-07-2019 / 23:44:42 / Claus Gittinger"
       
  1369 ! !
       
  1370 
       
  1371 !FileVersionDiffBrowser methodsFor:'initialization & release'!
       
  1372 
       
  1373 initialize
       
  1374     super initialize.
       
  1375     
       
  1376     isMultipleVersionBrowser := false.
       
  1377     isMultipleFilesVersionBrowser := false.
       
  1378 
       
  1379     diffTextLabelA := ValueHolder new.
       
  1380     diffTextLabelB := ValueHolder new.
       
  1381     infoHolder := ValueHolder new.
       
  1382 
       
  1383     selectedSymbolicVersionIndexHolder := nil asValue.
       
  1384     selectedSymbolicVersionIndexHolder onChangeSend:#selectedSymbolicVersionIndexHolderChanged to:self.
       
  1385 
       
  1386     selectedSymbolicVersionHolder := nil asValue.
       
  1387     selectedSymbolicVersionHolder onChangeSend:#selectedSymbolicVersionHolderChanged to:self.
       
  1388 
       
  1389     selectedVersionIndexHolder := nil asValue.
       
  1390     selectedVersionIndexHolder onChangeSend:#selectedVersionIndexHolderChanged to:self.
       
  1391 
       
  1392     selectedVersionHolder := nil asValue.
       
  1393     selectedVersionHolder onChangeSend:#selectedVersionHolderChanged to:self.
       
  1394       
       
  1395     symbolicVersionList := List new.
       
  1396     symbolicVersionNameList := List new.
       
  1397     versionEntriesList := List new.
       
  1398     versionList := List new.
       
  1399 
       
  1400     "Created: / 08-05-2019 / 10:59:30 / Claus Gittinger"
       
  1401     "Modified: / 08-07-2019 / 00:06:27 / Claus Gittinger"
       
  1402 !
       
  1403 
       
  1404 postBuildWith:aBuilder
       
  1405     "
       
  1406     components which are invisible should be ignored by the panel.
       
  1407     Cannot be set via the interface builder.
       
  1408 
       
  1409     <return: self>
       
  1410     "
       
  1411 
       
  1412     super postBuildWith:aBuilder
       
  1413 
       
  1414     "Modified: / 07-07-2019 / 23:56:48 / Claus Gittinger"
       
  1415 !
       
  1416 
       
  1417 postOpenWith:aBuilder
       
  1418     super postOpenWith:aBuilder.
       
  1419 
       
  1420     self isMultipleVersionBrowser ifTrue:[
       
  1421         self withWaitCursorDo:[
       
  1422             self updateVersionList.
       
  1423         ]
       
  1424     ]
       
  1425 ! !
       
  1426 
       
  1427 !FileVersionDiffBrowser methodsFor:'menu action'!
       
  1428 
       
  1429 mainMenu
       
  1430     "if this application runs as an subapplication,
       
  1431      the menu bar should not be used."
       
  1432 
       
  1433     self masterApplication isNil ifTrue:[
       
  1434 	^ self class mainMenu
       
  1435     ].
       
  1436     ^ nil
       
  1437 
       
  1438     "Modified: / 25-07-2006 / 11:13:44 / cg"
       
  1439 !
       
  1440 
       
  1441 menuAHolder
       
  1442     ^ [ self class menuA ]
       
  1443 
       
  1444     "Created: / 05-02-2017 / 10:07:15 / cg"
       
  1445 !
       
  1446 
       
  1447 menuBHolder
       
  1448     ^ [ self class menuB ]
       
  1449 
       
  1450     "Created: / 05-02-2017 / 10:07:22 / cg"
       
  1451 !
       
  1452 
       
  1453 menuMHolder
       
  1454     ^ [ self class menuM ]
       
  1455 
       
  1456     "Created: / 05-02-2017 / 10:07:36 / cg"
       
  1457 !
       
  1458 
       
  1459 openDocumentation
       
  1460     HTMLDocumentView openFullOnDocumentationFile:'tools/misc/TOP.html#VERSIONDIFF'
       
  1461 !
       
  1462 
       
  1463 versionMenuCompareAgainstNextVersion
       
  1464     |fn selectedVersion nextVersion|
       
  1465 
       
  1466     selectedVersion := self selectedVersionHolder value.
       
  1467     nextVersion := self versionList at:(self selectedVersionIndex - 1).
       
  1468     fn := fileHolder value.
       
  1469     
       
  1470     self class 
       
  1471         openOnFile:fn versionA:selectedVersion versionB:nextVersion
       
  1472 
       
  1473     "Modified: / 08-07-2019 / 00:09:54 / Claus Gittinger"
       
  1474 !
       
  1475 
       
  1476 versionMenuCompareAgainstPreviousVersion
       
  1477     |fn selectedVersion prevVersion|
       
  1478 
       
  1479     selectedVersion := self selectedVersionHolder value.
       
  1480     selectedVersion isNil ifTrue:[
       
  1481         self selectedVersionIndexHolder value:1
       
  1482     ].    
       
  1483     prevVersion := self versionList at:(self selectedVersionIndex + 1).
       
  1484     fn := fileHolder value.
       
  1485     
       
  1486     self class 
       
  1487         openOnFile:fn versionA:prevVersion versionB:selectedVersion
       
  1488 
       
  1489     "Modified: / 08-07-2019 / 00:10:12 / Claus Gittinger"
       
  1490 ! !
       
  1491 
       
  1492 !FileVersionDiffBrowser methodsFor:'private'!
       
  1493 
       
  1494 addAcceptToTextViewMenus
       
  1495     "add to the standard diff text view or single text views menu an accept entry.
       
  1496      The acceptAction will fetch the corresponding change and apply it
       
  1497      (not the shown text)
       
  1498 
       
  1499      <return: self>
       
  1500     "
       
  1501 
       
  1502     |diffTextView leftView rightView singleView|
       
  1503 
       
  1504     diffTextView := self diffTextView.
       
  1505     leftView := diffTextView leftTextView.
       
  1506     rightView := diffTextView rightTextView.
       
  1507     singleView := self componentAt:#singleTextView.
       
  1508 
       
  1509     (Array
       
  1510         with:leftView
       
  1511         with:rightView
       
  1512         with:singleView)
       
  1513     do:[:v |
       
  1514         |mGen|
       
  1515 
       
  1516         mGen := [
       
  1517             |m|
       
  1518 
       
  1519             m := v editMenu.
       
  1520 
       
  1521             (m selectorAt:#accept) isNil ifTrue:[
       
  1522                 m addLabels:(resources array:#('-' 'Accept'))
       
  1523                   selectors:#(nil #accept)
       
  1524                   after:#copySelection.
       
  1525             ].
       
  1526             m
       
  1527                 actionAt:#accept
       
  1528                 put:[
       
  1529                     v == singleView ifTrue:[
       
  1530                         self acceptInSingleView
       
  1531                     ] ifFalse:[
       
  1532                         v == leftView ifTrue:[
       
  1533                            self acceptInLeftView
       
  1534                         ] ifFalse:[
       
  1535                            self acceptInRightView
       
  1536                         ].
       
  1537                     ].
       
  1538                 ].
       
  1539             m selectorAt:#accept put:nil.
       
  1540             m enable:#copySelection.
       
  1541             m setEnable:#accept to:[self canAcceptInCodeView].
       
  1542             m
       
  1543         ].
       
  1544         v menuHolder:mGen.
       
  1545         v menuMessage:#value.
       
  1546     ]
       
  1547 !
       
  1548 
       
  1549 getFile:fileName version:version
       
  1550     |errStream errorMessages inStream contents|
       
  1551 
       
  1552     errStream := '' writeStream.
       
  1553     [
       
  1554         inStream := PipeStream 
       
  1555                     readingFrom:('cvs update -p -r %1 %2' 
       
  1556                                     bindWith:(version ? '')
       
  1557                                     with:fileName baseName)
       
  1558                     errorDisposition:errStream
       
  1559                     inDirectory:fileName directory pathName.                
       
  1560         contents := inStream upToEnd.
       
  1561     ] ensure:[
       
  1562         inStream notNil ifTrue:[
       
  1563             inStream close
       
  1564         ]
       
  1565     ].
       
  1566     contents isEmptyOrNil ifTrue:[
       
  1567         errorMessages := errStream contents.
       
  1568         errorMessages notEmptyOrNil ifTrue:[
       
  1569             self halt.
       
  1570         ].    
       
  1571     ].    
       
  1572     ^ contents
       
  1573 
       
  1574     "Created: / 07-07-2019 / 22:09:21 / Claus Gittinger"
       
  1575     "Modified: / 08-07-2019 / 01:24:35 / Claus Gittinger"
       
  1576 !
       
  1577 
       
  1578 informationUntranslated:msg
       
  1579     self infoHolder value:msg
       
  1580 
       
  1581     "Created: / 09-08-2018 / 15:40:52 / Claus Gittinger"
       
  1582 !
       
  1583 
       
  1584 resetSelectionHolders
       
  1585     "
       
  1586     reset all selection holders when a new change set is given.
       
  1587     First set the selection to nil.
       
  1588 
       
  1589     <return: self>
       
  1590     "
       
  1591 
       
  1592     self diffTextView text1:'' text2:''.
       
  1593 
       
  1594     "Modified (comment): / 08-07-2019 / 00:06:09 / Claus Gittinger"
       
  1595 !
       
  1596 
       
  1597 showDiffTextView
       
  1598     "
       
  1599     if a method change is selected, then show the diff text view.
       
  1600     Add an accept entry to the popup menu.
       
  1601 
       
  1602     <return: self>
       
  1603     "
       
  1604 
       
  1605     (self componentAt:#diffTextViewBox) raise; beVisible.
       
  1606     (self componentAt:#diffTextView) realizeAllSubViews.
       
  1607 
       
  1608     "/ self addAcceptToTextViewMenus.
       
  1609 
       
  1610     "Modified: / 08-07-2019 / 00:02:19 / Claus Gittinger"
       
  1611 !
       
  1612 
       
  1613 showSingleTextView
       
  1614     "
       
  1615     if a method  is selected which is only in version A or B of the class,
       
  1616     then show the text view.
       
  1617     Add an accept entry to the popup menu.
       
  1618 
       
  1619     <return: self>
       
  1620     "
       
  1621 
       
  1622     (self componentAt:#diffTextViewBox) beInvisible.
       
  1623     "/ self addAcceptToTextViewMenus.
       
  1624 
       
  1625     "Modified: / 08-07-2019 / 00:03:10 / Claus Gittinger"
       
  1626 !
       
  1627 
       
  1628 showVersionInfoIfNothingSelected
       
  1629     "show the revision info (author, date, time and logMessage), 
       
  1630      if no method is selected"
       
  1631 
       
  1632     |revInfo infoText|
       
  1633 
       
  1634     "/ self information:''.
       
  1635 
       
  1636     versionInfoList notNil ifTrue:[
       
  1637         revInfo := versionInfoList detect:[:info | (info at:#revision) = selectedVersionHolder value] ifNone:nil.
       
  1638         revInfo notNil ifTrue:[
       
  1639             infoText := 'Revision: %1\Author:   %2\Date:     %3\Log:\\%4' withCRs
       
  1640                             bindWith:(revInfo at:#revision) 
       
  1641                             with:(revInfo at:#author) 
       
  1642                             with:(revInfo at:#date)
       
  1643                             with:(revInfo at:#logMessage).
       
  1644         ].
       
  1645     ].    
       
  1646     self showSingleTextView.
       
  1647 
       
  1648     "Modified: / 05-02-2017 / 11:49:47 / cg"
       
  1649     "Modified (comment): / 08-07-2019 / 00:06:32 / Claus Gittinger"
       
  1650 ! !
       
  1651 
       
  1652 !FileVersionDiffBrowser methodsFor:'setup'!
       
  1653 
       
  1654 setupForAllVersionsOfFile:aFilename
       
  1655     self fileHolder value:aFilename.
       
  1656     self updateVersionList.
       
  1657 
       
  1658     "Created: / 07-07-2019 / 22:42:40 / Claus Gittinger"
       
  1659     "Modified: / 07-07-2019 / 23:46:28 / Claus Gittinger"
       
  1660 !
       
  1661 
       
  1662 setupForFile:aFilename againstVersion:aVersionA
       
  1663     "compute the diffs for the file's current version against the repository version A.
       
  1664      When setting the diffs, the labels, list etc. of the receiver
       
  1665      are updated."
       
  1666 
       
  1667     |text1 text2|
       
  1668 
       
  1669     text1 := aFilename contentsAsString.
       
  1670     text2 := self getFile:aFilename version:aVersionA.
       
  1671     
       
  1672     self diffTextView text1:text1 text2:text2.        
       
  1673     self diffTextLabelA value:('File: %1' bindWith:aFilename baseName).
       
  1674     self diffTextLabelB value:aVersionA.
       
  1675 
       
  1676     "Created: / 07-07-2019 / 19:57:27 / Claus Gittinger"
       
  1677     "Modified: / 08-07-2019 / 01:13:47 / Claus Gittinger"
       
  1678 !
       
  1679 
       
  1680 setupForFile:fileA labelA:labelA andFile:fileB labelB:labelB
       
  1681     "generate the diffs from the two files A and B.
       
  1682      When setting the diffs, the labels, list etc. of the receiver
       
  1683      are updated."
       
  1684 
       
  1685     self diffTextView
       
  1686         text1:(fileA contentsAsString) 
       
  1687         text2:(fileB contentsAsString).
       
  1688 
       
  1689     self diffTextLabelA value:labelA.
       
  1690     self diffTextLabelB value:labelB.
       
  1691 
       
  1692     "Created: / 07-07-2019 / 19:59:03 / Claus Gittinger"
       
  1693     "Modified: / 08-07-2019 / 01:14:36 / Claus Gittinger"
       
  1694 ! !
       
  1695 
       
  1696 !FileVersionDiffBrowser class methodsFor:'documentation'!
       
  1697 
       
  1698 version_CVS
       
  1699     ^ '$Header$'
       
  1700 ! !
       
  1701