[3] | 1 | $Id: readme.txt 978 2009-12-12 20:09:41Z peter $ |
---|
[813] | 2 | {{{ |
---|
[978] | 3 | Copyright (C) 2005 Jari Häkkinen |
---|
| 4 | Copyright (C) 2006, 2007, 2008 Jari Häkkinen, Peter Johansson |
---|
[847] | 5 | Copyright (C) 2009 Peter Johansson |
---|
[3] | 6 | |
---|
[813] | 7 | This file is part of svndigest, http://dev.thep.lu.se/svndigest |
---|
| 8 | |
---|
| 9 | svndigest is free software; you can redistribute it and/or modify it |
---|
| 10 | under the terms of the GNU General Public License as published by the |
---|
| 11 | Free Software Foundation; either version 3 of the License, or (at your |
---|
| 12 | option) any later version. |
---|
| 13 | |
---|
| 14 | svndigest is distributed in the hope that it will be useful, but |
---|
| 15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
| 17 | General Public License for more details. |
---|
| 18 | |
---|
| 19 | You should have received a copy of the GNU General Public License |
---|
| 20 | along with svndigest. If not, see <http://www.gnu.org/licenses/>. |
---|
| 21 | }}} |
---|
| 22 | |
---|
| 23 | |
---|
[341] | 24 | = About svndigest = |
---|
[84] | 25 | |
---|
[341] | 26 | Svndigest traverses a directory structure (controlled by subversion) |
---|
[149] | 27 | and calculates developer statistics for all subversion controlled |
---|
[187] | 28 | entries. The result is written to a sub-directory of a user |
---|
[188] | 29 | specifiable target directory (default is the current working |
---|
[185] | 30 | directory). |
---|
[3] | 31 | |
---|
[341] | 32 | == Statistics == |
---|
| 33 | |
---|
[149] | 34 | To understand what statistics is calculated by svndigest this |
---|
| 35 | definition is needed: The developer who made the latest change to a |
---|
[185] | 36 | line still in use in the latest revision, is considered as the |
---|
| 37 | contributor of that line regardless of who actually originally created |
---|
| 38 | that line. |
---|
[3] | 39 | |
---|
[188] | 40 | For each developer svndigest calculates the number of contributed |
---|
[189] | 41 | lines in the latest (checked out) revision. Svndigest calculates for |
---|
| 42 | each revision, by checking when each line was last changed, how many |
---|
| 43 | lines each developer had contributed at that specific revision and |
---|
[341] | 44 | still are in use. |
---|
[3] | 45 | |
---|
[687] | 46 | see also: http://dev.thep.lu.se/svndigest/wiki/StatsType |
---|
[495] | 47 | |
---|
[341] | 48 | == Different linetypes == |
---|
[188] | 49 | |
---|
[524] | 50 | Svndigest parses each file to decide whether a line is ''code'', |
---|
| 51 | ''comment'', or ''other''. Depending on the file name different |
---|
[341] | 52 | parsing modes are used, which means different sets of rules what is |
---|
[524] | 53 | ''code'' or ''comment'' are employed. Common for all modes is that |
---|
[341] | 54 | comment blocks are identified by a start code (e.g. '/*' in a C file) |
---|
| 55 | and a stop code (e.g. '*/' in a C file). If a line contains |
---|
[505] | 56 | visible characters being outside comment blocks, the line is |
---|
[341] | 57 | considered to be ''code''. Otherwise, if the line contains |
---|
| 58 | alphanumeric characters inside a comment block, the line is considered |
---|
| 59 | to be a line of ''comment''. Otherwise the line is considered to be |
---|
[524] | 60 | ''other''. |
---|
[188] | 61 | |
---|
[526] | 62 | From svndigest 0.7, it is possible to configure which rules are used |
---|
| 63 | for different files. For more on how to configure svndigest see |
---|
| 64 | below. If no configuration file is given or no rules are given, a set |
---|
| 65 | of default rules are used. For files named `*.h`, for example, rules |
---|
| 66 | allowing to detect comments as either `// ... \n` or `/* |
---|
| 67 | ... */`. These rules can be set in the configuration file using a |
---|
[525] | 68 | one-liner like: |
---|
[188] | 69 | |
---|
[524] | 70 | `*.h = "//":"\n" ; "/*":"*/"` |
---|
[342] | 71 | |
---|
[525] | 72 | The first string (`*.h`) is a file-name-pattern describing which files |
---|
[524] | 73 | this rule will be used on. The second block, `"//":"\n"`, is the first |
---|
| 74 | rule saying one way to mark comments is to start with a ''start |
---|
| 75 | code'', `//`, and end with an ''end code'', `\n`. The start and end |
---|
| 76 | codes are surrounded by `""` and separated by `:`. Similarily, the |
---|
[525] | 77 | second block describes that comments also could come as `/* ... */`. |
---|
[524] | 78 | |
---|
[526] | 79 | Sometimes it might be useful if a file could be parsed as though it |
---|
| 80 | was going under a different name. It could, for example, be useful if |
---|
| 81 | files named `Makefile.in` could be parsed as `Makefile` or files named |
---|
| 82 | `test_repo.sh.in` could be parsed as though it was named |
---|
| 83 | `test_repo.sh`. More generally, it would be useful if files named |
---|
| 84 | `<file-name-pattern>.in` could be parsed as though it was named |
---|
| 85 | `<file-name-pattern>`. For this reason it is possible to set rules on |
---|
| 86 | how a filename should be interpreted (see section |
---|
| 87 | [file-name-dictionary] in configuration file). Default behaviour is |
---|
| 88 | that there is only one such a rule in use, namely the one described |
---|
| 89 | above that trailing `.in` in file names are discarded. |
---|
| 90 | |
---|
| 91 | |
---|
[833] | 92 | == Caching Statistics == |
---|
| 93 | |
---|
| 94 | To avoid retrieving the same data repeatedly from the repository, |
---|
[959] | 95 | statistics is cached in files located in `.svndigest`. Subsequent |
---|
[833] | 96 | svndigest runs read the cache files and retrieve information from the |
---|
| 97 | repository only for the revisions that have been committed since the |
---|
| 98 | cache file was created. Obviously, it is important that the cache |
---|
| 99 | files reflect the history of the current working copy. If that is not |
---|
| 100 | the case, for example, if you have switched working copy using `svn |
---|
| 101 | switch`, you can make svndigest ignore the cache through option |
---|
| 102 | `--ignore-cache`. |
---|
| 103 | |
---|
| 104 | |
---|
[341] | 105 | == Different file types == |
---|
[188] | 106 | |
---|
[46] | 107 | There are many different types of files and for many file types it |
---|
[3] | 108 | does not make sense to define lines. Source code, documentation, and |
---|
[185] | 109 | other human readable files can be treated in single line basis whereas |
---|
| 110 | symbolic links and binary files cannot. svndigest treats binary files |
---|
[361] | 111 | and symbolic links as zero-line files. There is a possibility to |
---|
| 112 | exclude files from the statistics, the use of the property |
---|
[711] | 113 | svndigest:ignore. |
---|
[3] | 114 | |
---|
[189] | 115 | Sometimes large test files and XML files are added to the repository |
---|
[185] | 116 | that should not really be counted in the statistics. This is solved |
---|
| 117 | with the svndigest:ignore property. Files with this property are |
---|
[187] | 118 | excluded from statistics. Setting the svndigest:ignore property to a |
---|
[185] | 119 | directory will exclude all siblings to that directory from svndigest |
---|
| 120 | treatment. |
---|
[3] | 121 | |
---|
[711] | 122 | To set the property on file `FILE`, issue `svn propset |
---|
| 123 | svndigest:ignore "" FILE`. For more detailed information refer to |
---|
| 124 | http://svnbook.red-bean.com/. |
---|
| 125 | |
---|
[351] | 126 | == Configuration == |
---|
| 127 | |
---|
[439] | 128 | The configuration file may be used to define various behaviors for |
---|
[351] | 129 | svndigest. By default svndigest looks for a config file named `config` |
---|
| 130 | in directory `<root-dir>/.svndigest` (<root-dir> is directory set by |
---|
| 131 | option `--root`). If no such file is found, svndigest behaves as |
---|
| 132 | default. Which file to be used as config file may also be set with |
---|
| 133 | option `--config-file`. To update an old config file you can use the |
---|
| 134 | option `--generate-config`. With this option set the used |
---|
| 135 | configuration will be written to standard output. If new variables has |
---|
| 136 | been added to configuration of svndigest, these variables will be |
---|
| 137 | written with default values. Note: if you have added a comment (e.g. a |
---|
[353] | 138 | subversion keyword) to your old config file, this will not be |
---|
[351] | 139 | inherited to the new config file. To preserve such a comment you must |
---|
| 140 | merge the new config file with the old config file manually. |
---|
| 141 | |
---|
[970] | 142 | The color used for each author in plots and blame output can be |
---|
| 143 | configured in section [author-color] in config file. The format of the |
---|
| 144 | color string is a 6-digit hexadecimal number in which each color (red, |
---|
| 145 | green and blue) is decribed by 2 digits, i.e. each color is described |
---|
| 146 | by a value between 0 and 255 in hexadecimal format. It is also allowed |
---|
| 147 | to set the color with a 3-digit hexadecimal number in which case, for |
---|
| 148 | example, 'a5b' would be equivalent to 'aa55bb'. |
---|
| 149 | |
---|
[348] | 150 | == Copyright update == |
---|
| 151 | |
---|
| 152 | Using the option `--copyright` svndigest will try to update the |
---|
| 153 | copyright statement in each of the parsed files. The copyright |
---|
| 154 | statement is detected as the first line containing `Copyright |
---|
| 155 | (C)`. The copyright statement block is defined to start at this line |
---|
| 156 | and ends with the first following line containing no alphanumerical |
---|
[444] | 157 | characters (excluding `prefix` string preceeding `Copyright (C)`). This |
---|
[349] | 158 | copyright statement block is replaced with a new copyright statement |
---|
| 159 | generated from analyzing `svn log`. An author is considered to have |
---|
[348] | 160 | copyright of the file if (s)he has modified the file and thereby |
---|
| 161 | occurs in the log. For an example of the format of the generated |
---|
[351] | 162 | copyright statement, please have a look at the bottom of this file. By |
---|
| 163 | default the `svn user name` of the author is printed in the copyright |
---|
| 164 | statement. This may be overridden by setting a `copyright-alias` in |
---|
| 165 | the config file. In svndigest, e.g., user name `jari` is set to |
---|
| 166 | copyright-alias ''Jari Häkkinen'' and user name `peter` is set to |
---|
| 167 | copyright-alias ''Peter Johansson''. If two (or several) authors are |
---|
| 168 | given the same copyright-alias they are considered as one person in |
---|
| 169 | the copyright statement (i.e. their alias is not repeated). This may |
---|
| 170 | be useful if you want to give copyright to an organization rather than |
---|
| 171 | to individual developers. |
---|
[348] | 172 | |
---|
[352] | 173 | == TracLinks == |
---|
| 174 | |
---|
| 175 | From svndigest 0.6 there is support for TracLinks. The root trac |
---|
| 176 | location may be set in the configuration, in which case various links |
---|
| 177 | to the trac site will be included in the resulting report. This |
---|
| 178 | includes links from revision number to the corresponding revision at |
---|
| 179 | the trac site, and various kinds of links are detected in the messages |
---|
| 180 | in `Recent Log`. |
---|
| 181 | |
---|
[341] | 182 | == Prerequisites == |
---|
[3] | 183 | |
---|
[341] | 184 | Svndigest runs against a working copy (WC), i.e., svndigest will not |
---|
| 185 | run directly against a repository. Svndigest requires that the WC is |
---|
| 186 | pristine before running the analysis, i.e., no files are allowed to be |
---|
| 187 | modified. We also recommend that the WC is in synch with the |
---|
| 188 | repository. Issue `svn update` before running svndigest. |
---|
[185] | 189 | |
---|
[341] | 190 | == Flow of the program == |
---|
[3] | 191 | The current flow of the program is. |
---|
| 192 | |
---|
[341] | 193 | * Check that we are working with a WC in subversion control. |
---|
[3] | 194 | |
---|
[520] | 195 | * Build the requested directory structure ignoring not subversion |
---|
| 196 | controlled items. During the directory structure creation a check |
---|
| 197 | is made that the WC is up to date with the repository. |
---|
[3] | 198 | |
---|
[341] | 199 | * Walk through the directory structure and calculate statistics for |
---|
| 200 | each entry. |
---|
[3] | 201 | |
---|
[341] | 202 | * Create the plots and HTML presentation. |
---|
| 203 | |
---|
[959] | 204 | = Copy Cache = |
---|
| 205 | |
---|
| 206 | As explained above, statistics are cached during a run and svndigest |
---|
| 207 | only communicates with the server to retrieve statistics of the |
---|
| 208 | activity since last run. Subsequent runs are much faster why it is |
---|
| 209 | prefereble to run svndigest in a wc with recent cache available. |
---|
| 210 | |
---|
| 211 | Sometimes it is useful to copy the cache from one wc to another, and |
---|
| 212 | an easy way to do this is to use the tool `svndigest-copy-cache`, |
---|
| 213 | which is shipped with svndigest. A common use case is when creating, |
---|
| 214 | say, a release branch from the trunk, in which case you likely will |
---|
| 215 | have two working copies to follow the two branches. If you want to run |
---|
| 216 | svndigest on both of them and you want to avoid the first expensive |
---|
| 217 | run (without cache) you can copy the cache from the trunk wc to the |
---|
| 218 | release-branch wc. |
---|
| 219 | |
---|
| 220 | As explained in the caching section, it is important that the cache |
---|
| 221 | reflects a revision that belong to the history of the wc. So, for |
---|
| 222 | example, when creating a branch it is crucial to copy the cache from |
---|
| 223 | the trunk wc to the new branch wc before running svndigest on trunk |
---|
| 224 | wc. Otherwise the cache will contain information about changesets that |
---|
| 225 | were committed after the new branch were forked out. This will not |
---|
| 226 | only be untrue as these changesets are not in the line of history of |
---|
| 227 | the branch, but it will also cause problems for svndigest when |
---|
| 228 | calculating the statistics of the most recent revisons and result is |
---|
| 229 | undefined due to inconsistency between the cache and the log. For an |
---|
| 230 | example of how `svndigest-copy-cache` may be used please refer to the |
---|
| 231 | ReleaseProcedure of svndigest. |
---|
| 232 | |
---|
| 233 | `svndigest-copy-cache` copies the cache file from `ROOT` tree to the |
---|
| 234 | corresponding directory in `TARGET` tree. The tree structure of the |
---|
| 235 | two working copies must be identical because `svndigest-copy-cache` |
---|
| 236 | will not create any directories in `TARGET` tree except that |
---|
| 237 | `.svndigest` directories are created when necessary. |
---|
| 238 | |
---|
| 239 | Also, `svndigest-copy-cache` is ignorant about svn wc and will parse |
---|
| 240 | through `ROOT` directory and all its sub-directories ,looking for |
---|
| 241 | svndigest cache files, regardless whether they belong to the same svn |
---|
| 242 | working copy or not. Therefore, having other svn wc in subdirectories |
---|
| 243 | of `ROOT` might give an unexpected result. |
---|