Changes between Version 41 and Version 42 of GitMirror


Ignore:
Timestamp:
05/10/2016 12:11:28 PM (17 months ago)
Author:
Glyph
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • GitMirror

    v41 v42  
    11[wiki:ContributingToTwistedLabs Contribute] > [wiki:TwistedDevelopment Development] > [wiki:VcsWorkflows DVCS Workflows] > Git
    22
    3 [[PageOutline(1-3, , inline)]]
    4 
    5 = For Twisted contributors =
    6 
    7 If you want to develop a patch for Twisted (as described in the BasicGuideToContributingCode) but prefer to use Git rather than SVN, this is the section for you.
    8 
    9 For other version control systems, see [wiki:VcsWorkflows DVCS Workflows].
    10 
    11 == Creating a Git clone ==
    12 
    13 Twisted has an up-to-date [https://github.com/twisted/twisted mirror] on github.
    14 
    15  1. Create a Git clone of the repository by running this command:
    16 {{{
    17 git clone https://github.com/twisted/twisted Twisted
    18 }}}
    19     This should create a subdirectory named `Twisted` containing the latest trunk revision of the code.
    20  1. Since Twisted is normally developed in SVN, Twisted developers are used to processing SVN-style patch files, not Git's patch format. You can change the behaviour of `git diff` to match SVN just for this single repository with the following commands:
    21 {{{
    22 git config --file Twisted/.git/config --bool --add diff.noprefix true
    23 }}}
    24 Note: this can make tools like `magit` work in odd ways.
    25 
    26 == Updating your Git clone ==
    27 
    28 If more commits have been made to the SVN trunk, or a Twisted developer has created a new branch for your patch to live on, you'll want to update your clone with those changes so that you can produce new patches based on those changes. Just `cd` into the repository and run:
    29 
    30 {{{
    31 git fetch
    32 git checkout trunk
    33 git rebase origin/trunk
    34 }}}
    35 
    36 == Submitting Patches ==
    37 
    38 Twisted core reviewers ''do not'' watch the GitHub pull request list. However, if you wish, you can submit a pull request to the Twisted project, and link to the pull request in a Twisted ticket when marking it for review.
    39 
    40 If you like, you can instead attach a patch directly to the ticket:
    41 
    42 While on the branch for which you want to generate a diff
    43 
    44 {{{
    45 git diff origin... > destroy-the-sun.patch
    46 }}}
    47 or, if there is already a branch in svn,
    48 {{{
    49 git fetch
    50 git diff origin/destroy-the-sun-5000.. > destroy-the-sun-v666.patch
    51 }}}
    52 and then attach the patch to the appropriate ticket.
    53 ----
    54 
    55 = For Twisted core developers =
    56 
    57 Start by reading the [wiki:CommitterCheckList general commiter check list]
    58 
    59 Event if you will use git, you still need to have SVN installed, as at least mkbranch needs it.
    60 
    61 To be able to interact with svn, the following commands need to be run in the repository created above, replacing USERNAME with your SVN account name.
    62 
    63 {{{
    64 git svn init --stdlayout --tags tags/releases --prefix origin/ \
    65     --rewrite-root=svn://svn.twistedmatrix.com/svn/Twisted \
    66     svn+ssh://USERNAME@svn.twistedmatrix.com/svn/Twisted
    67 git svn dcommit -n
    68 }}}
    69 
    70 Twisted does not completely follow the standard SVN repository layout. In particular, there is a "branches/releases" directory that contains more branches (as opposed to being a branch) and a "tags/releases" directory that contains more tags (as opposed to being a tag). Thus, git cannot be used to commit to release branches.   
    71 
    72 You also should set a global config to tell git-svn to remove directories that have been made newly-empty, since git doesn't track directories, while svn does:
    73 {{{
    74 git config --global --bool svn.rmdir true
    75 }}}
    76 
    77 == git svn branching ==
    78 
    79 Follow the [http://twistedmatrix.com/documents/current/core/development/policy/svn-dev.html#auto6 standard Twisted branch-name conventions] when creating branches with Git.
    80 
    81 Use the `mkbranch` utility from [https://pypi.python.org/pypi/twisted-dev-tools twisted-dev-tools]. Use it as follows:
    82 
    83 {{{
    84 mkbranch $BRANCH_NAME
    85 git fetch
    86 git checkout $BRANCH_NAME
    87 }}}
    88 
    89 == git svn committing ==
    90 
    91 `git commit` only makes local commits. To get commits into svn,
    92 {{{
    93 git svn dcommit --dry
    94 }}}
    95 will (update git-svn's metadata cache and) show where git will try to commit, and the list of commits it will push.
    96 {{{
    97 git svn dcommit
    98 }}}
    99 will actually push the changes to svn.
    100 
    101 No special rules apply about making Git commits, you can make as many commits as you like, then rebase them into a nice patch series as normal (although the Twisted review process generally reviews the diff of an entire branch, not individual commits, since rebasing isn't possible in SVN).
    102 
    103 However, once you send your patches to the central SVN server with `git svn dcommit`, be very careful about messing with them. Don't rebase any further back than the last push, or else the next `dcommit` is likely to go awry.
    104 
    105 Likewise, if you merge from trunk to branch, then `dcommit` the merge, it will become an ordinary commit that doesn't remember its ancestry, and merging it back onto the trunk later is likely to cause grief. So don't do that.
    106 
    107 == git svn merging forward / solving conflicts ==
    108 
    109 "Merging forward" means rebranching trunk and merging your changes in.
    110 It has roughly the same effect as merging trunk into your branch in git.
    111 Doing it this way works more reliably with svn.
    112 
    113 In case your old branch conflicts with trunk, you will need to create a new branch merge it forward.
    114 Don't merge trunk into your branch in git using the usual {{{git merge}}} command. This will not fix the conflicts in SVN, but only on your local GIT branch.
    115 
    116 {{{
    117 mkbranch $BRANCH_NAME-2
    118 git fetch
    119 git checkout $BRANCH_NAME-2
    120 git merge --ff --squash origin/$BRANCH_NAME
    121 git commit -m'Merging forward'
    122 git svn dcommit
    123 }}}
    124 
    125 
    126 == git svn branch merging ==
    127 
    128 In the following example, `$BRANCH_NAME` means the name of the branch you're trying to merge to trunk.
    129 
    130 {{{
    131 # Check out the trunk (what git calls 'master'), make sure it's up-to-date.
    132 git checkout origin/trunk
    133 
    134 # Apply all the changes on the branch to the trunk as one change set.
    135 git merge --ff --squash origin/$BRANCH_NAME
    136 
    137 # Commit the change set. Remember to use the Canonical Merge Commit Message Format!
    138 git commit
    139 
    140 # Push the commit to the central SVN repository.
    141 git svn dcommit
    142 }}}
    143 
    144 By "Canonical Merge Commit Message Format", I mean the example merge commit message in [wiki:ReviewProcess#Authors:Howtomergethechangetotrunk the review process].
    145 
    146 
    147 == reverting - reopening ticktes ==
    148 
    149 In the unfortunate event of breaking trunk the commit which cause the failure should be reverted as soon as possible and the fix merged in a separate commnit.
    150 
    151 Identify the git SHA revision number of the commit which introduce the error and revert that commit.
    152 
    153 {{{
    154 
    155 git revert a1b2c313
    156 # Edit the new commit message
    157 # Then push the changes.
    158 git svn dcommit
    159 }}}
    160 
    161 As the commit message use the standard format as described in [wiki:ReviewProcess#Revertingachange]
    162 
    163 For now the commit message will contain the **SVN ID**.
    164 The SVN revision ID look for the `git-svn-id` comment from the commit message.
    165 
     3Our code is hosted at https://github.com/twisted/twisted - it is not longer a mirror.