|
10 | 10 |
|
11 | 11 | Rerun the Diffusion parser on specific commits and repositories. Mostly
|
12 | 12 | useful for debugging changes to Diffusion.
|
| 13 | +
|
| 14 | +e.g. enqueue reparse owners in the TEST repo for all commits: |
| 15 | +./reparse.php --all TEST --owners |
| 16 | +
|
| 17 | +e.g. do same but exclude before yesterday (local time): |
| 18 | +./reparse.php --all TEST --owners --min-date yesterday |
| 19 | +./reparse.php --all TEST --owners --min-date "today -1 day" |
| 20 | +
|
| 21 | +e.g. do same but exclude before 03/31/2013 (local time): |
| 22 | +./reparse.php --all TEST --owners --min-date "03/31/2013" |
13 | 23 | EOHELP
|
14 | 24 | );
|
15 | 25 |
|
| 26 | +$min_date_usage_examples = |
| 27 | + "Valid examples:\n". |
| 28 | + " 'today', 'today 2pm', '-1 hour', '-2 hours', '-24 hours',\n". |
| 29 | + " 'yesterday', 'today -1 day', 'yesterday 2pm', '2pm -1 day',\n". |
| 30 | + " 'last Monday', 'last Monday 14:00', 'last Monday 2pm',\n". |
| 31 | + " '31 March 2013', '31 Mar', '03/31', '03/31/2013',\n". |
| 32 | + "See __http://www.php.net/manual/en/datetime.formats.php__ for more.\n"; |
| 33 | + |
16 | 34 | $args->parseStandardArguments();
|
17 | 35 | $args->parse(
|
18 | 36 | array(
|
|
33 | 51 | array(
|
34 | 52 | 'name' => 'min-date',
|
35 | 53 | 'param' => 'date',
|
36 |
| - 'help' => 'When used with __--all__, this will restrict to '. |
37 |
| - 'reparsing only the commits that are newer than __date__.', |
| 54 | + 'help' => 'Must be used with __--all__, this will exclude commits '. |
| 55 | + 'which are earlier than __date__.'. |
| 56 | + "\n".$min_date_usage_examples, |
38 | 57 | ),
|
39 | 58 | // which parts
|
40 | 59 | array(
|
|
87 | 106 | usage("Specify a commit or repository to reparse.");
|
88 | 107 | }
|
89 | 108 |
|
| 109 | +if ($all_from_repo && $reparse_what) { |
| 110 | + $commits = implode(', ', $reparse_what); |
| 111 | + usage( |
| 112 | + "Specify a commit or repository to reparse, not both:\n". |
| 113 | + "All from repo: ".$all_from_repo."\n". |
| 114 | + "Commit(s) to reparse: ".$commits); |
| 115 | +} |
| 116 | + |
90 | 117 | if (!$reparse_message && !$reparse_change && !$reparse_herald &&
|
91 | 118 | !$reparse_owners && !$reparse_harbormaster) {
|
92 | 119 | usage("Specify what information to reparse with --message, --change, ".
|
93 | 120 | "--herald, --harbormaster, and/or --owners");
|
94 | 121 | }
|
| 122 | + |
| 123 | +$min_timestamp = false; |
| 124 | +if ($min_date) { |
| 125 | + $min_timestamp = strtotime($min_date); |
| 126 | + |
| 127 | + if (!$all_from_repo) { |
| 128 | + usage( |
| 129 | + "You must use --all if you specify --min-date\n". |
| 130 | + "e.g.\n". |
| 131 | + " ./reparse.php --all TEST --owners --min-date yesterday"); |
| 132 | + } |
| 133 | + |
| 134 | + // previous to PHP 5.1.0 you would compare with -1, instead of false |
| 135 | + if (false === $min_timestamp) { |
| 136 | + usage( |
| 137 | + "Supplied --min-date is not valid\n". |
| 138 | + "Supplied value: '".$min_date."'\n". |
| 139 | + $min_date_usage_examples); |
| 140 | + } |
| 141 | +} |
| 142 | + |
95 | 143 | if ($reparse_owners && !$force) {
|
96 | 144 | echo phutil_console_wrap(
|
97 | 145 | "You are about to recreate the relationship entries between the commits ".
|
|
114 | 162 | throw new Exception("Unknown repository {$all_from_repo}!");
|
115 | 163 | }
|
116 | 164 | $constraint = '';
|
117 |
| - if ($min_date) { |
| 165 | + if ($min_timestamp) { |
| 166 | + echo "Excluding entries before UNIX timestamp: ".$min_timestamp."\n"; |
118 | 167 | $table = new PhabricatorRepositoryCommit();
|
119 | 168 | $conn_r = $table->establishConnection('r');
|
120 | 169 | $constraint = qsprintf(
|
121 | 170 | $conn_r,
|
122 |
| - 'AND epoch > unix_timestamp(%s)', |
123 |
| - $min_date); |
| 171 | + 'AND epoch >= %d', |
| 172 | + $min_timestamp); |
124 | 173 | }
|
125 | 174 | $commits = id(new PhabricatorRepositoryCommit())->loadAllWhere(
|
126 | 175 | 'repositoryID = %d %Q',
|
|
236 | 285 |
|
237 | 286 | function usage($message) {
|
238 | 287 | echo phutil_console_format(
|
239 |
| - '**Usage Exception:** '.$message."\n"); |
| 288 | + '**Usage Exception:** '.$message."\n". |
| 289 | + "Use __--help__ to display full help\n"); |
240 | 290 | exit(1);
|
241 | 291 | }
|
0 commit comments