Network team merge process, setup instructions, and notes.
This page explains how to merge patches into Tor. For the rules about '''when''' to merge patches into Tor, see the [[org/teams/NetworkTeam/MergePolicy|MergePolicy]] document.
This page explains how to merge patches into Tor. For the rules about **when** to merge patches into Tor, see the [[org/teams/NetworkTeam/MergePolicy|MergePolicy]] document.
[[TOC]]
== How do you do a Merge? ==
=== Configuring your Environment ===
## How do you do a Merge?
### Configuring your Environment
[draft]
==== Master and Backport Merges ====
#### Master and Backport Merges
===== 1. Make sure you have the git hooks installed =====
##### 1. Make sure you have the git hooks installed
You can find the hooks in `tor/scripts/git/`. They need to be copied into tor/.git/hooks, without the extension:
So then now within the worktree, you can simply do "git pull" and it will
always fetch the latest from origin/maint-0.3.5 which is important because the
...
...
@@ -144,7 +144,7 @@ at all times.
Basically, a maintainer should do the above for all maintained branches
(including releases-*).
==== New Maint and Release Branches ====
#### New Maint and Release Branches
Make sure that your git scripts are up to date with the new branches!
...
...
@@ -156,113 +156,113 @@ Set TOR_FULL_GIT_PATH in your .profile, and run `git-setup-dirs.sh -u`.
Set up the new maint-* and release-* worktrees, using the instructions in step 5 above.
=== Merging a Branch ===
### Merging a Branch
==== Master Merges ====
#### Master Merges
===== 0. Make sure your environment is set up =====
##### 0. Make sure your environment is set up
* git hooks
* tor-github custom remote
===== 1. Make sure you have the latest version of master checked out in your git directory =====
##### 1. Make sure you have the latest version of master checked out in your git directory
{{{
```
$ git fetch upstream
}}}
```
===== 2. Make sure that you have the latest version of the branch you're merging =====
##### 2. Make sure that you have the latest version of the branch you're merging
{{{
```
$ git fetch tor-github
}}}
```
===== 3. Check all the things you're supposed to check =====
##### 3. Check all the things you're supposed to check
===== 4. Merge the branch =====
##### 4. Merge the branch
{{{
```
# Sometimes, tor-github/pr/NNNNN will also work
$ git merge tor-github/pr/NNNNN/head
}}}
```
===== 5. Push to master =====
##### 5. Push to master
{{{
```
$ git push upstream master
}}}
```
===== 6. Update the ticket, and wait for CI =====
##### 6. Update the ticket, and wait for CI
See "Backport Merges" Steps 8 & 9 for details.
==== Backport Merges ====
#### Backport Merges
===== 0. Make sure your environment is set up =====
##### 0. Make sure your environment is set up
* git hooks
* tor-github custom remote
* git scripts
* worktrees
===== 1. Make sure you have the latest version of all supported branches checked out in your worktrees =====
##### 1. Make sure you have the latest version of all supported branches checked out in your worktrees
{{{
```
$ git-pull-all.sh
}}}
```
===== 2. Make sure that you have the latest version of the branch you're merging =====
##### 2. Make sure that you have the latest version of the branch you're merging
You can get the supported branches and github PRs using:
{{{
```
$ git-pull-all.sh
}}}
```
===== 3. Check all the things you're supposed to check =====
##### 3. Check all the things you're supposed to check
===== 4. Go into the earliest target directory where you are merging today, and merge the branch =====
##### 4. Go into the earliest target directory where you are merging today, and merge the branch
{{{
```
$ cd maint-0.3.5
# Sometimes, tor-github/pr/NNNNN will also work
$ git merge tor-github/pr/NNNNN/head
}}}
```
===== 5. If the merge isn't clean, ask the patch author or a stable maintainer what to do =====
##### 5. If the merge isn't clean, ask the patch author or a stable maintainer what to do
===== 6. Run `git-merge-forward.sh` and verify that there are no conflicts =====
##### 6. Run `git-merge-forward.sh` and verify that there are no conflicts
The merge-forward script will stop after any conflicts.
===== 7. If the merge isn't clean, ask the patch author or a stable maintainer what to do =====
##### 7. If the merge isn't clean, ask the patch author or a stable maintainer what to do
You can go in to the worktree and fix the conflict yourself, if you can work out how. Let the patch author know on the ticket, and ask them to check your merge.
===== 8. Push all the branches =====
##### 8. Push all the branches
{{{
```
$ git-push-all.sh
}}}
```
===== 9. Update the ticket =====
##### 9. Update the ticket
If you are merging a patch into the earliest series to which it
applies, close the ticket after you merge, and say where you merged
it. If you are merging a patch that is a candidate for backport, move
the ticket into the earliest open milestone to which it applies.
===== 9. Wait for the CI to finish on master =====
##### 9. Wait for the CI to finish on master
If the CI fails due to practracker errors, update the practracker exceptions file, and push to master again.
(practracker fixes don't need review.) Ask the person who wrote the code to fix the exception.
Make a note on the trac ticket for the PR that caused the error.
=== Merging Different Branches into Different Releases ===
### Merging Different Branches into Different Releases
Follow the "Backport Merges" steps 3-5 for each branch you need to merge.
==== Finding Branches to Merge ====
#### Finding Branches to Merge
1. Work out all the maint branches you are merging pull requests into today:
* if you're doing a mainline merge, the maint branches might be:
...
...
@@ -289,7 +289,7 @@ To simplify this process, we usually:
* Wait for testing in an alpha release
* Merge the change to all other versions
==== Doing the Merges ====
#### Doing the Merges
Here's how you do the merges:
1. Find the earliest maint branch you want to merge into today, and the pull request for that maint branch
...
...
@@ -298,13 +298,13 @@ Here's how you do the merges:
4. Repeat from 2 for the next pull request and its maint branch
5. Once all the pull requests are merged, merge all branches forward
==== Dealing with Merge Conflicts ====
#### Dealing with Merge Conflicts
If there are any merge conflicts, stop! Don't push anything!
Reset your merge directories to the current branches on torproject.org.
Ask for help on the ticket. Include details of the merge conflict.
==== Worked Example ====
#### Worked Example
Here is a worked example from https://trac.torproject.org/projects/tor/ticket/29806#comment:18
...
...
@@ -325,7 +325,7 @@ The other pull requests are:
* master: https://github.com/torproject/tor/pull/822 into master
Here are the exact steps on the command-line:
{{{
```
$ cd ../maint-0.4.0
$ git merge tor-github/pr/821
Auto-merging src/test/test_dir.c
...
...
@@ -387,18 +387,18 @@ master Handling branch
[+] Switching branch to master...success
[+] Merging branch origin/master...success
[+] Merging branch maint-0.4.0 into master...success
}}}
```
These forward merges were clean merges:
{{{
```
[+] Merging branch maint-0.4.0 into release-0.4.0...success
[+] Merging branch maint-0.4.0 into master...success
}}}
```
The rest of the merges did not add a merge commit, because there were no changes.
== How do we Create Backport Branches? ==
## How do we Create Backport Branches?
Use `git-merge-forward.sh -t bugNNNNN` to automatically create merge forward branches from the current contents of your maint-* and master working directories.
...
...
@@ -419,7 +419,7 @@ Just merge lines in merge commits. Don't put semantic changes in merge commits.
If we create merge branches this way, we should be able to merge all these branches in the right places, then merge forward without conflicts.
== TODO ==
## TODO
We should integrate this document with the stable maintainer guide.