mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-27 09:12:41 +01:00
Handle "hg pull" return code change between 2.1 and 2.1.1 more gracefully
Summary: See <https://github.com/facebook/phabricator/issues/102>. Between Feb 1 and Mar 1, the hg released changed the exit code behavior of "hg pull". This broke us mildly (and a bunch of other applications more severely, which is why it was reverted). Detect the common case of this (english) and don't fail. Test Plan: @killermonk, can you try applying this? I'll try to do an upgrade to 2.1 and see if I can also do a proper test. Reviewers: Makinde, btrahan, killermonk Reviewed By: btrahan CC: killermonk, aran, epriestley Differential Revision: https://secure.phabricator.com/D1948
This commit is contained in:
parent
49cc3d9f0d
commit
ec736f9c50
1 changed files with 30 additions and 2 deletions
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -39,7 +39,35 @@ final class PhabricatorRepositoryMercurialPullDaemon
|
|||
// This is a local command, but needs credentials.
|
||||
$future = $repository->getRemoteCommandFuture('pull -u');
|
||||
$future->setCWD($local_path);
|
||||
|
||||
try {
|
||||
$future->resolvex();
|
||||
} catch (CommandException $ex) {
|
||||
$err = $ex->getError();
|
||||
$stdout = $ex->getStdOut();
|
||||
|
||||
// NOTE: Between versions 2.1 and 2.1.1, Mercurial changed the behavior
|
||||
// of "hg pull" to return 1 in case of a successful pull with no changes.
|
||||
// This behavior has been reverted, but users who updated between Feb 1,
|
||||
// 2012 and Mar 1, 2012 will have the erroring version. Do a dumb test
|
||||
// against stdout to check for this possibility.
|
||||
// See: https://github.com/facebook/phabricator/issues/101/
|
||||
|
||||
// NOTE: Mercurial has translated versions, which translate this error
|
||||
// string. In a translated version, the string will be something else,
|
||||
// like "aucun changement trouve". There didn't seem to be an easy way
|
||||
// to handle this (there are hard ways but this is not a common problem
|
||||
// and only creates log spam, not application failures). Assume English.
|
||||
|
||||
// TODO: Remove this once we're far enough in the future that deployment
|
||||
// of 2.1 is exceedingly rare?
|
||||
if ($err == 1 && preg_match('/no changes found/', $stdout)) {
|
||||
return;
|
||||
} else {
|
||||
throw $ex;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue