Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13978375
D7784.id17612.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D7784.id17612.diff
View Options
Index: src/applications/diffusion/conduit/ConduitAPI_diffusion_historyquery_Method.php
===================================================================
--- src/applications/diffusion/conduit/ConduitAPI_diffusion_historyquery_Method.php
+++ src/applications/diffusion/conduit/ConduitAPI_diffusion_historyquery_Method.php
@@ -128,6 +128,7 @@
hgsprintf('reverse(%s::%s)', '0', $commit_hash),
$path_arg);
+ $stdout = PhabricatorRepository::filterMercurialDebugOutput($stdout);
$lines = explode("\n", trim($stdout));
$lines = array_slice($lines, $offset);
Index: src/applications/diffusion/query/lowlevel/DiffusionLowLevelMercurialBranchesQuery.php
===================================================================
--- src/applications/diffusion/query/lowlevel/DiffusionLowLevelMercurialBranchesQuery.php
+++ src/applications/diffusion/query/lowlevel/DiffusionLowLevelMercurialBranchesQuery.php
@@ -12,6 +12,7 @@
// NOTE: `--debug` gives us 40-character hashes.
list($stdout) = $repository->execxLocalCommand(
'--debug branches');
+ $stdout = PhabricatorRepository::filterMercurialDebugOutput($stdout);
$branches = array();
Index: src/applications/diffusion/query/parents/DiffusionMercurialCommitParentsQuery.php
===================================================================
--- src/applications/diffusion/query/parents/DiffusionMercurialCommitParentsQuery.php
+++ src/applications/diffusion/query/parents/DiffusionMercurialCommitParentsQuery.php
@@ -10,6 +10,7 @@
list($stdout) = $repository->execxLocalCommand(
'log --debug --limit 1 --template={parents} --rev %s',
$drequest->getStableCommitName());
+ $stdout = PhabricatorRepository::filterMercurialDebugOutput($stdout);
$hashes = preg_split('/\s+/', trim($stdout));
foreach ($hashes as $key => $value) {
Index: src/applications/repository/storage/PhabricatorRepository.php
===================================================================
--- src/applications/repository/storage/PhabricatorRepository.php
+++ src/applications/repository/storage/PhabricatorRepository.php
@@ -440,6 +440,29 @@
return $args;
}
+ /**
+ * Sanitize output of an `hg` command invoked with the `--debug` flag to make
+ * it usable.
+ *
+ * @param string Output from `hg --debug ...`
+ * @return string Usable output.
+ */
+ public static function filterMercurialDebugOutput($stdout) {
+ // When hg commands are run with `--debug` and some config file isn't
+ // trusted, Mercurial prints out a warning to stdout, twice, after Feb 2011.
+ //
+ // http://selenic.com/pipermail/mercurial-devel/2011-February/028541.html
+
+ $lines = preg_split('/(?<=\n)/', $stdout);
+ $regex = '/ignoring untrusted configuration option .*\n$/';
+
+ foreach ($lines as $key => $line) {
+ $lines[$key] = preg_replace($regex, '', $line);
+ }
+
+ return implode('', $lines);
+ }
+
public function getURI() {
return '/diffusion/'.$this->getCallsign().'/';
}
Index: src/applications/repository/storage/__tests__/PhabricatorRepositoryTestCase.php
===================================================================
--- src/applications/repository/storage/__tests__/PhabricatorRepositoryTestCase.php
+++ src/applications/repository/storage/__tests__/PhabricatorRepositoryTestCase.php
@@ -107,5 +107,52 @@
}
+ public function testFilterMercurialDebugOutput() {
+ $map = array(
+ "" => "",
+
+ "quack\n" => "quack\n",
+
+ "ignoring untrusted configuration option x.y = z\nquack\n" =>
+ "quack\n",
+
+ "ignoring untrusted configuration option x.y = z\n".
+ "ignoring untrusted configuration option x.y = z\n".
+ "quack\n" =>
+ "quack\n",
+
+ "ignoring untrusted configuration option x.y = z\n".
+ "ignoring untrusted configuration option x.y = z\n".
+ "ignoring untrusted configuration option x.y = z\n".
+ "quack\n" =>
+ "quack\n",
+
+ "quack\n".
+ "ignoring untrusted configuration option x.y = z\n".
+ "ignoring untrusted configuration option x.y = z\n".
+ "ignoring untrusted configuration option x.y = z\n" =>
+ "quack\n",
+
+ "ignoring untrusted configuration option x.y = z\n".
+ "ignoring untrusted configuration option x.y = z\n".
+ "duck\n".
+ "ignoring untrusted configuration option x.y = z\n".
+ "ignoring untrusted configuration option x.y = z\n".
+ "bread\n".
+ "ignoring untrusted configuration option x.y = z\n".
+ "quack\n" =>
+ "duck\nbread\nquack\n",
+
+ "ignoring untrusted configuration option x.y = z\n".
+ "duckignoring untrusted configuration option x.y = z\n".
+ "quack" =>
+ "duckquack",
+ );
+
+ foreach ($map as $input => $expect) {
+ $actual = PhabricatorRepository::filterMercurialDebugOutput($input);
+ $this->assertEqual($expect, $actual, $input);
+ }
+ }
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Oct 19, 10:55 PM (3 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6734194
Default Alt Text
D7784.id17612.diff (4 KB)
Attached To
Mode
D7784: Work around `hg` echoing warnings to stdout under --debug
Attached
Detach File
Event Timeline
Log In to Comment