@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Updating the filtering of Mercurial debug output

Summary:
With newer versions of Mercurial come newer debug messages which need filtered out.

1. In the scenario of Phabricator observing a hosted Mercurial repository which exists on a server in a multi-user environment it's possible that a repository computes branch cache at a tip revision which is not present. When this happens Mercurial will include in the debug output this information. This message indicates that the cache is going to be re-computed. See https://www.mercurial-scm.org/pipermail/mercurial/2014-June/047239.html.
2. Likely in some version with added or improved support for `pager` the debug info seems to indicate when a pager is being invoked for a command. This seems to print out regularly despite piping the stdout.
3. If the repository on Phabricator ever had the `largefiles` extension enabled then some additional details about "updated patterns" will print out.

Test Plan:
I verified an observed repository's history could be browsed, specifically the history of files which previously resulted in "Undefined offset: 1".

Added a unit test to check the results of `filterMercurialDebugOutput()`.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D21677

+77
+2
src/__phutil_library_map__.php
··· 904 904 'DiffusionLowLevelResolveRefsQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelResolveRefsQuery.php', 905 905 'DiffusionMercurialBlameQuery' => 'applications/diffusion/query/blame/DiffusionMercurialBlameQuery.php', 906 906 'DiffusionMercurialCommandEngine' => 'applications/diffusion/protocol/DiffusionMercurialCommandEngine.php', 907 + 'DiffusionMercurialCommandEngineTests' => 'applications/diffusion/protocol/__tests__/DiffusionMercurialCommandEngineTests.php', 907 908 'DiffusionMercurialFileContentQuery' => 'applications/diffusion/query/filecontent/DiffusionMercurialFileContentQuery.php', 908 909 'DiffusionMercurialFlagInjectionException' => 'applications/diffusion/exception/DiffusionMercurialFlagInjectionException.php', 909 910 'DiffusionMercurialRawDiffQuery' => 'applications/diffusion/query/rawdiff/DiffusionMercurialRawDiffQuery.php', ··· 7041 7042 'DiffusionLowLevelResolveRefsQuery' => 'DiffusionLowLevelQuery', 7042 7043 'DiffusionMercurialBlameQuery' => 'DiffusionBlameQuery', 7043 7044 'DiffusionMercurialCommandEngine' => 'DiffusionCommandEngine', 7045 + 'DiffusionMercurialCommandEngineTests' => 'PhabricatorTestCase', 7044 7046 'DiffusionMercurialFileContentQuery' => 'DiffusionFileContentQuery', 7045 7047 'DiffusionMercurialFlagInjectionException' => 'Exception', 7046 7048 'DiffusionMercurialRawDiffQuery' => 'DiffusionRawDiffQuery',
+9
src/applications/diffusion/conduit/DiffusionHistoryQueryConduitAPIMethod.php
··· 166 166 167 167 $last = null; 168 168 foreach (array_reverse($lines) as $line) { 169 + // In the event additional log output is included in future mercurial 170 + // updates, if the line does not contain any semi-colon then log it and 171 + // ignore it. 172 + if (strpos($line, ';') === false) { 173 + phlog(pht( 174 + 'Unexpected output from mercurial "log --debug" command: %s', 175 + $line)); 176 + continue; 177 + } 169 178 list($hash, $parents) = explode(';', $line); 170 179 $parents = trim($parents); 171 180 if (!$parents) {
+24
src/applications/diffusion/protocol/DiffusionMercurialCommandEngine.php
··· 71 71 // 72 72 // Separately, it may fail to write to a different branch cache, and may 73 73 // encounter issues reading the branch cache. 74 + // 75 + // When Mercurial repositories are hosted on external systems with 76 + // multi-user environments it's possible that the branch cache is computed 77 + // on a revision which does not end up being published. When this happens it 78 + // will recompute the cache but also print out "invalid branch cache". 79 + // 80 + // https://www.mercurial-scm.org/pipermail/mercurial/2014-June/047239.html 81 + // 82 + // When observing a repository which uses largefiles, the debug output may 83 + // also contain extraneous output about largefile changes. 84 + // 85 + // At some point Mercurial added/improved support for pager used when 86 + // command output is large. It includes printing out debug information that 87 + // the pager is being started for a command. This seems to happen despite 88 + // the output of the command being piped/read from another process. 89 + // 90 + // When printing color output Mercurial may run into some issue with the 91 + // terminal info. This should never happen in Phabricator since color 92 + // output should be turned off, however in the event it shows up we should 93 + // filter it out anyways. 74 94 75 95 $ignore = array( 76 96 'ignoring untrusted configuration option', 77 97 "couldn't write revision branch cache:", 78 98 "couldn't write branch cache:", 79 99 'invalid branchheads cache', 100 + 'invalid branch cache', 101 + 'updated patterns: .hglf', 102 + 'starting pager for command', 103 + 'no terminfo entry for', 80 104 ); 81 105 82 106 foreach ($ignore as $key => $pattern) {
+42
src/applications/diffusion/protocol/__tests__/DiffusionMercurialCommandEngineTests.php
··· 1 + <?php 2 + 3 + final class DiffusionMercurialCommandEngineTests extends PhabricatorTestCase { 4 + 5 + public function testFilteringDebugOutput() { 6 + // Output that should be filtered out from the results 7 + $output = 8 + "ignoring untrusted configuration option\n". 9 + "couldn't write revision branch cache:\n". 10 + "couldn't write branch cache: blah blah blah\n". 11 + "invalid branchheads cache\n". 12 + "invalid branch cache (served): tip differs\n". 13 + "starting pager for command 'log'\n". 14 + "updated patterns: ". 15 + ".hglf/project/src/a/b/c/SomeClass.java, ". 16 + "project/src/a/b/c/SomeClass.java\n". 17 + "no terminfo entry for sitm\n"; 18 + 19 + $filtered_output = 20 + DiffusionMercurialCommandEngine::filterMercurialDebugOutput($output); 21 + 22 + $this->assertEqual('', $filtered_output); 23 + 24 + // The output that should make it through the filtering 25 + $output = 26 + "0b33a9e5ceedba14b03214f743957357d7bb46a9;694". 27 + ":8b39f63eb209dd2bdfd4bd3d0721a9e38d75a6d3". 28 + "-1:0000000000000000000000000000000000000000\n". 29 + "8b39f63eb209dd2bdfd4bd3d0721a9e38d75a6d3;693". 30 + ":165bce9ce4ccc97024ba19ed5a22f6a066fa6844". 31 + "-1:0000000000000000000000000000000000000000\n". 32 + "165bce9ce4ccc97024ba19ed5a22f6a066fa6844;692:". 33 + "2337bc9e3cf212b3b386b5197801b1c81db64920". 34 + "-1:0000000000000000000000000000000000000000\n"; 35 + 36 + $filtered_output = 37 + DiffusionMercurialCommandEngine::filterMercurialDebugOutput($output); 38 + 39 + $this->assertEqual($output, $filtered_output); 40 + } 41 + 42 + }