Skip to content

Commit

Permalink
fix cache updates for scm aware queries
Browse files Browse the repository at this point in the history
Summary:
A negative logic bug meant that we'd never update our remotename->hash mapping.

This could lead to a feedback loop; each attempt to `hg log` would cause hg to update blackbox.log
and thus cause subscriptions to be re-evaluated and thus run `hg log` again.

Reviewed By: simpkins

Differential Revision: D8337997

fbshipit-source-id: b49a717af752264bc3de8741fc4a2040d39cbfa2
  • Loading branch information
wez authored and facebook-github-bot committed Jun 9, 2018
1 parent c55f903 commit ffc0222
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion scm/Mercurial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ w_string Mercurial::mergeBaseWith(w_string_piece commitId, w_string requestId)
// we collected because we know that a pending change will advise clients of
// the new state
auto cache = cache_.wlock();
if (!fileTimeEqual(startDirState, cache->dirstate)) {
if (fileTimeEqual(startDirState, cache->dirstate)) {
cache->mergeBases[idString] = outputs.first;
}
}
Expand Down
15 changes: 15 additions & 0 deletions tests/integration/test_scm.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,21 @@ def test_scmHg(self):
)
self.assertFileListsEqual(res["files"], ["a/b/c/f1"])

# Sanity check that the mergebase cache is basically working.
# Ideally we'd check for a single miss in the server instance log, but
# since we may run variations on this same test against the same instance,
# it is hard to guarantee that the count would be meaningful here. So
# instead we look at the volume of log calls and check that it is below
# a reasonable threshold.
blackbox = os.path.join(root, ".hg", "blackbox.log")
if os.path.exists(blackbox):
misses = 0
with open(blackbox) as f:
for line in f:
if "'ancestor(.,TheMaster)' exited" in line:
misses += 1
self.assertLessEqual(misses, 20)

def getConsolidatedFileList(self, dat):
fset = set()
for _ in dat:
Expand Down

0 comments on commit ffc0222

Please sign in to comment.