From dcd901db766aea65b2438548c3a53f7b37c4d3d5 Mon Sep 17 00:00:00 2001 From: John Elliott Date: Mon, 23 Dec 2024 12:34:09 -0800 Subject: [PATCH] Fixed bug in changesSinceV2 where to and from in CommitTransitions were swapped Summary: # Context We are introducing EdenFS notifications to support scalable and ergonomic file system notifications for EdenFS mounts. # This Diff * Because we process the journal from back to front there was confusion on which commit id is `from` and which is `to`. We got it backwards. This diff fixes that. * Updated the integration tests (there are no .t tests here). * We have put in a hack in the buck2 integration code that will need to be addressed when this change is rolled out fully. # Next Steps * Add suffix (extension) filters - inclusion and exclusion. * Investigate best performance data structures for modeling inclusion and exclusion path filters (Watchman uses a radix tree search). * Change the journal walking code to scan for position then walk forwards - current implemantion walks backward. * .t tests, Python integration tests, C++ unit tests # Discussion Points None Differential Revision: D67552308 fbshipit-source-id: 972e1581fd896acc57d9e77d198ccd5a4946ac33 --- eden/fs/service/EdenServiceHandler.cpp | 4 ++-- eden/integration/changes_test.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/eden/fs/service/EdenServiceHandler.cpp b/eden/fs/service/EdenServiceHandler.cpp index f26b34f856e1b..cf3a759a70f54 100644 --- a/eden/fs/service/EdenServiceHandler.cpp +++ b/eden/fs/service/EdenServiceHandler.cpp @@ -2425,9 +2425,9 @@ void EdenServiceHandler::sync_changesSinceV2( }, [&](const RootUpdateJournalDelta& current) -> void { CommitTransition commitTransition; - commitTransition.from_ref() = rootIdCodec.renderRootId(currentHash); - commitTransition.to_ref() = + commitTransition.from_ref() = rootIdCodec.renderRootId(current.fromHash); + commitTransition.to_ref() = rootIdCodec.renderRootId(currentHash); currentHash = current.fromHash; LargeChangeNotification largeChange; diff --git a/eden/integration/changes_test.py b/eden/integration/changes_test.py index 4331ad81f2377..e3815e7590013 100644 --- a/eden/integration/changes_test.py +++ b/eden/integration/changes_test.py @@ -182,8 +182,8 @@ def test_commit_transition(self): # For CommitTransition, from_bytes is the current hash and to_bytes is the previous hash buildLargeChange( LargeChangeNotification.COMMITTRANSITION, - from_bytes=bytes.fromhex(commit1), - to_bytes=bytes.fromhex(self.commit0), + from_bytes=bytes.fromhex(self.commit0), + to_bytes=bytes.fromhex(commit1), ), ] self.assertTrue(self.check_changes(changes1.changes, expected_changes1)) @@ -193,8 +193,8 @@ def test_commit_transition(self): expected_changes2 = [ buildLargeChange( LargeChangeNotification.COMMITTRANSITION, - from_bytes=bytes.fromhex(self.commit0), - to_bytes=bytes.fromhex(commit1), + from_bytes=bytes.fromhex(commit1), + to_bytes=bytes.fromhex(self.commit0), ), ] self.assertTrue(self.check_changes(changes2.changes, expected_changes2))