Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for merging Snapshots #5746

Merged
merged 4 commits into from
Apr 26, 2018

Conversation

stuhood
Copy link
Member

@stuhood stuhood commented Apr 25, 2018

Problem

As described in #5707: we need a way to merge Snapshot objects (although we have not yet decided how to expose them to @rules.)

Solution

Add Snapshot::merge.

Result

Fixes #5707.

@stuhood
Copy link
Member Author

stuhood commented Apr 25, 2018

(for the record: the individual commits here aren't useful)

Copy link
Contributor

@illicitonion illicitonion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great :) Thanks!

// TODO: This will not have been stored... we'll need to explicitly store it.
return future::ok(EMPTY_DIGEST).to_boxed();
} else if dir_digests.len() == 1 {
let mut dir_digests = dir_digests;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would possibly be a little clearer to make the argument mut, rather than to mut-ify it in the method body

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did this to avoid that... this localizes the awareness of the mutability to where it is actually relevant.

};
let merged_root_directory = store.load_directory(merged.digest).wait().unwrap().unwrap();

assert_eq!(merged.path_stats.len(), 3);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you compare the actual contents, rather than just the length? Ordering is well defined here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, good point.

.files
.iter()
.map(|filenode| filenode.name.clone())
.collect::<HashSet<_>>(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nodes in Directories have a canonical ordering (they should be sorted), so this should probably be a Vec rather than a HashSet

};

match merged_res {
Err(ref msg) if msg.contains("Snapshots contained duplicate path: ") => (),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe throw in a check that the error message contains the strong roland?

Copy link
Contributor

@illicitonion illicitonion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@stuhood stuhood merged commit 2c9cece into pantsbuild:master Apr 26, 2018
@stuhood stuhood deleted the stuhood/merge-snapshots branch April 26, 2018 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants