mercurial/HGCopyrightUpdateTool.st
author Jan Vrany <jan.vrany@labware.com>
Fri, 19 Feb 2021 08:29:41 +0000
changeset 924 4d92f234f671
parent 903 3c6c268d7395
permissions -rw-r--r--
Rework and fix HGSourceCodeManager >> #revisionLogOf:...directory:module:` This commit changes the logic in two ways: 1. #newestRevision is now the newest revision in the branch that *contains* given file (not necesarily modidfes it). If there are multiple heads in that branch, pretty much random one is returned. This changes old behavior and therefore this commit updates tests. 2. If a specific single revision is requested, i.e., both from and to revisions are the same, revision log with that single revision is returned no matter whether it modifies the file or even contains that file at all. This is essentially a workaround to fix issue #305. Moreover, this commit simplifies the code a lot by delegating all the changeset searching and filtering to mercurial using revset expressions. See https://swing.fit.cvut.cz/projects/stx-jv/ticket/305#comment:3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
817
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     1
"
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     2
stx:libscm - a new source code management library for Smalltalk/X
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     3
Copyright (C) 2012-2015 Jan Vrany
903
3c6c268d7395 Improve `doCompileCopyrightMethodFor:` to update copyright upon commit
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 817
diff changeset
     4
Copyright (C) 2020 LabWare
817
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     5
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     6
This library is free software; you can redistribute it and/or
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     7
modify it under the terms of the GNU Lesser General Public
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     8
License as published by the Free Software Foundation; either
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     9
version 2.1 of the License. 
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    10
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    11
This library is distributed in the hope that it will be useful,
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    12
but WITHOUT ANY WARRANTY; without even the implied warranty of
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    14
Lesser General Public License for more details.
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    15
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    16
You should have received a copy of the GNU Lesser General Public
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    17
License along with this library; if not, write to the Free Software
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    18
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    19
"
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    20
"{ Package: 'stx:libscm/mercurial' }"
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    21
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    22
"{ NameSpace: Smalltalk }"
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    23
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    24
StandaloneStartupHeadless subclass:#HGCopyrightUpdateTool
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    25
	instanceVariableNames:''
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    26
	classVariableNames:''
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    27
	poolDictionaries:''
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    28
	category:'SCM-Mercurial-StX-Tools'
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    29
!
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    30
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    31
!HGCopyrightUpdateTool class methodsFor:'documentation'!
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    32
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    33
copyright
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    34
"
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    35
stx:libscm - a new source code management library for Smalltalk/X
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    36
Copyright (C) 2012-2015 Jan Vrany
903
3c6c268d7395 Improve `doCompileCopyrightMethodFor:` to update copyright upon commit
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 817
diff changeset
    37
