mercurial/HGCopyrightUpdateTool.st
author convert-repo
Thu, 30 Aug 2018 03:34:47 +0000
changeset 857 fdb5c39711ea
parent 817 e38e4f23a097
child 903 3c6c268d7395
permissions -rw-r--r--
update tags
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
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     4
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     5
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
     6
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
     7
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
     8
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
     9
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    10
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
    11
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
    12
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
    13
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
    14
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    15
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
    16
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
    17
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
    18
"
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    19
"{ 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
    20
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    21
"{ NameSpace: Smalltalk }"
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    22
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    23
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
    24
	instanceVariableNames:''
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    25
	classVariableNames:''
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    26
	poolDictionaries:''
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    27
	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
    28
!
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
!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
    31
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    32
copyright
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    33
"
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    34
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
    35
Copyright (C) 2012-2015 Jan Vrany
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    36
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    37
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
    38
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
    39
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
    40
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
    41
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    42
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
    43
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
    44
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
    45
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
    46
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    47
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
    48
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
    49
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
    50
"
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    51
!
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
documentation
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
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
    56
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    57
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
    58
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    59
 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
    60
    '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
    61
    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
    62
    `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
    63
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    64
 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
    65
    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
    66
    commits.
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    67
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    68
 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
    69
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    70
 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
    71
    backs.
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    72
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    73
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
    74
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
    75
`--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
    76
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    77
"
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
!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
    81
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    82
new
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    83
    "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
    84
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    85
    ^ 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
    86
! !
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    87
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    88
!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
    89
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    90
applicationUUID
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    91
    "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
    92
     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
    93
     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
    94
     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
    95
     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
    96
     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
    97
     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
    98
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    99
    ^ 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
   100
! !
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   101
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   102
!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
   103
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   104
main: argv
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   105
    "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
   106
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   107
    | 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
   108
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   109
    verbose := 0.
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   110
    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
   111
    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
   112
    optparser
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   113
        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
   114
        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
   115
        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
   116
        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
   117
        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
   118
    [
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   119
        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
   120
    ] 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
   121
        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
   122
        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
   123
    ].
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   124
    [
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   125
        | updater repo |
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 := HGCopyrightUpdater new.
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   128
        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
   129
        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
   130
        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
   131
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   132
        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
   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 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
   135
            (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
   136
                [ 
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   137
                    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
   138
                ] 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
   139
                    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
   140
                ].
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   141
            ]
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
        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
   144
    ] 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
   145
        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
   146
        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
   147
            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
   148
        ] ifFalse:[ 
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   149
            ex pass.
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   150
        ].
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   151
    ].
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
    "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
   154
!
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   155
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   156
usage
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   157
    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
   158
    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
   159
    Stdout 
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   160
        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
   161
        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
   162
        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
   163
        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
   164
        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
   165
        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
   166
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   167
    "
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   168
    HGCopyrightUpdateTool usage.
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
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   171
    "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
   172
! !
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   173
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   174
!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
   175
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   176
version_HG
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
    ^ '$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
   179
! !
e38e4f23a097 Added tool to update copyright notices in files based on commits
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   180