|
29 | 29 |
|
30 | 30 | // Figure out which user is writing the commit.
|
31 | 31 |
|
32 |
| -if ($repository->isGit()) { |
| 32 | +if ($repository->isGit() || $repository->isHg()) { |
33 | 33 | $username = getenv('PHABRICATOR_USER');
|
34 | 34 | if (!strlen($username)) {
|
35 | 35 | throw new Exception(pht('usage: PHABRICATOR_USER should be defined!'));
|
36 | 36 | }
|
| 37 | + |
| 38 | + // TODO: If this is a Mercurial repository, the hook we're responding to |
| 39 | + // is available in $argv[2]. It's unclear if we actually need this, or if |
| 40 | + // we can block all actions we care about with just pretxnchangegroup. |
| 41 | + |
37 | 42 | } else if ($repository->isSVN()) {
|
38 | 43 | // NOTE: In Subversion, the entire environment gets wiped so we can't read
|
39 | 44 | // PHABRICATOR_USER. Instead, we've set "--tunnel-user" to specify the
|
|
50 | 55 |
|
51 | 56 | $engine->setSubversionTransactionInfo($svn_txn, $svn_repo);
|
52 | 57 | } else {
|
53 |
| - throw new Exceptiont(pht('Unknown repository type.')); |
| 58 | + throw new Exception(pht('Unknown repository type.')); |
54 | 59 | }
|
55 | 60 |
|
56 | 61 | $user = id(new PhabricatorPeopleQuery())
|
|
67 | 72 |
|
68 | 73 | // Read stdin for the hook engine.
|
69 | 74 |
|
70 |
| -$stdin = @file_get_contents('php://stdin'); |
71 |
| -if ($stdin === false) { |
72 |
| - throw new Exception(pht('Failed to read stdin!')); |
| 75 | +if ($repository->isHg()) { |
| 76 | + // Mercurial leaves stdin open, so we can't just read it until EOF. |
| 77 | + $stdin = ''; |
| 78 | +} else { |
| 79 | + // Git and Subversion write data into stdin and then close it. Read the |
| 80 | + // data. |
| 81 | + $stdin = @file_get_contents('php://stdin'); |
| 82 | + if ($stdin === false) { |
| 83 | + throw new Exception(pht('Failed to read stdin!')); |
| 84 | + } |
73 | 85 | }
|
74 | 86 |
|
75 | 87 | $engine->setStdin($stdin);
|
|
0 commit comments