Initial version of v2 pull integration + project info v2#282
Initial version of v2 pull integration + project info v2#282MarcelGeo wants to merge 26 commits intov2-pull-integrationfrom
Conversation
+ tests for both v2 and v1 features + projectinfo v2 compatibility test
wonder-sk
left a comment
There was a problem hiding this comment.
let's first do a bit of refactoring... the idea is that:
- we introduce a new class that captures project delta (added/updated/updated_diff/deleted) files
- the project delta class would be returned by get_pull_changes and get_push_changes
- there would a function that can combine server changes (from get_pull_changes) and local changes (from get_push_changes) and return a list of tasks to do at the end of the pull (e.g. copy, copy conflict, apply diff, delete - like PullTask in mobile app's merginapi)
- apply_pull_changes() would just go through the list of "pull tasks" and apply them, rather than again getting local changes and doing logic based on that
- models.py for some classes without specific location - clenup of non-necssary functions from previous version - refactor of pull handling using PullActions
+ descriptions + tests for appl_pull_actions + restore get_pull_changes for backward compatibility with project status
| self.size_check = size_check # whether we want to do merged file size check | ||
|
|
||
| def merge(self): | ||
| with open(self.dest_file, "wb") as final: |
There was a problem hiding this comment.
don't we need to create intermediate dirs?
There was a problem hiding this comment.
it was done before. I updated this to create also directory.
| resp = mc.get( | ||
| f"/v2/projects/{mp.project_id()}/raw/diff/{self.file_path}", | ||
| ) | ||
| if resp.status in [200, 206]: |
There was a problem hiding this comment.
Do we always download diff in single request? If so, let's state it explicitly somewhere.
There was a problem hiding this comment.
added comments ⬇️
| (DeltaChangeType.UPDATE_DIFF, DeltaChangeType.UPDATE): PullActionType.COPY_CONFLICT, | ||
| (DeltaChangeType.UPDATE_DIFF, DeltaChangeType.DELETE): PullActionType.COPY, | ||
| (DeltaChangeType.UPDATE_DIFF, DeltaChangeType.UPDATE_DIFF): PullActionType.APPLY_DIFF, # rebase | ||
| (DeltaChangeType.DELETE, None): PullActionType.DELETE, |
There was a problem hiding this comment.
why pull action type delete here and not also for other use cases?
There was a problem hiding this comment.
not sure what you mean here. better to discuss @varmar05
Pull Request Test Coverage Report for Build 21143761159Details
💛 - Coveralls |
There was a problem hiding this comment.
Pull request overview
Implements the initial v2 pull integration using the /delta endpoint (with a v1 fallback), and adds v2 project info support plus related integration/unit tests.
Changes:
- Add v2 pull flow in
pull_project_asyncbased on server feature flag (v2_pull_enabled) and project delta items. - Introduce typed models for delta items, pull actions, and v2 project info responses.
- Expand test coverage for pull actions/delta calculation and project info v2 compatibility.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 15 comments.
Show a summary per file
| File | Description |
|---|---|
mergin/client_pull.py |
Refactors pull pipeline around ProjectDelta + PullAction, adds v2 diff download path. |
mergin/client.py |
Adds project_info_v2() and get_project_delta() API wrappers and a server-version capability check. |
mergin/merginproject.py |
Adds delta/local-delta computation and applies pull via action-based execution. |
mergin/models.py |
Adds dataclasses for delta items, pull actions, and v2 project info response typing. |
mergin/common.py |
Adds enums for delta change and pull action types. |
mergin/test/test_client.py |
Updates/extends integration tests for v2 pull and v2 project info. |
mergin/test/test_mergin_project.py |
Adds unit tests for pull-action selection, delta calculation, local delta, and applying actions. |
mergin/test/test_client_pull.py |
Adds unit tests for download item creation helpers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- unify get_pull_changes with get_pull_delta - add pull action with rebase and no_rebase - simplify PullAction class
Resolved #280
/deltaendpoint, where pull changes between current version and server are calculated from delta itemsFixes
Pull logic updates
in
pull_project_asyncis check if server supports v2_pullIf supports: get pull delta from server
If not: calculate pull delta from files and projects
config.jsonThen calculate delta items between local files and server (local delta) - delta needs to be applied to server
Compare pull_delta and local_delta ->
PullActionwith actions needs to be done after files are downloaded from a server defined inPullActionTypeenumStarting download
After download is finished -> call
pull_project_finalizeMethod
apply_pull_actionsis then responsible to finalizePullActionbased on type