Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions docs/backend/storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,21 @@ The first start after history sizes were recorded measured the history of existi

Upload callers hold the project's save lock (`project-history-<id>`). History preparation takes that lock itself, after resolving ancestors, and checks the saved source hasn't changed since. So an upload releases its lock while history is prepared and takes it back afterwards. That avoids deadlocking on its own lock and holding nested locks across a chain of remix ancestors.

### Pull requests and remix sync

A pull request records the remix's head when it is opened, but an open pull request follows the remix: `GET /v1/projects/:id/pulls/:index`, its `diff` and its `merge` use the current head of the remix branch the pull request was opened from (`headBranch`). A pull request opened before branches were recorded follows the remix's only branch, or keeps its recorded head when the remix has several. If the branch no longer exists, they fall back to the recorded head. Merged and closed pull requests keep the head they had. `GET` shows the live head only to callers who can inspect the pull request. Its `baseCommit` stays the recorded fork point, so loading the pull request does no history work, and the diff response carries the live base. The diff compares the remix head with the closest commit it shares with the head of the target branch (`baseBranch`), or with the recorded base once that branch has been deleted, so changes the remix brought in from the target are not shown as part of the pull request. The `pull` object in a diff response carries that `baseCommit` and `headCommit`. The diff's merge base is cached by the two heads, because the commits behind a head never change, and a cached base is used only while both histories still contain it. Preparing a merge always walks the histories. Reading a project's commits or files with `?pull=<index>&pullTarget=<id>` is limited to commits that belong to that pull request (its recorded base, recorded target head, recorded head, prepared head, live head and live base), and downloading `workspace.mwp?pull=<index>` also requires a signed-in editor of the target project or the owner of the remix.

`POST /v1/projects/:id/pulls/:index/merge` merges against the same shared commit, or against the recorded `baseCommit` when the two histories no longer share one. It refuses with 409 `target_branch_changed` (with `branch`) while the target is on another branch than the pull request's `baseBranch`, and with 409 `target_branch_missing` once that branch has been deleted or renamed or 409 `uncommitted_changes` while the target has saved changes that are not committed (unless, for `target_branch_missing` or `uncommitted_changes`, the pull request is already merged, since closing it touches no project files). Projects without branch metadata skip the branch check. The upload repeats the source-visibility check, both branch checks and the `uncommitted_changes` refusal. `GET` reports `baseBranchMissing: true` once the target branch is gone, so the UI hides the merge action and tells the viewer to close and reopen the pull request before anyone tries to merge. When the target's head is an ancestor of the remix head, the remix has no uncommitted changes and the remix is on the branch the pull request follows, the server writes a merge commit whose tree is the remix head and answers `{merged: true, fastForward: true}`. When the target already has the remix head, the pull request is marked merged under the project's save lock and the answer is `{merged: true, alreadyMerged: true}`. Otherwise it stores the remix head it merged on the pull request as `preparedSourceHead` and answers `{merged: false, merge, expectedHead, sourceHead}`, where `merge` is the three-way merge with `changes`, `conflicts` and `baseHead`. A merge that cannot be prepared answers 409 `pull_merge_unavailable`. The client applies `merge.changes` to the target tree at `expectedHead` and uploads the result with `pullId`, `expectedHead`, `mergeTree` and `mergeSourceHead` (the `sourceHead` it merged). If the remix has moved since, the upload answers 409 `pull_head_changed`. An upload without `mergeSourceHead` is checked against `preparedSourceHead` (or the recorded head before any merge was prepared), so an older client can merge what the server last prepared and fails with 409 `pull_head_changed` if the remix moved after that. A pull request upload must carry `mergeTree` and no `workspace`, `restoreCommit`, `mergeSourceBranch` or `mergeTargetBranch`, or it answers 400. It answers 409 `head_changed` without `expectedHead` or when the target moved, 409 `pull_not_open` once the pull request was closed or merged, and 409 `pull_not_closed` (or 500 on the merge endpoint) if the project saves but the pull request record cannot be marked merged. Merging needs the same edit access as saving the project, so admins and group managers who can edit it can merge too. Once merged, the pull request records the remix head it merged as `headCommit`.

`POST /v1/projects/:id/remix/sync` prepares a merge of the original project's current head into a remix. Only someone who can edit the remix (its maintainers, or admins and group managers who can edit it) and see inside both projects may call it. It answers `{merge, targetProjectId, sourceProjectId, sourceTitle, sourceHead, targetHead, expectedHead}`. `merge.alreadyMerged` is true when the remix already contains the original's head, and `merge.fastForward` when the remix has no commits of its own since. Text conflicts are marked `this remix` and `original`. A history that still stores the whole project as one `project.sb3` file has a single binary conflict for that file, so the choice is the whole remix or the whole original. The client applies the changes to the remix tree at `targetHead` and uploads them with `syncHead` (the `sourceHead`), `expectedHead` and `mergeTree`. The server then writes a merge commit, `Merge changes from <original title>`, whose parents are the remix head and the original's head. A sync writes that merge commit even when it could fast-forward. A sync refuses with:

- 404 when the project is not a remix, or its original no longer exists.
- 403 for anyone else, or once the original's source is no longer visible to the caller.
- 409 `sync_history_unavailable` when either project has no MistWarp history, 409 `sync_unavailable` when the two histories share no commit or the merge cannot be prepared, and 500 when a history exists but cannot be read.
- 409 `uncommitted_changes` while the remix has saved changes that are not committed, because the merged project would replace them.
- 409 `head_changed` when `expectedHead` is missing or the remix moved, and 409 `original_changed` when the original moved after the sync was prepared.
- 400 when `syncHead` is combined with `pullId`, branch merge fields, `restoreCommit` or `replaceHistory`, or the upload has no `mergeTree`.

### Serving snapshots

Project, release and report-evidence snapshots are served from the local copy while one exists. Otherwise the API fetches the object from R2 through a presigned URL and passes it on as stored, with `Content-Encoding: gzip` when the stored copy is gzipped:
Expand Down
4 changes: 4 additions & 0 deletions docs/community/releases-and-feedback.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ You can send an improvement without changing the creator's project directly:
4. Open the fork's project page, choose **Contribute**, and create a pull request.
5. The project owner reviews the changes and decides whether to merge them.

A pull request follows your fork. Commits you save to the fork after opening it appear in the pull request, so you can answer review feedback by changing the fork. Owners need to commit any changes they saved in the editor before merging, and the project has to be on the branch the pull request targets. If that branch has been deleted, close the pull request and open a new one.

When the original project gets new commits, keep your fork up to date with **Sync with original**. It is on the fork's developer view (the **Code** tab), next to the line that says how far ahead and behind the original your fork is. A sync brings the original's new commits into your fork as one merge commit. If you and the original changed the same part of a sprite, edit the marked conflict and choose which version of each changed costume or sound to keep, then select **Save resolutions and sync**. Commit any changes you saved in the editor first, because the synced project replaces them. Projects whose history was saved before sprites were stored as separate files show one conflict for the whole project, so you choose either your fork or the original.

A bounty is a credit reward for a specific piece of work. Attach it when you create the pull request. MistWarp pays the reward when the project owner merges that pull request. Creating a fork or pull request alone does not claim the credits.

Project owners create bounties under **Manage and analytics**, **Collaboration**, then **Bounties**. A useful bounty says exactly what should change and what the owner will accept as done.
Expand Down
Loading