D7785: remotefilelog: actually fix (and test this time) a bytes vs str issue

spectral (Kyle Lippincott) phabricator at mercurial-scm.org
Thu Jan 2 22:56:49 EST 2020


spectral created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  I attempted this in 94670e124d29 <https://phab.mercurial-scm.org/rHG94670e124d294f1e466734cbd4a21136f595b18b> but we didn't actually have any tests for this
  function it seems, and I mistook "it works now" for it being fixed (when what
  had actually happened was that my cache had populated enough that I didn't
  trigger the minimum threshold on my reattempts).

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D7785

AFFECTED FILES
  hgext/remotefilelog/fileserverclient.py
  tests/test-remotefilelog-prefetch.t

CHANGE DETAILS

diff --git a/tests/test-remotefilelog-prefetch.t b/tests/test-remotefilelog-prefetch.t
--- a/tests/test-remotefilelog-prefetch.t
+++ b/tests/test-remotefilelog-prefetch.t
@@ -236,3 +236,36 @@
   $ hg revert -a -r 1 || true
   3 files fetched over 1 fetches - (3 misses, 0.00% hit ratio) over * (glob)
   abort: z2 at 109c3a557a73: not found in manifest! (?)
+
+# warning when we have excess remotefilelog fetching
+
+  $ cat > repeated_fetch.py << EOF
+  > import binascii
+  > from mercurial import extensions, registrar
+  > cmdtable = {}
+  > command = registrar.command(cmdtable)
+  > @command(b'repeated-fetch', [], b'', inferrepo=True)
+  > def repeated_fetch(ui, repo, *args, **opts):
+  >     for i in range(20):
+  >         try:
+  >             hexid = (b'%02x' % (i + 1)) * 20
+  >             repo.fileservice.prefetch([(b'somefile.txt', hexid)])
+  >         except:
+  >             pass
+  > EOF
+
+We should only output to the user once. We're ignoring most of the output
+because we're not actually fetching anything real here, all the hashes are
+bogus, so it's just going to be errors and a final summary of all the misses.
+  $ hg --config extensions.repeated_fetch=repeated_fetch.py \
+  >    --config remotefilelog.fetchwarning="fetch warning!" \
+  >    --config extensions.blackbox= \
+  >    repeated-fetch 2>&1 | grep 'fetch warning'
+  fetch warning!
+
+We should output to blackbox three times, with a stack trace on each (though
+that isn't tested here).
+  $ grep 'excess remotefilelog fetching' .hg/blackbox.log
+  .* excess remotefilelog fetching: (re)
+  .* excess remotefilelog fetching: (re)
+  .* excess remotefilelog fetching: (re)
diff --git a/hgext/remotefilelog/fileserverclient.py b/hgext/remotefilelog/fileserverclient.py
--- a/hgext/remotefilelog/fileserverclient.py
+++ b/hgext/remotefilelog/fileserverclient.py
@@ -663,5 +663,5 @@
         self.ui.log(
             b'remotefilelog',
             b'excess remotefilelog fetching:\n%s\n',
-            b''.join(pycompat.sysbytes(traceback.format_stack())),
+            b''.join(pycompat.sysbytes(s) for s in traceback.format_stack()),
         )



To: spectral, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list