This is an archive of the discontinued Mercurial Phabricator instance.

prefetch: merge prefetchtrees command into prefetch
ClosedPublic

Authored by singhsrb on Nov 14 2017, 3:43 PM.
Tags
None
Subscribers

Details

Reviewers
durham
Group Reviewers
Restricted Project
Commits
rFBHGXc99011005e70: prefetch: merge prefetchtrees command into prefetch
Summary

Currently,

  • hg prefetch prefetches files.
  • hg prefetchtrees prefetches trees.

This commit removes prefetchtrees and makes prefetch responsible for
everything i.e. prefetch will prefetch whatever it can prefetch be it files,
trees, or both.

Test Plan

Ran all the tests.

Diff Detail

Repository
rFBHGX Facebook Mercurial Extensions
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

singhsrb created this revision.Nov 14 2017, 3:43 PM
Herald added a reviewer: Restricted Project. · View Herald TranscriptNov 14 2017, 3:43 PM
durham requested changes to this revision.Nov 14 2017, 7:44 PM
durham added a subscriber: durham.

Looks good. Just requesting changes for clarification on the test permutations.

tests/test-treemanifest-prefetch.t
27

I don't understand the three cases here. Shouldn't it just be remotefilelog on or off? Maybe have a comment if explaining them if they are all needed.

treemanifest/__init__.py
1026

I'd add comments to these two functions, since it's not obvious from the names how they differ.

1031

Kinda awkward that this is done in three locations now (here, below, and in remotefilelog). Maybe in _prefetchwrapper we delete the repack option from opts and then have a if opts.get('repack'): backgroundrepack(..) call in there. At least then the pattern is a little clearer. Versus the code below which requires that we know repack is an option and that not calling orig means we don't execute that option.

Not much cleaner, but a good start for now.

This revision now requires changes to proceed.Nov 14 2017, 7:44 PM
singhsrb planned changes to this revision.Nov 14 2017, 8:24 PM
singhsrb added inline comments.
tests/test-treemanifest-prefetch.t
27

There are three cases of interest:

  1. remotefilelog enabled and the repo is shallow: We prefetch trees and files in this case.
  2. remotefilelog enabled and the repo is not shallow: We only prefetch trees in this case.
  3. remotefilelog disabled: We only prefetch trees in this case.

I can add more documentation to explain these.

treemanifest/__init__.py
1026

I was hoping the comment at line 188 would help in sorting that out. But no harm in adding more comments.

1031

I would prefer that too. This crossed my mind at some point and then I just ignored it. Thanks for noticing this!

singhsrb updated this revision to Diff 3536.Nov 15 2017, 4:44 PM
durham accepted this revision.Nov 15 2017, 6:14 PM

Not sure how I feel about the wide spread use of the test conditions here, but let's see if it causes problems in the future.

tests/test-treemanifest-prefetch.t
52

We should be able to set remotefilelog.server=True regardless, since normal clones from clients will still work just fine.

109

Maybe not as part of this diff, but we should make treemanifest add the debug*pack commands if treemanifest is not enabled. So we wouldn't need this change.

128

Why drop this line?

387

What about the remotefilelog.false case?

This revision is now accepted and ready to land.Nov 15 2017, 6:14 PM
singhsrb added inline comments.Nov 15 2017, 7:37 PM
tests/test-treemanifest-prefetch.t
52

I wanted to highlight its not really required for the other tests. In hindsight, I would prefer your suggestion after all the other conditional blocks. I will update this!

109

Yeah, I considered that. I even considered having a separate extension for the debugcommands since they seem fairly independent. I will take care of this eventually because I hate the pattern too.

128

When we prefetch both trees and files, we end up fetching more trees in case we actually don't have the base commit. That's just because of how the code is structured for now. I thought we don't care about that even though its a stronger check and therefore, removed the line. The --base option states that the base revision is assumed to be local. If its not, the behavior is undefined.

387

I actually did not check because I was primarily looking at the prefetch command. I would expect pull to behave the same way with/without my changes with remotefilelog disabled on the client. I can check if that's the case.

durham added inline comments.Nov 16 2017, 2:33 PM
tests/test-treemanifest-prefetch.t
128

If we don't clear the cache, it's not necessarily obvious that the reason we only downloaded some of the data is because of --base, and not because the data is already in the repo.

387

Does (capability !) means "this line applies if that capability is not enabled"? Or "this line applies if that capability is enabled"? If it's the latter, I would've expected a line here for when remotefilelog.false is on, since a normal non-remotefilelog hg pull should have output here.

singhsrb added a subscriber: quark.Nov 16 2017, 5:26 PM
singhsrb added inline comments.
tests/test-treemanifest-prefetch.t
128

Okay, I will separate out the cases and add a comment.

387

@quark helped out with it this! The summary is that it turns out this was a feature (or bug based on what you make of it) of capability ! feature. I thought it indicates that the this line applies if that capability is enabled but it actually means this line applies if that capability is enabled. Otherwise, it is optional. This was making the line added 2 changesets with 2 changes to 1 files pass for both remotefilelog.true.shallowrepo.false (because we asked it to match) and also for remotefilelog.false (because it was optional). I will fix this to a more appropriate syntax.

singhsrb updated this revision to Diff 3579.Nov 16 2017, 5:29 PM