From 72c413ac41bcebd0689ed39b3e673eabaffad126 Mon Sep 17 00:00:00 2001 From: "iannucci@chromium.org" Date: Mon, 14 Apr 2014 23:34:46 +0000 Subject: [PATCH] Move walkthrough to end of tutorial, add real TL;DR section. R=scottmg@chromium.org BUG=261743 Review URL: https://codereview.chromium.org/238203002 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@263746 0039d316-1c4b-4281-b951-d872f2087c98 --- docs/html/depot_tools_tutorial.html | 453 +++++++++--------- docs/man7/depot_tools_tutorial.7 | 427 +++++++++-------- ... depot_tools_tutorial.demo.walkthrough.sh} | 0 docs/src/depot_tools_tutorial.txt | 55 ++- 4 files changed, 510 insertions(+), 425 deletions(-) rename docs/src/{depot_tools_tutorial.demo.tldr.sh => depot_tools_tutorial.demo.walkthrough.sh} (100%) diff --git a/docs/html/depot_tools_tutorial.html b/docs/html/depot_tools_tutorial.html index 3595c59ff9..73c545d85c 100644 --- a/docs/html/depot_tools_tutorial.html +++ b/docs/html/depot_tools_tutorial.html @@ -771,7 +771,7 @@ Chromium using these tools. This will cover:

  • -TL;DR Walkthrough +TL;DR

  • @@ -794,6 +794,11 @@ Chromium using these tools. This will cover:

    Managing dependent CLs

  • +
  • +

    +Example Walkthrough +

    +
  • Please refer to the manpages (or --help output) for details about any of the commands mentioned in this tutorial.

    @@ -979,6 +984,30 @@ commands:

    +

    TL;DR

    +
    +
    +
    +
    $ # get the code
    +$ # In an empty directory:
    +$ fetch {chromium,blink,...}
    +
    +$ # Update third_party repos and run pre-compile hooks
    +$ gclient sync
    +
    +$ # Make a new change and upload it for review
    +$ git new-branch branchname
    +$ # repeat: [edit, git add, git commit]
    +$ git cl upload
    +
    +$ # After change is reviewed, commit with the CQ
    +$ git cl set_commit
    +$ # Note that the committed hash which lands will /not/ match the
    +$ # commit hashes of your local branch.
    +
    +
    +
    +

    GETTING THE CODE

    Pick an empty directory and run one of the following:

    @@ -1004,23 +1033,207 @@ directory:

    And finally:

    -
    $ gclient sync <1>
    +
    $ gclient sync
    -
      -
    1. +

      This will pull all dependencies of the Chromium src checkout. You will need +to run this any time you update the main src checkout.

      +
    +
    +
    +

    CREATING / UPLOADING A CL

    +
    +
    + + + +
    +
    Note
    +
    The remainder of the tutorial assumes that your current working directory +is the src/ folder mentioned in Getting the code.
    +
    +

    Each CL corresponds exactly with a single branch in git. Any time you want to +begin a new CL, just:

    +
    +
    +
    $ git new-branch <branch_name>
    +
    +

    This will create and checkout a new branch named branch_name which will track +the default upstream (which is origin/master). See git-new-branch(1) +for more features, such as the ability to track LKGR.

    +

    Commit as many changes as you like to this branch. When you want to upload it +for review, run:

    +
    +
    +
    $ git cl upload
    +
    +

    This will take the diff of your branch against its upstream (origin/master), +and will post it to the Chromium code +review site.

    +
    +
    +
    +

    UPDATING THE CODE

    +
    +

    Inevitably, you’ll want to pull in changes from the main Chromium repo. This is +pretty easy with depot_tools:

    +
    +
    +
    $ git rebase-update
    +
    +

    This command will update all of your CLs to contain the latest code from their +upstreams. It will also automatically clean up CLs which have been committed and +a couple other nice things. See git-rebase-update(1) for the full +scoop.

    +

    One thing to look out for are merge conflicts. These happen for exactly the +same as they do with SVN, but the experience is a little more controllable with +git. git rebase-update will try to rebase all your branches for you, but if it +encounters a merge conflict in one, it will halt and leave you in a rebase +conflict state (see git-rebase(1)). Resolving git rebase merge +conflicts is beyond the scope of this tutorial, but there are many good sources +online (see the Prerequisites for some).

    +

    Sometimes you’re pretty certain that you’ve committed a certain branch, but git +rebase-update isn’t able to tell that for sure. This is usually because your +branch doesn’t rebase cleanly. You could just delete the branch with git branch +-D <branch>, but you’d like to double check the diff of your branch against its +upstream before deleting it. If this is the case you can abort the rebase +started by git rebase-update, and then run git-squash-branch(1) to +flatten your branch into a single commit. When you run git rebase-update +again, you’ll get a (hopefully) much smaller / saner diff. If it turns out you +were wrong about your branch being fully committed, you can use +git-reflog(1) to reset your branch back to where it was before. If the +diff looks inconsequential, you can use git rebase --skip to ignore it, and +then git rebase-update will clean it up for you.

    +

    Once you’re done resolving all of the merge conflict, just run git +rebase-update, and it will pick up where it left off. Once the command has +finished updating all of your branches, it will return you back to the branch +you started on.

    +
    + + + +
    +
    Note
    +
    Running git rebase-update will update all your branches, but it will not +automatically run gclient sync to update your dependencies.
    +
    +
    +
    +
    +

    MANAGING MULTIPLE CLS

    +
    +

    Sometimes you want to work on more than one CL at once (say, you have a CL +posted for review and want to work on something else). For each CL that you +want to work on, just use git new-branch <branchname>.

    +

    Once you start to have more than one CL at a time, it can be easy to lose your +bearings. Fortunately, depot_tools has two tools to help you out:

    +
    +
    +
    $ git map
    +* 7dcfe47        (frozen_changes) 2014-03-12 ~ FREEZE.unindexed
    +* 4b0c180        2014-03-12 ~ modfile
    +* 59a7cca        2014-03-12 ~ a deleted file
    +* 6bec695        (origin/master) 2014-03-11 ~ Add neat feature    <(frozen_changes)
    +* d15a38a        2014-03-11 ~ Epic README update
    +* d559894        (master) 2014-03-11 ~ Important upstream change
    +| * 9c311fd      (cool_feature) 2014-03-11 ~ Respond to CL comments
    +| | * 2a1eeb2    (subfeature) 2014-03-11 ~ integrate with CoolService
    +| | * d777af6    2014-03-11 ~ slick commenting action
    +| |/
    +| * 265803a      2014-03-11 ~ another improvement    <(subfeature)
    +| * 6d831ac      (spleen_tag) 2014-03-11 ~ Refactor spleen
    +| * 82e74ab      2014-03-11 ~ Add widget
    +|/
    +* d08c5b3        (bogus_noparent) 2014-03-11 ~ Wonderful beginnings    <(cool_feature)
    +
    +

    Note that this example repo is in dire need of a git-rebase-update(1)!

    +
    +
    +
    $ git map-branches
    +origin/master
    +  cool_feature
    +    subfeature
    +  frozen_changes *
    +  master
    +
    +
    +
    +git-map(1) +
    +

    -This will pull all dependencies of the Chromium src checkout. You will need -to run this any time you update the main src checkout. + This tool shows you the history of all of your branches in a pseudo-graphical + format. In particular, it will show you which commits all of your branches + are on, which commit you currently have checked out, and more. Check out the + doc for the full details.

    - -
    + +
    +git-map-branches(1) +
    +
    +

    + This tool just shows you which branches you have in your repo, and thier + upstream relationship to each other (as well as which branch you have checked + out at the moment). +

    +
    +
    +

    Additionally, sometimes you need to switch between branches, but you’ve got work +in progress. You could use git-stash(1), but that can be tricky to +manage because you need to remember which branches you stashed what changes on. +Helpfully depot_tools includes two tools which can greatly assist in case:

    +

    git-freeze(1) allows you to put the current branch in 'suspended +animation' by committing your changes to a specially-named commit on the top of +your current branch. When you come back to your branch later, you can just run +git-thaw(1) to get your work-in-progress changes back to what they were.

    +

    Another useful tool is git-rename-branch(1). Unlike git branch -m <old> +<new>, this tool will correctly preserve the upstream relationships of your +branch compared to its downstreams.

    +

    Finally, take a look at git-upstream-diff(1). This will show you the +combined diff for all the commits on your branch against the upstream tracking +branch. This is exactly what git cl upload will push up to code review. +Additionally, consider trying the --wordwise argument to get a colorized +per-word diff (instead of a per-line diff).

    -

    TL;DR WALKTHROUGH

    +

    MANAGING DEPENDENT CLS

    -

    This section will demo what a typical workflow looks like when writing, updating, -and committing multiple CLs.

    +

    Now that you know how to manage independent CLs, we’ll see how to manage +dependent CLs. Dependent CLs are useful when your second (or third or fourth +or …) CL depends on the changes in one of your other CLs (such as: CL 2 won’t +compile without CL 1, but you want to submit them as two separate reviews).

    +

    Like all of the other CLs we’ve created, we use git-new-branch(1), but +this time with an extra argument. First, git checkout the branch +you want to base the new one on (i.e. CL 1), and then run:

    +
    +
    +
    $ git new-branch --upstream_current <branch_name>
    +
    +

    This will make a new branch which tracks the current branch as its upstream +(as opposed to origin/master). All changes you commit to this branch will be +in addition to the previous branch, but when you git cl upload, you will only +upload the diff for the dependent (child) branch. You may have as many branches +nested in this fashion as you like.

    +

    git-map(1) and git-map-branches(1) are particularly helpful when +you have dependent branches. In addition, there are two helper commands which +let you traverse your working copy up and down this tree of branches: +git-nav-upstream(1) and git-nav-downstream(1).

    +

    Sometimes when dealing with dependent CLs, it turns out that you accidentally +based a branch on the wrong upstream, but since then you’ve committed changes to +it, or even based another branch off of that one. Or you discover that you +have two independent CLs that would actually be much better off as dependent +CLs. In instances like these, you can check out the offending branch and use +git-reparent-branch(1) to move it to track a different parent. Note that +this can also be used to move a branch from tracking origin/master to lkgr +or vice versa.

    +
    +
    +
    +

    EXAMPLE WALKTHROUGH

    +
    +

    This section will demo what a typical workflow looks like when writing, +updating, and committing multiple CLs.

    $ fetch chromium
     ... truncated output ...
     $ cd src
    @@ -1047,10 +1260,10 @@ It was a Domo-Kuun.
     * 2250f53	 2014-04-10 ~ ozone: evdev: Filter devices by path
     * 33a7a74	 2014-04-10 ~ Always output seccomp error messages to stderr
     $ git status
    -# On branch fix_typo
    -# Your branch is ahead of 'origin/master' by 1 commit.
    -#   (use "git push" to publish your local commits)
    -#
    +On branch fix_typo
    +Your branch is ahead of 'origin/master' by 1 commit.
    +  (use "git push" to publish your local commits)
    +
     nothing to commit, working directory clean
     $ git cl upload -r domo@chromium.org --send-mail
     ... truncated output ...
    @@ -1066,15 +1279,15 @@ overhead, barely disturbing the thick cigarette smoke. No doubt was left about
     when the fan was last cleaned.
     EOF
     $ git status
    -# On branch chap2
    -# Your branch is up-to-date with 'origin/master'.
    -#
    -# Changes not staged for commit:
    -#   (use "git add <file>..." to update what will be committed)
    -#   (use "git checkout -- <file>..." to discard changes in working directory)
    -#
    -#	modified:   build/whitespace_file.txt
    -#
    +On branch chap2
    +Your branch is up-to-date with 'origin/master'.
    +
    +Changes not staged for commit:
    +  (use "git add <file>..." to update what will be committed)
    +  (use "git checkout -- <file>..." to discard changes in working directory)
    +
    +	modified:   build/whitespace_file.txt
    +
     no changes added to commit (use "git add" and/or "git commit -a")
     

    Someone on the code review pointed out that our typo-fix has a typo :( We're still working on 'chap2' but we really want to land 'fix_typo', so let's switch over and fix it.

    $ git freeze
     $ git checkout fix_typo
    @@ -1319,196 +1532,6 @@ development using these tools. Any git workflow is compatible, as long as
     
    -

    CREATING / UPLOADING A CL

    -
    -
    - - - -
    -
    Note
    -
    The remainder of the tutorial assumes that your current working directory -is the src/ folder mentioned in Getting the code.
    -
    -

    Each CL corresponds exactly with a single branch in git. Any time you want to -begin a new CL, just:

    -
    -
    -
    $ git new-branch <branch_name>
    -
    -

    This will create and checkout a new branch named branch_name which will track -the default upstream (which is origin/master). See git-new-branch(1) -for more features, such as the ability to track LKGR.

    -

    Commit as many changes as you like to this branch. When you want to upload it -for review, run:

    -
    -
    -
    $ git cl upload
    -
    -

    This will take the diff of your branch against its upstream (origin/master), -and will post it to the Chromium code -review site.

    -
    -
    -
    -

    UPDATING THE CODE

    -
    -

    Inevitably, you’ll want to pull in changes from the main Chromium repo. This is -pretty easy with depot_tools:

    -
    -
    -
    $ git rebase-update
    -
    -

    This command will update all of your CLs to contain the latest code from their -upstreams. It will also automatically clean up CLs which have been committed and -a couple other nice things. See git-rebase-update(1) for the full -scoop.

    -

    One thing to look out for are merge conflicts. These happen for exactly the -same as they do with SVN, but the experience is a little more controllable with -git. git rebase-update will try to rebase all your branches for you, but if it -encounters a merge conflict in one, it will halt and leave you in a rebase -conflict state (see git-rebase(1)). Resolving git rebase merge -conflicts is beyond the scope of this tutorial, but there are many good sources -online (see the Prerequisites for some).

    -

    Sometimes you’re pretty certain that you’ve committed a certain branch, but git -rebase-update isn’t able to tell that for sure. This is usually because your -branch doesn’t rebase cleanly. You could just delete the branch with git branch --D <branch>, but you’d like to double check the diff of your branch against its -upstream before deleting it. If this is the case you can abort the rebase -started by git rebase-update, and then run git-squash-branch(1) to -flatten your branch into a single commit. When you run git rebase-update -again, you’ll get a (hopefully) much smaller / saner diff. If it turns out you -were wrong about your branch being fully committed, you can use -git-reflog(1) to reset your branch back to where it was before. If the -diff looks inconsequential, you can use git rebase --skip to ignore it, and -then git rebase-update will clean it up for you.

    -

    Once you’re done resolving all of the merge conflict, just run git -rebase-update, and it will pick up where it left off. Once the command has -finished updating all of your branches, it will return you back to the branch -you started on.

    -
    - - - -
    -
    Note
    -
    Running git rebase-update will update all your branches, but it will not -automatically run gclient sync to update your dependencies.
    -
    -
    -
    -
    -

    MANAGING MULTIPLE CLS

    -
    -

    Sometimes you want to work on more than one CL at once (say, you have a CL -posted for review and want to work on something else). For each CL that you -want to work on, just use git new-branch <branchname>.

    -

    Once you start to have more than one CL at a time, it can be easy to lose your -bearings. Fortunately, depot_tools has two tools to help you out:

    -
    -
    -
    $ git map
    -* 7dcfe47        (frozen_changes) 2014-03-12 ~ FREEZE.unindexed
    -* 4b0c180        2014-03-12 ~ modfile
    -* 59a7cca        2014-03-12 ~ a deleted file
    -* 6bec695        (origin/master) 2014-03-11 ~ Add neat feature    <(frozen_changes)
    -* d15a38a        2014-03-11 ~ Epic README update
    -* d559894        (master) 2014-03-11 ~ Important upstream change
    -| * 9c311fd      (cool_feature) 2014-03-11 ~ Respond to CL comments
    -| | * 2a1eeb2    (subfeature) 2014-03-11 ~ integrate with CoolService
    -| | * d777af6    2014-03-11 ~ slick commenting action
    -| |/
    -| * 265803a      2014-03-11 ~ another improvement    <(subfeature)
    -| * 6d831ac      (spleen_tag) 2014-03-11 ~ Refactor spleen
    -| * 82e74ab      2014-03-11 ~ Add widget
    -|/
    -* d08c5b3        (bogus_noparent) 2014-03-11 ~ Wonderful beginnings    <(cool_feature)
    -
    -

    Note that this example repo is in dire need of a git-rebase-update(1)!

    -
    -
    -
    $ git map-branches
    -origin/master
    -  cool_feature
    -    subfeature
    -  frozen_changes *
    -  master
    -
    -
    -
    -git-map(1) -
    -
    -

    - This tool shows you the history of all of your branches in a pseudo-graphical - format. In particular, it will show you which commits all of your branches - are on, which commit you currently have checked out, and more. Check out the - doc for the full details. -

    -
    -
    -git-map-branches(1) -
    -
    -

    - This tool just shows you which branches you have in your repo, and thier - upstream relationship to each other (as well as which branch you have checked - out at the moment). -

    -
    -
    -

    Additionally, sometimes you need to switch between branches, but you’ve got work -in progress. You could use git-stash(1), but that can be tricky to -manage because you need to remember which branches you stashed what changes on. -Helpfully depot_tools includes two tools which can greatly assist in case:

    -

    git-freeze(1) allows you to put the current branch in 'suspended -animation' by committing your changes to a specially-named commit on the top of -your current branch. When you come back to your branch later, you can just run -git-thaw(1) to get your work-in-progress changes back to what they were.

    -

    Another useful tool is git-rename-branch(1). Unlike git branch -m <old> -<new>, this tool will correctly preserve the upstream relationships of your -branch compared to its downstreams.

    -

    Finally, take a look at git-upstream-diff(1). This will show you the -combined diff for all the commits on your branch against the upstream tracking -branch. This is exactly what git cl upload will push up to code review. -Additionally, consider trying the --wordwise argument to get a colorized -per-word diff (instead of a per-line diff).

    -
    -
    -
    -

    MANAGING DEPENDENT CLS

    -
    -

    Now that you know how to manage independent CLs, we’ll see how to manage -dependent CLs. Dependent CLs are useful when your second (or third or fourth -or …) CL depends on the changes in one of your other CLs (such as: CL 2 won’t -compile without CL 1, but you want to submit them as two separate reviews).

    -

    Like all of the other CLs we’ve created, we use git-new-branch(1), but -this time with an extra argument. First, git checkout the branch -you want to base the new one on (i.e. CL 1), and then run:

    -
    -
    -
    $ git new-branch --upstream_current <branch_name>
    -
    -

    This will make a new branch which tracks the current branch as its upstream -(as opposed to origin/master). All changes you commit to this branch will be -in addition to the previous branch, but when you git cl upload, you will only -upload the diff for the dependent (child) branch. You may have as many branches -nested in this fashion as you like.

    -

    git-map(1) and git-map-branches(1) are particularly helpful when -you have dependent branches. In addition, there are two helper commands which -let you traverse your working copy up and down this tree of branches: -git-nav-upstream(1) and git-nav-downstream(1).

    -

    Sometimes when dealing with dependent CLs, it turns out that you accidentally -based a branch on the wrong upstream, but since then you’ve committed changes to -it, or even based another branch off of that one. Or you discover that you -have two independent CLs that would actually be much better off as dependent -CLs. In instances like these, you can check out the offending branch and use -git-reparent-branch(1) to move it to track a different parent. Note that -this can also be used to move a branch from tracking origin/master to lkgr -or vice versa.

    -
    -
    -

    CONCLUSION

    Hopefully that gives you a good starting overview on Chromium development using @@ -1564,7 +1587,7 @@ from


    diff --git a/docs/man7/depot_tools_tutorial.7 b/docs/man7/depot_tools_tutorial.7 index d4ec51d1fd..c8b65ad3ac 100644 --- a/docs/man7/depot_tools_tutorial.7 +++ b/docs/man7/depot_tools_tutorial.7 @@ -2,12 +2,12 @@ .\" Title: depot_tools_tutorial .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 04/10/2014 +.\" Date: 04/14/2014 .\" Manual: Chromium depot_tools Manual -.\" Source: depot_tools bec7be9 +.\" Source: depot_tools e722300 .\" Language: English .\" -.TH "DEPOT_TOOLS_TUTORIAL" "7" "04/10/2014" "depot_tools bec7be9" "Chromium depot_tools Manual" +.TH "DEPOT_TOOLS_TUTORIAL" "7" "04/14/2014" "depot_tools e722300" "Chromium depot_tools Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -63,7 +63,7 @@ Getting the code .sp -1 .IP \(bu 2.3 .\} -TL;DR Walkthrough +TL;DR .RE .sp .RS 4 @@ -110,6 +110,17 @@ Managing multiple CLs Managing dependent CLs .RE .sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Example Walkthrough +.RE +.sp Please refer to the manpages (or \-\-help output) for details about any of the commands mentioned in this tutorial\&. .if n \{\ .sp @@ -247,6 +258,33 @@ If you have never used git before, you\(cqll need to set some global git configu .RE .\} .sp +.SH "TL;DR" +.sp +.if n \{\ +.RS 4 +.\} +.nf +\fB$\fR # get the code +\fB$\fR # In an empty directory: +\fB$ fetch {chromium,blink,\&.\&.\&.}\fR + +\fB$\fR # Update third_party repos and run pre\-compile hooks +\fB$ gclient sync\fR + +\fB$\fR # Make a new change and upload it for review +\fB$ git new\-branch branchname\fR +\fB$\fR # repeat: [edit, git add, git commit] +\fB$ git cl upload\fR + +\fB$\fR # After change is reviewed, commit with the CQ +\fB$ git cl set_commit\fR +\fB$\fR # Note that the committed hash which lands will /not/ match the +\fB$\fR # commit hashes of your local branch\&. +.fi +.if n \{\ +.RE +.\} +.sp .SH "GETTING THE CODE" .sp Pick an empty directory and run one of the following: @@ -298,16 +336,190 @@ And finally: .RS 4 .\} .nf -\fB$ gclient sync\fR \fB(1)\fR +\fB$ gclient sync\fR .fi .if n \{\ .RE .\} .sp .sp -\fB1. \fRThis will pull all dependencies of the Chromium src checkout\&. You will need to run this any time you update the main src checkout\&. +This will pull all dependencies of the Chromium src checkout\&. You will need to run this any time you update the main src checkout\&. +.SH "CREATING / UPLOADING A CL" +.if n \{\ +.sp +.\} +.RS 4 +.it 1 an-trap +.nr an-no-space-flag 1 +.nr an-break-flag 1 +.br +.ps +1 +\fBNote\fR +.ps -1 .br -.SH "TL;DR WALKTHROUGH" +.sp +The remainder of the tutorial assumes that your current working directory is the src/ folder mentioned in Getting the code\&. +.sp .5v +.RE +.sp +Each CL corresponds exactly with a single branch in git\&. Any time you want to begin a new CL, just: +.sp +.if n \{\ +.RS 4 +.\} +.nf +\fB$ git new\-branch \fR +.fi +.if n \{\ +.RE +.\} +.sp +.sp +This will create and checkout a new branch named branch_name which will track the default upstream (which is origin/master)\&. See \fBgit-new-branch\fR(1) for more features, such as the ability to track \fILKGR\fR\&. +.sp +Commit as many changes as you like to this branch\&. When you want to upload it for review, run: +.sp +.if n \{\ +.RS 4 +.\} +.nf +\fB$ git cl upload\fR +.fi +.if n \{\ +.RE +.\} +.sp +.sp +This will take the diff of your branch against its upstream (origin/master), and will post it to the \m[blue]\fBChromium code review site\fR\m[]\&\s-2\u[5]\d\s+2\&. +.SH "UPDATING THE CODE" +.sp +Inevitably, you\(cqll want to pull in changes from the main Chromium repo\&. This is pretty easy with \fIdepot_tools\fR: +.sp +.if n \{\ +.RS 4 +.\} +.nf +\fB$ git rebase\-update\fR +.fi +.if n \{\ +.RE +.\} +.sp +.sp +This command will update all of your CLs to contain the latest code from their upstreams\&. It will also automatically clean up CLs which have been committed and a couple other nice things\&. See \fBgit-rebase-update\fR(1) for the full scoop\&. +.sp +One thing to look out for are \fImerge conflicts\fR\&. These happen for exactly the same as they do with SVN, but the experience is a little more controllable with git\&. git rebase\-update will try to rebase all your branches for you, but if it encounters a merge conflict in one, it will halt and leave you in a rebase conflict state (see \fBgit-rebase\fR(1))\&. Resolving git rebase merge conflicts is beyond the scope of this tutorial, but there are many good sources online (see the Prerequisites for some)\&. +.sp +Sometimes you\(cqre pretty certain that you\(cqve committed a certain branch, but git rebase\-update isn\(cqt able to tell that for sure\&. This is usually because your branch doesn\(cqt rebase cleanly\&. You could just delete the branch with git branch \-D , but you\(cqd like to double check the diff of your branch against its upstream before deleting it\&. If this is the case you can abort the rebase started by git rebase\-update, and then run \fBgit-squash-branch\fR(1) to flatten your branch into a single commit\&. When you run git rebase\-update again, you\(cqll get a (hopefully) much smaller / saner diff\&. If it turns out you were wrong about your branch being fully committed, you can use \fBgit-reflog\fR(1) to reset your branch back to where it was before\&. If the diff looks inconsequential, you can use git rebase \-\-skip to ignore it, and then git rebase\-update will clean it up for you\&. +.sp +Once you\(cqre done resolving all of the merge conflict, just run git rebase\-update, and it will pick up where it left off\&. Once the command has finished updating all of your branches, it will return you back to the branch you started on\&. +.if n \{\ +.sp +.\} +.RS 4 +.it 1 an-trap +.nr an-no-space-flag 1 +.nr an-break-flag 1 +.br +.ps +1 +\fBNote\fR +.ps -1 +.br +.sp +Running git rebase\-update will update all your branches, but it will not automatically run gclient sync to update your dependencies\&. +.sp .5v +.RE +.SH "MANAGING MULTIPLE CLS" +.sp +Sometimes you want to work on more than one CL at once (say, you have a CL posted for review and want to work on something else)\&. For each CL that you want to work on, just use git new\-branch \&. +.sp +Once you start to have more than one CL at a time, it can be easy to lose your bearings\&. Fortunately, \fIdepot_tools\fR has two tools to help you out: +.sp +.if n \{\ +.RS 4 +.\} +.nf +\fB$ git map\fR +*\:\fB 7dcfe47 \fR (\:\fBfrozen_changes\fR\:) 2014\-03\-12 ~ FREEZE\&.unindexed +* \fB4b0c180\fR 2014\-03\-12 ~ modfile +* \fB59a7cca\fR 2014\-03\-12 ~ a deleted file +* \fB6bec695\fR (\:origin/master\:) 2014\-03\-11 ~ Add neat feature \fB<(frozen_changes)\fR +* \fBd15a38a\fR 2014\-03\-11 ~ Epic README update +* \fBd559894\fR (\:\fBmaster\fR\:) 2014\-03\-11 ~ Important upstream change +| * \fB9c311fd\fR (\:\fBcool_feature\fR\:) 2014\-03\-11 ~ Respond to CL comments +| | * \fB2a1eeb2\fR (\:\fBsubfeature\fR\:) 2014\-03\-11 ~ integrate with CoolService +| | * \fBd777af6\fR 2014\-03\-11 ~ slick commenting action +| |/ +| * \fB265803a\fR 2014\-03\-11 ~ another improvement \fB<(subfeature)\fR +| * \fB6d831ac\fR (\:\fBspleen_tag\fR\:) 2014\-03\-11 ~ Refactor spleen +| * \fB82e74ab\fR 2014\-03\-11 ~ Add widget +|/ +* \fBd08c5b3\fR (\:\fBbogus_noparent\fR\:) 2014\-03\-11 ~ Wonderful beginnings \fB<(cool_feature)\fR +.fi +.if n \{\ +.RE +.\} +.sp +.sp +Note that this example repo is in dire need of a \fBgit-rebase-update\fR(1)! +.sp +.if n \{\ +.RS 4 +.\} +.nf +\fB$ git map\-branches\fR +origin/master + cool_feature + subfeature + frozen_changes * + master +.fi +.if n \{\ +.RE +.\} +.sp + +.PP +\fBgit-map\fR(1) +.RS 4 +This tool shows you the history of all of your branches in a pseudo\-graphical format\&. In particular, it will show you which commits all of your branches are on, which commit you currently have checked out, and more\&. Check out the doc for the full details\&. +.RE +.PP +\fBgit-map-branches\fR(1) +.RS 4 +This tool just shows you which branches you have in your repo, and thier upstream relationship to each other (as well as which branch you have checked out at the moment)\&. +.RE +.sp +Additionally, sometimes you need to switch between branches, but you\(cqve got work in progress\&. You could use \fBgit-stash\fR(1), but that can be tricky to manage because you need to remember which branches you stashed what changes on\&. Helpfully \fIdepot_tools\fR includes two tools which can greatly assist in case: +.sp +\fBgit-freeze\fR(1) allows you to put the current branch in \*(Aqsuspended animation\*(Aq by committing your changes to a specially\-named commit on the top of your current branch\&. When you come back to your branch later, you can just run \fBgit-thaw\fR(1) to get your work\-in\-progress changes back to what they were\&. +.sp +Another useful tool is \fBgit-rename-branch\fR(1)\&. Unlike git branch \-m , this tool will correctly preserve the upstream relationships of your branch compared to its downstreams\&. +.sp +Finally, take a look at \fBgit-upstream-diff\fR(1)\&. This will show you the combined diff for all the commits on your branch against the upstream tracking branch\&. This is \fIexactly\fR what git cl upload will push up to code review\&. Additionally, consider trying the \-\-wordwise argument to get a colorized per\-word diff (instead of a per\-line diff)\&. +.SH "MANAGING DEPENDENT CLS" +.sp +Now that you know how to manage \fIindependent\fR CLs, we\(cqll see how to manage \fIdependent\fR CLs\&. Dependent CLs are useful when your second (or third or fourth or \&...) CL depends on the changes in one of your other CLs (such as: CL 2 won\(cqt compile without CL 1, but you want to submit them as two separate reviews)\&. +.sp +Like all of the other CLs we\(cqve created, we use \fBgit-new-branch\fR(1), but this time with an extra argument\&. First, git checkout the branch you want to base the new one on (i\&.e\&. CL 1), and then run: +.sp +.if n \{\ +.RS 4 +.\} +.nf +\fB$ git new\-branch \-\-upstream_current \fR +.fi +.if n \{\ +.RE +.\} +.sp +.sp +This will make a new branch which tracks the \fIcurrent\fR branch as its upstream (as opposed to \fIorigin/master\fR)\&. All changes you commit to this branch will be in addition to the previous branch, but when you git cl upload, you will only upload the diff for the dependent (child) branch\&. You may have as many branches nested in this fashion as you like\&. +.sp +\fBgit-map\fR(1) and \fBgit-map-branches\fR(1) are particularly helpful when you have dependent branches\&. In addition, there are two helper commands which let you traverse your working copy up and down this tree of branches: \fBgit-nav-upstream\fR(1) and \fBgit-nav-downstream\fR(1)\&. +.sp +Sometimes when dealing with dependent CLs, it turns out that you accidentally based a branch on the wrong upstream, but since then you\(cqve committed changes to it, or even based \fIanother\fR branch off of that one\&. Or you discover that you have two independent CLs that would actually be much better off as dependent CLs\&. In instances like these, you can check out the offending branch and use \fBgit-reparent-branch\fR(1) to move it to track a different parent\&. Note that this can also be used to move a branch from tracking origin/master to lkgr or vice versa\&. +.SH "EXAMPLE WALKTHROUGH" .sp This section will demo what a typical workflow looks like when writing, updating, and committing multiple CLs\&. .sp @@ -376,10 +588,10 @@ It was a Domo\-Kuun\&. * \fB2250f53 \fR 2014\-04\-10 ~ ozone: evdev: Filter devices by path * \fB33a7a74 \fR 2014\-04\-10 ~ Always output seccomp error messages to stderr \fB$ git status\fR -# On branch fix_typo -# Your branch is ahead of \*(Aqorigin/master\*(Aq by 1 commit\&. -# (use "git push" to publish your local commits) -# +On branch fix_typo +Your branch is ahead of \*(Aqorigin/master\*(Aq by 1 commit\&. + (use "git push" to publish your local commits) + nothing to commit, working directory clean \fB$ git cl upload \-r domo@chromium\&.org \-\-send\-mail\fR \&.\&.\&. truncated output \&.\&.\&. @@ -406,15 +618,15 @@ overhead, barely disturbing the thick cigarette smoke\&. No doubt was left about when the fan was last cleaned\&. EOF \fB$ git status\fR -# On branch chap2 -# Your branch is up\-to\-date with \*(Aqorigin/master\*(Aq\&. -# -# Changes not staged for commit: -# (use "git add \&.\&.\&." to update what will be committed) -# (use "git checkout \-\- \&.\&.\&." to discard changes in working directory) -# -# modified: build/whitespace_file\&.txt -# +On branch chap2 +Your branch is up\-to\-date with \*(Aqorigin/master\*(Aq\&. + +Changes not staged for commit: + (use "git add \&.\&.\&." to update what will be committed) + (use "git checkout \-\- \&.\&.\&." to discard changes in working directory) + + modified: build/whitespace_file\&.txt + no changes added to commit (use "git add" and/or "git commit \-a") .fi .if n \{\ @@ -780,181 +992,6 @@ chap3 up\-to\-date .sp .sp So there you have the basic flow\&. Note that you don\(cqt \fIhave\fR to do chromium development using these tools\&. Any git workflow is compatible, as long as git cl upload is able to upload good patches\&. -.SH "CREATING / UPLOADING A CL" -.if n \{\ -.sp -.\} -.RS 4 -.it 1 an-trap -.nr an-no-space-flag 1 -.nr an-break-flag 1 -.br -.ps +1 -\fBNote\fR -.ps -1 -.br -.sp -The remainder of the tutorial assumes that your current working directory is the src/ folder mentioned in Getting the code\&. -.sp .5v -.RE -.sp -Each CL corresponds exactly with a single branch in git\&. Any time you want to begin a new CL, just: -.sp -.if n \{\ -.RS 4 -.\} -.nf -\fB$ git new\-branch \fR -.fi -.if n \{\ -.RE -.\} -.sp -.sp -This will create and checkout a new branch named branch_name which will track the default upstream (which is origin/master)\&. See \fBgit-new-branch\fR(1) for more features, such as the ability to track \fILKGR\fR\&. -.sp -Commit as many changes as you like to this branch\&. When you want to upload it for review, run: -.sp -.if n \{\ -.RS 4 -.\} -.nf -\fB$ git cl upload\fR -.fi -.if n \{\ -.RE -.\} -.sp -.sp -This will take the diff of your branch against its upstream (origin/master), and will post it to the \m[blue]\fBChromium code review site\fR\m[]\&\s-2\u[5]\d\s+2\&. -.SH "UPDATING THE CODE" -.sp -Inevitably, you\(cqll want to pull in changes from the main Chromium repo\&. This is pretty easy with \fIdepot_tools\fR: -.sp -.if n \{\ -.RS 4 -.\} -.nf -\fB$ git rebase\-update\fR -.fi -.if n \{\ -.RE -.\} -.sp -.sp -This command will update all of your CLs to contain the latest code from their upstreams\&. It will also automatically clean up CLs which have been committed and a couple other nice things\&. See \fBgit-rebase-update\fR(1) for the full scoop\&. -.sp -One thing to look out for are \fImerge conflicts\fR\&. These happen for exactly the same as they do with SVN, but the experience is a little more controllable with git\&. git rebase\-update will try to rebase all your branches for you, but if it encounters a merge conflict in one, it will halt and leave you in a rebase conflict state (see \fBgit-rebase\fR(1))\&. Resolving git rebase merge conflicts is beyond the scope of this tutorial, but there are many good sources online (see the Prerequisites for some)\&. -.sp -Sometimes you\(cqre pretty certain that you\(cqve committed a certain branch, but git rebase\-update isn\(cqt able to tell that for sure\&. This is usually because your branch doesn\(cqt rebase cleanly\&. You could just delete the branch with git branch \-D , but you\(cqd like to double check the diff of your branch against its upstream before deleting it\&. If this is the case you can abort the rebase started by git rebase\-update, and then run \fBgit-squash-branch\fR(1) to flatten your branch into a single commit\&. When you run git rebase\-update again, you\(cqll get a (hopefully) much smaller / saner diff\&. If it turns out you were wrong about your branch being fully committed, you can use \fBgit-reflog\fR(1) to reset your branch back to where it was before\&. If the diff looks inconsequential, you can use git rebase \-\-skip to ignore it, and then git rebase\-update will clean it up for you\&. -.sp -Once you\(cqre done resolving all of the merge conflict, just run git rebase\-update, and it will pick up where it left off\&. Once the command has finished updating all of your branches, it will return you back to the branch you started on\&. -.if n \{\ -.sp -.\} -.RS 4 -.it 1 an-trap -.nr an-no-space-flag 1 -.nr an-break-flag 1 -.br -.ps +1 -\fBNote\fR -.ps -1 -.br -.sp -Running git rebase\-update will update all your branches, but it will not automatically run gclient sync to update your dependencies\&. -.sp .5v -.RE -.SH "MANAGING MULTIPLE CLS" -.sp -Sometimes you want to work on more than one CL at once (say, you have a CL posted for review and want to work on something else)\&. For each CL that you want to work on, just use git new\-branch \&. -.sp -Once you start to have more than one CL at a time, it can be easy to lose your bearings\&. Fortunately, \fIdepot_tools\fR has two tools to help you out: -.sp -.if n \{\ -.RS 4 -.\} -.nf -\fB$ git map\fR -*\:\fB 7dcfe47 \fR (\:\fBfrozen_changes\fR\:) 2014\-03\-12 ~ FREEZE\&.unindexed -* \fB4b0c180\fR 2014\-03\-12 ~ modfile -* \fB59a7cca\fR 2014\-03\-12 ~ a deleted file -* \fB6bec695\fR (\:origin/master\:) 2014\-03\-11 ~ Add neat feature \fB<(frozen_changes)\fR -* \fBd15a38a\fR 2014\-03\-11 ~ Epic README update -* \fBd559894\fR (\:\fBmaster\fR\:) 2014\-03\-11 ~ Important upstream change -| * \fB9c311fd\fR (\:\fBcool_feature\fR\:) 2014\-03\-11 ~ Respond to CL comments -| | * \fB2a1eeb2\fR (\:\fBsubfeature\fR\:) 2014\-03\-11 ~ integrate with CoolService -| | * \fBd777af6\fR 2014\-03\-11 ~ slick commenting action -| |/ -| * \fB265803a\fR 2014\-03\-11 ~ another improvement \fB<(subfeature)\fR -| * \fB6d831ac\fR (\:\fBspleen_tag\fR\:) 2014\-03\-11 ~ Refactor spleen -| * \fB82e74ab\fR 2014\-03\-11 ~ Add widget -|/ -* \fBd08c5b3\fR (\:\fBbogus_noparent\fR\:) 2014\-03\-11 ~ Wonderful beginnings \fB<(cool_feature)\fR -.fi -.if n \{\ -.RE -.\} -.sp -.sp -Note that this example repo is in dire need of a \fBgit-rebase-update\fR(1)! -.sp -.if n \{\ -.RS 4 -.\} -.nf -\fB$ git map\-branches\fR -origin/master - cool_feature - subfeature - frozen_changes * - master -.fi -.if n \{\ -.RE -.\} -.sp - -.PP -\fBgit-map\fR(1) -.RS 4 -This tool shows you the history of all of your branches in a pseudo\-graphical format\&. In particular, it will show you which commits all of your branches are on, which commit you currently have checked out, and more\&. Check out the doc for the full details\&. -.RE -.PP -\fBgit-map-branches\fR(1) -.RS 4 -This tool just shows you which branches you have in your repo, and thier upstream relationship to each other (as well as which branch you have checked out at the moment)\&. -.RE -.sp -Additionally, sometimes you need to switch between branches, but you\(cqve got work in progress\&. You could use \fBgit-stash\fR(1), but that can be tricky to manage because you need to remember which branches you stashed what changes on\&. Helpfully \fIdepot_tools\fR includes two tools which can greatly assist in case: -.sp -\fBgit-freeze\fR(1) allows you to put the current branch in \*(Aqsuspended animation\*(Aq by committing your changes to a specially\-named commit on the top of your current branch\&. When you come back to your branch later, you can just run \fBgit-thaw\fR(1) to get your work\-in\-progress changes back to what they were\&. -.sp -Another useful tool is \fBgit-rename-branch\fR(1)\&. Unlike git branch \-m , this tool will correctly preserve the upstream relationships of your branch compared to its downstreams\&. -.sp -Finally, take a look at \fBgit-upstream-diff\fR(1)\&. This will show you the combined diff for all the commits on your branch against the upstream tracking branch\&. This is \fIexactly\fR what git cl upload will push up to code review\&. Additionally, consider trying the \-\-wordwise argument to get a colorized per\-word diff (instead of a per\-line diff)\&. -.SH "MANAGING DEPENDENT CLS" -.sp -Now that you know how to manage \fIindependent\fR CLs, we\(cqll see how to manage \fIdependent\fR CLs\&. Dependent CLs are useful when your second (or third or fourth or \&...) CL depends on the changes in one of your other CLs (such as: CL 2 won\(cqt compile without CL 1, but you want to submit them as two separate reviews)\&. -.sp -Like all of the other CLs we\(cqve created, we use \fBgit-new-branch\fR(1), but this time with an extra argument\&. First, git checkout the branch you want to base the new one on (i\&.e\&. CL 1), and then run: -.sp -.if n \{\ -.RS 4 -.\} -.nf -\fB$ git new\-branch \-\-upstream_current \fR -.fi -.if n \{\ -.RE -.\} -.sp -.sp -This will make a new branch which tracks the \fIcurrent\fR branch as its upstream (as opposed to \fIorigin/master\fR)\&. All changes you commit to this branch will be in addition to the previous branch, but when you git cl upload, you will only upload the diff for the dependent (child) branch\&. You may have as many branches nested in this fashion as you like\&. -.sp -\fBgit-map\fR(1) and \fBgit-map-branches\fR(1) are particularly helpful when you have dependent branches\&. In addition, there are two helper commands which let you traverse your working copy up and down this tree of branches: \fBgit-nav-upstream\fR(1) and \fBgit-nav-downstream\fR(1)\&. -.sp -Sometimes when dealing with dependent CLs, it turns out that you accidentally based a branch on the wrong upstream, but since then you\(cqve committed changes to it, or even based \fIanother\fR branch off of that one\&. Or you discover that you have two independent CLs that would actually be much better off as dependent CLs\&. In instances like these, you can check out the offending branch and use \fBgit-reparent-branch\fR(1) to move it to track a different parent\&. Note that this can also be used to move a branch from tracking origin/master to lkgr or vice versa\&. .SH "CONCLUSION" .sp Hopefully that gives you a good starting overview on Chromium development using \fIdepot_tools\fR\&. If you have questions which weren\(cqt answered by this tutorial or the man pages for the tools (see the index of all tools here: \fBdepot_tools\fR(7)), please feel free to ask\&. diff --git a/docs/src/depot_tools_tutorial.demo.tldr.sh b/docs/src/depot_tools_tutorial.demo.walkthrough.sh similarity index 100% rename from docs/src/depot_tools_tutorial.demo.tldr.sh rename to docs/src/depot_tools_tutorial.demo.walkthrough.sh diff --git a/docs/src/depot_tools_tutorial.txt b/docs/src/depot_tools_tutorial.txt index 5d08da4985..6c81e68826 100644 --- a/docs/src/depot_tools_tutorial.txt +++ b/docs/src/depot_tools_tutorial.txt @@ -16,11 +16,12 @@ Chromium using these tools. This will cover: * <<_setting_up,Setting up>> * <<_getting_the_code,Getting the code>> -* <<_tl_dr_walkthrough,TL;DR Walkthrough>> +* <<_tl_dr,TL;DR>> * <<_creating_uploading_a_cl,Creating / Uploading a CL>> * <<_updating_the_code,Updating the code>> * <<_managing_multiple_cls,Managing multiple CLs>> * <<_managing_dependent_cls,Managing dependent CLs>> +* <<_example_walkthrough,Example Walkthrough>> Please refer to the manpages (or `--help` output) for details about any of the commands mentioned in this tutorial. @@ -145,6 +146,29 @@ commands: [white]**$ git config --global color.ui true** ---- +TL;DR +----- +[postsubs="quotes"] +---- +[white]**$** # get the code +[white]**$** # In an empty directory: +[white]**$ fetch {chromium,blink,...}** + +[white]**$** # Update third_party repos and run pre-compile hooks +[white]**$ gclient sync** + +[white]**$** # Make a new change and upload it for review +[white]**$ git new-branch branchname** +[white]**$** # repeat: [edit, git add, git commit] +[white]**$ git cl upload** + +[white]**$** # After change is reviewed, commit with the CQ +[white]**$ git cl set_commit** +[white]**$** # Note that the committed hash which lands will /not/ match the +[white]**$** # commit hashes of your local branch. +---- + + GETTING THE CODE ---------------- Pick an empty directory and run one of the following: @@ -177,22 +201,11 @@ And finally: [postsubs="quotes"] ---- -[white]**$ gclient sync** <1> +[white]**$ gclient sync** ---- -<1> This will pull all dependencies of the Chromium src checkout. You will need -to run this any time you update the main src checkout. - - -TL;DR WALKTHROUGH ------------------ -This section will demo what a typical workflow looks like when writing, updating, -and committing multiple CLs. -demo:tldr[] - -So there you have the basic flow. Note that you don't 'have' to do chromium -development using these tools. Any git workflow is compatible, as long as -`git cl upload` is able to upload good patches. +This will pull all dependencies of the Chromium src checkout. You will need +to run this any time you update the main src checkout. CREATING / UPLOADING A CL @@ -379,6 +392,18 @@ this can also be used to move a branch from tracking `origin/master` to `lkgr` or vice versa. +EXAMPLE WALKTHROUGH +------------------- +This section will demo what a typical workflow looks like when writing, +updating, and committing multiple CLs. + +demo:walkthrough[] + +So there you have the basic flow. Note that you don't 'have' to do chromium +development using these tools. Any git workflow is compatible, as long as +`git cl upload` is able to upload good patches. + + CONCLUSION ---------- Hopefully that gives you a good starting overview on Chromium development using