forked from facebook/watchman
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
augment JournalDelta with unclean paths on snapshot hash change
Summary: We were previously generating a simple JournalDelta consisting of just the from/to snapshot hashes. This is great from a `!O(repo)` perspective when recording what changed but makes it difficult for clients downstream to reason about changes that are not tracked in source control. This diff adds a concept of `uncleanPaths` to the journal; these are paths that we think are/were different from the hashes in the journal entry. Since JournalDelta needs to be able to be merged I've opted for a simple list of the paths that have a differing status; I'm not including all of the various dirstate states for this because it is not obvious how to reconcile the state across successive snapshot change events. The `uncleanPaths` set is populated with an initial set of different paths as the first part of the checkout call (prior to changing the hash), and then is updated after the hash has changed to capture any additional differences. Care needs to be taken to avoid recursively attempting to grab the parents lock so I'm replicating just a little bit of the state management glue in the `performDiff` method. The Journal was not setting the from/to snapshot hashes when merging deltas. This manifested in the watchman integration tests; we'd see the null revision as the `from` and the `to` revision held the `from` revision(!). On the watchman side we need to ask source control to expand the list of files that changed when the from/to hashes are different; I've added code to handle this. This doesn't do anything smart in the case that the source control aware queries are in use. We'll look at that in a following diff as it isn't strictly eden specific. `watchman clock` was returning a basically empty clock unconditionally, which meant that most since queries would report everything since the start of time. This is most likely contributing to poor Buck performance, although I have not investigated the performance aspect of this. It manifested itself in the watchman integration tests. Reviewed By: simpkins Differential Revision: D5896494 fbshipit-source-id: a88be6448862781a1d8f5e15285ca07b4240593a
- Loading branch information
1 parent
52b51c2
commit 2c6765e
Showing
8 changed files
with
257 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# vim:ts=4:sw=4:et: | ||
# Copyright 2017-present Facebook, Inc. | ||
# Licensed under the Apache License, Version 2.0 | ||
|
||
from __future__ import absolute_import | ||
from __future__ import division | ||
from __future__ import print_function | ||
# no unicode literals | ||
|
||
import WatchmanEdenTestCase | ||
|
||
|
||
class TestEdenJournal(WatchmanEdenTestCase.WatchmanEdenTestCase): | ||
|
||
def test_eden_journal(self): | ||
def populate(repo): | ||
repo.write_file('hello', 'hola\n') | ||
repo.commit('initial commit.') | ||
|
||
root = self.makeEdenMount(populate, enable_hg=True) | ||
repo = self.repoForPath(root) | ||
initial_commit = repo.get_head_hash() | ||
|
||
res = self.watchmanCommand('watch', root) | ||
self.assertEqual('eden', res['watcher']) | ||
|
||
clock = self.watchmanCommand('clock', root) | ||
|
||
self.touchRelative(root, 'newfile') | ||
|
||
res = self.watchmanCommand('query', root, { | ||
'fields': ['name'], | ||
'since': clock}) | ||
clock = res['clock'] | ||
self.assertFileListsEqual(res['files'], ['newfile']) | ||
|
||
repo.add_file('newfile') | ||
repo.commit(message='add newfile') | ||
res = self.watchmanCommand('query', root, { | ||
'expression': ['not', ['dirname', '.hg']], | ||
'fields': ['name'], | ||
'since': clock}) | ||
clock = res['clock'] | ||
self.assertFileListsEqual(res['files'], [ | ||
'newfile'], | ||
message='We expect to report the files changed in the commit') | ||
|
||
# Test the the journal has the correct contents across a "reset" like | ||
# operation where the parents are poked directly. This is using | ||
# debugsetparents rather than reset because the latter isn't enabled | ||
# by default for hg in the watchman test machinery. | ||
self.touchRelative(root, 'unclean') | ||
repo.hg('debugsetparents', initial_commit) | ||
res = self.watchmanCommand('query', root, { | ||
'expression': ['not', ['dirname', '.hg']], | ||
'fields': ['name'], | ||
'since': clock}) | ||
self.assertFileListsEqual(res['files'], [ | ||
'newfile', | ||
'unclean'], | ||
message=('We expect to report the file changed in the commit ' | ||
'as well as the unclean file')) |
Oops, something went wrong.