Tekkaman

导航

 

svn之merge

1. merge SOURCE[@REV] [TARGET_WCPATH]   (the 'sync' merge)

    This form is called a 'sync' (or 'catch-up') merge:

       svn merge SOURCE[@REV] [TARGET_WCPATH]

     A sync merge is used to fetch all the latest changes made on a parent branch. In other words, the target branch has originally been created by copying the source branch, and any changes committed on the source branch since branching are applied to the target branch. This uses merge tracking to skip all those revisions that have already been merged, so a sync merge can be repeated periodically to stay up-to-date with the source branch. 

  SOURCE specifies the branch from where the changes will be pulled, and TARGET_WCPATH specifies a working copy of the target branch to which the changes will be applied. Normally SOURCE and TARGET_WCPATH should each correspond to the root of a branch. (If you want to merge only a subtree, then the subtree path must be included in both SOURCE and TARGET_WCPATH; this is discouraged, to avoid subtree mergeinfo.)

     TARGET_WCPATH is a working copy path; if omitted, '.' is assumed.

  

  svn merge ^/trunk

2. merge [-c M[,N...] | -r N:M ...] SOURCE[@REV] [TARGET_WCPATH]  (the 'cherry-pick' merge)

  This form is called a 'cherry-pick' merge:

       svn merge [-c M[,N...] | -r N:M ...] SOURCE[@REV] [TARGET_WCPATH]

     A cherry-pick merge is used to merge specific revisions (or revision ranges) from one branch to another. By default, this uses merge tracking to automatically skip any revisions that have already been merged to the target; you can use the --ignore-ancestry option to disable such skipping.

   SOURCE is usually a URL. The optional '@REV' specifies only the peg revision of the URL and does not affect the merge range; if REV is not specified, the HEAD revision is assumed. If SOURCE is a working copy path, the corresponding URL of the path is used, and the default value of 'REV' is the base revision (usually the revision last updated to).

     TARGET_WCPATH is a working copy path; if omitted, '.' is assumed.

  

  svn merge -c50 ^/trunk

  svn merge -c50,54,60 -r65:68 ^/trunk

3. merge --reintegrate SOURCE[@REV] [TARGET_WCPATH]  (the 'reintegrate' merge)

  This form is called a 'reintegrate merge':

         svn merge --reintegrate SOURCE[@REV] [TARGET_WCPATH] 

     In a reintegrate merge, an (e.g. feature) branch is merged back to its originating branch. In other words, the source branch has originally been created by copying the target branch, development has concluded on the source branch and it should now be merged back into the target branch.

     SOURCE is the URL of a branch to be merged back. If REV is specified, it is used as the peg revision for SOURCE; if REV is not specified, the HEAD revision is assumed.

     TARGET_WCPATH is a working copy of the branch the changes will be applied to.

  

  svn merge --reintegrate ^/feature

  After the reintegrate merge, the feature branch cannot be synced to the trunk again without merge conflicts. If further work must be done on the feature branch, it should be deleted and then re-created.

 4. merge SOURCE1[@N] SOURCE2[@M] [TARGET_WCPATH]

          (the '2-URL' merge)

  This form is called a '2-URL merge':

         svn merge SOURCE1[@N] SOURCE2[@M] [TARGET_WCPATH]

     Two source URLs are specified, together with two revisions N and M. The two sources are compared at the specified revisions, and the difference is applied to TARGET_WCPATH, which is a path to a working copy of another branch. The three branches involved can be completely unrelated. 

     You should use this merge variant only if the other variants do not apply to your situation, as this variant can be quite complex to master.

  If TARGET_WCPATH is omitted, a default value of '.' is assumed.However, in the special case where both sources refer to a file node with the same basename and a similarly named file is also found within '.', the differences will be applied to that local file.  The source revisions default to HEAD if omitted.

     The sources can also be specified as working copy paths, in which case the URLs of the merge sources are derived from the working copies.

Merge Tracking】  

   - Merge Tracking -

  Subversion uses the svn:mergeinfo property to track merge history. This property is considered at the start of a merge to determine what to merge and it is updated at the conclusion of the merge to describe the merge that took place. Mergeinfo is used only if the two sources are on the same line of history -- if the first source is an ancestor of the second, or vice-versa (i.e. if one has originally been created by copying the other). This is verified and enforced when using sync merges and reintegrate merges.

  The --ignore-ancestry option prevents merge tracking and thus ignores mergeinfo, neither considering it nor recording it. 

   - Merging from foreign repositories -

  Subversion does support merging from foreign repositories. While all merge source URLs must point to the same repository, the merge target working copy may come from a different repository than the source. However, there are some caveats. Most notably, copies made in the merge source will be transformed into plain additions in the merge target. Also, merge-tracking is not supported for merges from foreign repositories.

posted on 2014-03-23 16:38  Tekkaman  阅读(3767)  评论(0编辑  收藏  举报