Copyright (C) 2020 LabWare
817
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    38
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    39
This library is free software; you can redistribute it and/or
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    40
modify it under the terms of the GNU Lesser General Public
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    41
License as published by the Free Software Foundation; either
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    42
version 2.1 of the License. 
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    43
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    44
This library is distributed in the hope that it will be useful,
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    45
but WITHOUT ANY WARRANTY; without even the implied warranty of
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    46
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    47
Lesser General Public License for more details.
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    48
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    49
You should have received a copy of the GNU Lesser General Public
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    50
License along with this library; if not, write to the Free Software
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    51
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    52
"
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    53
!
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    54
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    55
documentation
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    56
"
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    57
Update copyright in files based on information in commits.
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    58
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    59
It works as follows:
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    60
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    61
 1. For given file, it computes contributions from commits that 
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    62
    'contributed' to that particular file. Not every commit that 
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    63
    modifies a file is consider a contribution. See comment in
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    64
    `HGContribution class >> hasChangeset:contributedTo:`.
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    65
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    66
 2. Based on contribution generate a set copyright lines. The 
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    67
    years and name of copyright holder is taken from contributing
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    68
    commits.
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    69
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    70
 3. Parse file contents and collect existing copyrights.
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    71
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    72
 4. Finally, add missing copyrights and save updated contents
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    73
    backs.
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    74
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    75
NOTE: that this tool never removes a copyright line, except in one 
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    76
very specific case - if copyright line is in form YYYY-now and option
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    77
`--remove-year-now` is given.
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    78
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    79
"
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    80
! !
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    81
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    82
!HGCopyrightUpdateTool class methodsFor:'instance creation'!
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    83
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    84
new
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    85
    "return an initialized instance"
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    86
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    87
    ^ self basicNew initialize.
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    88
! !
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    89
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    90
!HGCopyrightUpdateTool class methodsFor:'constants & defaults'!
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    91
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    92
applicationUUID
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    93
    "answer an application-specific unique uuid.
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    94
     This is used as the name of some exclusive OS-resource, which is used to find out,
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    95
     if another instance of this application is already running.
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    96
     Under win32, a mutex is used; under unix, an exclusive file in the tempDir could be used.
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    97
     If redefined, please return a real UUID (i.e. UUID fromString:'.....') and not a string or
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    98
     similar possibly conflicting identifier.
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    99
     You can paste a fresh worldwide unique id via the editor's 'more'-'misc'-'paste UUID' menu function."
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   100
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   101
    ^ UUID fromString:'65a29670-3f5e-11e8-982c-606720e43e2c'
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   102
! !
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   103
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   104
!HGCopyrightUpdateTool class methodsFor:'startup'!
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   105
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   106
main: argv
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   107
    "Application entry point. `argv` is the array of command arguments (as Array of Strings)"
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   108
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   109
    | optparser cwd verbose dryrun removeYearToNow patterns |
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   110
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   111
    verbose := 0.
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   112
    dryrun := removeYearToNow := false.
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   113
    optparser := CmdLineParser new.
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   114
    optparser
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   115
        on: #('--cwd') do:[ :value | cwd := value ];
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   116
        on: #('-v' '--verbose') do:[ verbose := verbose + 1 ];
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   117
        on: #(     '--dry-run') do:[ dryrun := true ];
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   118
        on: #(     '--remove-year-now') do:[ removeYearToNow := true ];
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   119
        on: #('-h' '--help') do:[ self usage. Smalltalk exitIfStandalone:0 ].
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   120
    [
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   121
        patterns := optparser parse:argv.
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   122
    ] on: CmdLineOptionError do:[:ex |
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   123
        Stderr nextPutAll: 'ERROR: '; nextPutLine: ex description.
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   124
        Smalltalk exitIfStandalone:0.        
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   125
    ].
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   126
    [
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   127
        | updater repo |
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   128
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   129
        updater := HGCopyrightUpdater new.
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   130
        updater setVerbose: verbose.
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   131
        updater setDryRun: dryrun.
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   132
        updater setRemoveYearToNow: removeYearToNow.  
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   133
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   134
        repo := HGRepository on: cwd ? '.'.
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   135
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   136
        repo workingCopy parent1 root recursiveDirectoryContentsDo:[:file|
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   137
            (file isDirectory not and:[patterns isEmpty or:[ patterns anySatisfy: [:each | file pathName matches: each ] ] ]) ifTrue:[
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   138
                [ 
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   139
                    updater updateFile: file.
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   140
                ] on: Warning do:[:warning | 
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   141
                    Stderr nextPutAll: 'WARNING: '; nextPutLine: warning description.
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   142
                ].
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   143
            ]
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   144
        ].
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   145
        Smalltalk exitIfStandalone: 0.  
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   146
    ] on: Error do:[:ex | 
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   147
        Stderr nextPutAll: 'ERROR: '; nextPutLine: ex description.
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   148
        Smalltalk isStandAloneApp ifTrue:[ 
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   149
            Smalltalk exit:1
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   150
        ] ifFalse:[ 
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   151
            ex pass.
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   152
        ].
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   153
    ].
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   154
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   155
    "Modified: / 10-06-2018 / 21:00:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   156
!
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   157
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   158
usage
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   159
    Stdout nextPutLine: 'Usage: stx --run ', self name, ' [options...] [pattern...]'.
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   160
    Stdout nextPutLine: self commentOrDocumentationString.
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   161
    Stdout 
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   162
        nextPutLine:'Available options:';  
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   163
        nextPutLine:'  --cwd DIR ............ change working directory DIR';
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   164
        nextPutLine:'  -v | --verbose ....... verbose output (repeat for more info)';
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   165
        nextPutLine:'  --dry-run ............ do not modify any file';
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   166
        nextPutLine:'  --remove-year-now .... remove copyrights with years in form ''YYYY-now''';
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   167
        nextPutLine:'  --help ............... output this message'.
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   168
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   169
    "
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   170
    HGCopyrightUpdateTool usage.
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   171
    "
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   172
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   173
    "Modified: / 17-05-2018 / 15:10:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   174
! !
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   175
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   176
!HGCopyrightUpdateTool class methodsFor:'documentation'!
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   177
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   178
version_HG
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   179
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   180
    ^ '$Changeset: <not expanded> $'
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   181
! !
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   182