-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
erepo: cache all read only external repos by hexsha #3286
Conversation
try: | ||
# Try python implementation of rev-parse first, it's faster | ||
return self.repo.rev_parse(name).hexsha | ||
except NotImplementedError: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, when does it happen though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For text search, see test_diff.test_directories
. There are also dates in @{...}
format.
So we have 3 things cached now separately: - clean clones, to not ask for creds repatedly - cache dirs, also shared between erepos with same origin - checked out clones if they are read only, addressed by (url, hexsha) Several additions to `Git` along the way: - Git.is_sha() static method - .pull() and .push() work with multiple returned records correctly - .get_rev() and .resolve_rev() work faster - .resolve_rev() looks for remote branches - .has_rev() Fixes iterative#3280.
Everything should be addressed now. |
It follows `git checkout` logic now - if name can be unambiguously resolved across known remotes then it's done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Just one question. 🙂
Oops, forgot to mention. Can we have at least a test that no cloning is done for the same rev? Maybe, just an assert that the cloned directory is same when rev is same? with external_repo("/tmp/repo", "master") as repo1:
pass
with external_repo("/tmp/repo", "master") as repo2: # or, even better, check here with hash?
pass
assert repo1.root_dir == repo2.root_dir |
Not sure we should test that, this is an implementation detail. EDIT. Also, we were not cloning twice before this PR, clones were cached. This PR caches copies from a cached clone |
for remote in self.repo.remotes | ||
} - {None} | ||
if len(shas) > 1: | ||
raise RevError("ambiguous Git revision '{}'".format(rev)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC git choses the ref-like rev if it can, even in ambigous case. It does print a warning though. Not sure if it matters that much here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Let's merge and move on. Not happy about the lack of tests, but that is on you 🙂
I'd argue, it's not an implementation detail but a behavior that is reasonable and expected, a subtle but important distinction because if I refactor this, I'd like to keep this behavior intact (without a need to change test code). How'd you prevent this from regressing? |
@Suor #3280 (comment) So we should've added tests, right? 😉 |
:D just posted #3280 (comment) before reading this |
So we have 3 things cached now separately:
Several additions to
Git
along the way:Fixes #3280.