<html>
<head>
    <base href="https://wiki.asterisk.org/wiki">
            <link rel="stylesheet" href="/wiki/s/en/2176/25/9/_/styles/combined.css?spaceKey=AST&amp;forWysiwyg=true" type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://wiki.asterisk.org/wiki/display/AST/Subversion+Usage">Subversion Usage</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://wiki.asterisk.org/wiki/display/~dlee">David M. Lee</a>
    </h4>
        <div id="versionComment">
        <b>Comment:</b>
        Merging is hard.<br />
    </div>
        <br/>
                         <h4>Changes (2)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >$ cd trunk <br>$ svn merge --ignore-ancestry https://origsvn.digium.com/svn/asterisk/trunk https://origsvn.digium.com/svn/asterisk/team/jdoe/bug12345 . <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;"># Check the diff to see if it merged properly <br>$ svn diff | less <br></td></tr>
            <tr><td class="diff-unchanged" >{code} <br> <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">Be sure to check the resulting diff to make sure that the merge doesn&#39;t overwrite any changes in trunk. If it does, you will have to specify the specific revisions merge needs to base its diff off of. <br> <br>{code:bash} <br># The last change to bug12345 was at r2500. <br># trunk r2400 was merged into bug12345@2500. <br>$ svn merge --ignore-ancestry https://origsvn.digium.com/svn/asterisk/trunk@2400 https://origsvn.digium.com/svn/asterisk/team/jdoe/bug12345@2500 . <br>{code} <br> <br></td></tr>
            <tr><td class="diff-unchanged" >{note} <br>This is NOT using the svnmerge script; this is just a normal SVN merge. <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        

<div>
<ul>
    <li><a href='#SubversionUsage-CommitAccess'>1. Commit Access</a></li>
<ul>
    <li><a href='#SubversionUsage-Configuration'>1.1. Configuration</a></li>
    <li><a href='#SubversionUsage-SVNCheckouts'>1.2. SVN Checkouts</a></li>
</ul>
    <li><a href='#SubversionUsage-Using%7B%7Bsvnmerge%7D%7DforCrossBranchMerging'>2. Using <tt>svnmerge</tt> for Cross-Branch Merging</a></li>
<ul>
    <li><a href='#SubversionUsage-ToolsInstallation'>2.1. Tools Installation</a></li>
    <li><a href='#SubversionUsage-%7B%7Bsvnmerge%7D%7DProperties'>2.2. <tt>svnmerge</tt> Properties</a></li>
    <li><a href='#SubversionUsage-BranchMergingOrder'>2.3. Branch Merging Order</a></li>
    <li><a href='#SubversionUsage-BackportingChanges'>2.4. Backporting Changes</a></li>
</ul>
    <li><a href='#SubversionUsage-DeveloperBranches'>3. Developer Branches</a></li>
<ul>
    <li><a href='#SubversionUsage-CreatingaDeveloperBranch'>3.1. Creating a Developer Branch</a></li>
    <li><a href='#SubversionUsage-DeletingaDeveloperBranch'>3.2. Deleting a Developer Branch</a></li>
    <li><a href='#SubversionUsage-GroupBranches'>3.3. Group Branches</a></li>
    <li><a href='#SubversionUsage-AutomaticallyKeepingBranchesUptoDateUsing%7B%7Bautomerge%7D%7D'>3.4. Automatically Keeping Branches Up to Date Using <tt>automerge</tt></a></li>
<ul>
    <li><a href='#SubversionUsage-Setting%7B%7Bautomergeemail%7D%7DonaGroupBranch'>3.4.1. Setting <tt>automerge-email</tt> on a Group Branch</a></li>
    <li><a href='#SubversionUsage-Resolving%7B%7Bautomerge%7D%7DConflicts'>3.4.2. Resolving <tt>automerge</tt> Conflicts</a></li>
</ul>
    <li><a href='#SubversionUsage-PrivateBranches'>3.5. Private Branches</a></li>
    <li><a href='#SubversionUsage-MergingaDeveloperBranchinto%7B%7Btrunk%7D%7D'>3.6. Merging a Developer Branch into <tt>trunk</tt></a></li>
</ul>
</ul></div>

<h1><a name="SubversionUsage-CommitAccess"></a>1. Commit Access</h1>

<h2><a name="SubversionUsage-Configuration"></a>1.1. Configuration</h2>

<p>The subversion server uses SSL client certificates to handle authentication of users.  When you are granted commit access, you will be provided two files.  These files should be placed in your <tt>~/.subversion/</tt> directory.</p>

<ol>
        <li><a href="http://svnview.digium.com/svn/repotools/Digium_SVN-cacert-sha1.pem" class="external-link" rel="nofollow">Digium_SVN-cacert-sha1.pem</a></li>
        <li>&lt;name&gt;-cert.p12</li>
</ol>


<p>The following should be placed in the <tt>~/.subversion/servers</tt> file:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>~/.subversion/servers</b></div><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false">[groups]
digium = *.digium.com

[digium]
ssl-client-cert-file = /home/_&lt;username&gt;_/.subversion/_&lt;name&gt;_-cert.p12

[global]
ssl-authority-files = /home/_&lt;username&gt;_/.subversion/Digium_SVN-cacert-sha1.pem</pre>
</div></div>

<p>It is also recommended that you add the following to the <tt>~/.subversion/config</tt> file.  Otherwise, the merge scripts will hang waiting for input while trying to merge between branches.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>~/.subversion/config</b></div><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false">[miscellany]
interactive-conflicts=no</pre>
</div></div>

<h2><a name="SubversionUsage-SVNCheckouts"></a>1.2. SVN Checkouts</h2>

<p>Checkouts that come from <tt><a href="http://svn.asterisk.org/" class="external-link" rel="nofollow">http://svn.asterisk.org/</a></tt> are read-only copies of the repositories.  When doing a checkout that you intend to commit to, it must be from <tt><a href="https://origsvn.digium.com/" class="external-link" rel="nofollow">https://origsvn.digium.com/</a></tt>.  For example:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: bash; gutter: false">$ svn co https://origsvn.digium.com/svn/asterisk/trunk
$ svn co https://origsvn.digium.com/svn/asterisk/branches/1.8</pre>
</div></div>

<h1><a name="SubversionUsage-Using%7B%7Bsvnmerge%7D%7DforCrossBranchMerging"></a>2. Using <tt>svnmerge</tt> for Cross-Branch Merging</h1>

<h2><a name="SubversionUsage-ToolsInstallation"></a>2.1. Tools Installation</h2>

<p>You must install <tt>svnmerge</tt> and the related wrappers from our <tt>repotools</tt> repository.  The wrapper scripts use <tt>expect</tt>, so be sure to install that, too.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: bash; gutter: false">$ svn co http://svn.asterisk.org/svn/repotools
$ cd repotools
$ ./configure
$ sudo make install</pre>
</div></div>

<h2><a name="SubversionUsage-%7B%7Bsvnmerge%7D%7DProperties"></a>2.2. <tt>svnmerge</tt> Properties</h2>

<p>If you do a <tt>svn pl -v</tt> while you are located in an svn checkout, you will see all the properties currently attached to the root directory. For instance, on a checked out copy of Asterisk trunk, you will see something like this:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>  branch-1.8-blocked
    /branches/1.8:
  branch-1.8-merged
    /branches/1.8:1-279056,279113,279227,279273,279280,...............,286457
</pre>
</div></div>

<p>and on the 1.8 branch, you will see these sort of properties:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>  branch-1.6.2-blocked
    /branches/1.6.2:279852,279883,280227,280556,280812,282668
  branch-1.6.2-merged
    /branches/1.6.2:1-279056,279207,279501,279561,279597,279609,....................,286268
</pre>
</div></div>

<p>These properties identify the following things:</p>
<ol>
        <li>The branch changes are being merged from
        <ul>
                <li><tt>branch-&lt;branch&gt;-...</tt></li>
        </ul>
        </li>
        <li>The revisions merged from that branch
        <ul>
                <li><tt>branch-&lt;branch&gt;-merged:/branches/&lt;branch&gt;:&lt;revisions&gt;</tt></li>
        </ul>
        </li>
        <li>The revision explicitly not merged, or blocked, from that branch
        <ul>
                <li><tt>branch-&lt;branch&gt;-blocked:/branches/&lt;branch&gt;:&lt;revisions&gt;</tt></li>
        </ul>
        </li>
</ol>


<h2><a name="SubversionUsage-BranchMergingOrder"></a>2.3. Branch Merging Order</h2>

<p>When committing a change that applies to more than one branch, the change should first go into the oldest branch and will then be merged up to the next one.  If a branch is reached where the change should not be merged up, it should be explicitly blocked.  The following diagram shows the current branch merge order.</p>

<p>The column on the right describes the scripts you will use to merge between versions or block specific versions from merging.</p>

<table class="sectionMacro" border="0" cellpadding="5" cellspacing="0" width="100%"><tbody><tr>
<td class="confluenceTd" valign="top" width="25%">
<img src='/wiki/download/temp/graphviz2047252666559682757.png?contentType=image/png&delete=true'/></td>
<td class="confluenceTd" valign="top" width="75%">
<ul>
        <li>1.8 -&gt; 11
        <ul>
                <li><tt>merge811 <em>&lt;revision&gt;</em></tt></li>
                <li><tt>block811 <em>&lt;revision&gt;</em></tt></li>
        </ul>
        </li>
</ul>


<ul>
        <li>11 -&gt; trunk
        <ul>
                <li><tt>merge11trunk <em>&lt;revision&gt;</em></tt></li>
                <li><tt>block11trunk <em>&lt;revision&gt;</em></tt></li>
        </ul>
        </li>
</ul>


<p>The &lt;revision&gt; number passed to each script should be the revision resulting from the commit to an older branch. The script would be run from the checkout directory for the Asterisk version you are merging <b>to</b>.</p>

<p>For example if you have committed a change to 11 and that needs to be merged through to trunk, the commands would look similar to the following:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>/svn-asterisk-11$ svn commit -F ../commit_msg
Sending        apps/app_voicemail.c
Transmitting file data .
Committed revision 376262.
/svn-asterisk-11$ cd ../svn-asterisk-trunk
/svn-asterisk-trunk$ merge11trunk 376262
</pre>
</div></div>

<p>Then you would proceed with committing the merged changes.</p>

<div class='panelMacro'><table class='tipMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/wiki/images/icons/emoticons/check.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>All of these scripts create a commit message for you in the file <tt>../merge.msg</tt>.  Run "<tt>svn commit</tt>" and use that commit message with the following command:
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: bash; gutter: false">$ svn commit -F ../merge.msg</pre>
</div></div></td></tr></table></div>

<div class='panelMacro'><table class='tipMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/wiki/images/icons/emoticons/check.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>Sometimes when you go to commit your changes after merging from another branch, you will end up with a conflict. The conflict will typically be against <tt>.</tt> (period). To resolve the conflict, run "<tt>svn resolved .</tt>" prior to committing.</td></tr></table></div>
</td></tr></tbody></table>

<h2><a name="SubversionUsage-BackportingChanges"></a>2.4. Backporting Changes</h2>

<p>Sometimes a change is made in a branch and later it is decided that it should be backported to an older branch.  For example, a change may have gone into the 11 branch and later needs to be backported to the 1.8 branch.  To handle this, first manually make the change and commit to the 1.8 branch.  Then, there is another wrapper similar to <tt>merge811</tt> and <tt>block811</tt> to record that the code from a revision already exists in the 11 branch.  The wrapper is <tt>record811</tt>.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: bash; gutter: false">$ cd 11
$ record811 &lt;revision&gt;
$ svn commit -F ../merge.msg</pre>
</div></div>

<h1><a name="SubversionUsage-DeveloperBranches"></a>3. Developer Branches</h1>

<div class='panelMacro'><table class='infoMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/wiki/images/icons/emoticons/information.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>If you have been granted workspace on the server, you will have read and <a href="https://issues.asterisk.org/" class="external-link" rel="nofollow">electronically signed the Open Source Contributor License</a> found at <a href="https://issues.asterisk.org" class="external-link" rel="nofollow">https://issues.asterisk.org</a> (upon signing in) and have been given an SSL client certificate.</td></tr></table></div>

<p>Developer branches are stored in the <tt>/team/&lt;name&gt;</tt> directory of each project repository (and <tt>/team/&lt;name&gt;/private</tt> for private branches). </p>

<h2><a name="SubversionUsage-CreatingaDeveloperBranch"></a>3.1. Creating a Developer Branch</h2>

<p>Use the following commands to create a branch and prepare it for future merge tracking of the branch you created it from.  This example creates a branch off of Asterisk trunk.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: bash; gutter: false">$ svn copy https://origsvn.digium.com/svn/asterisk/trunk https://origsvn.digium.com/svn/asterisk/team/jdoe/my-fun-branch
$ svn checkout https://origsvn.digium.com/svn/asterisk/team/jdoe/my-fun-branch
$ cd my-fun-branch
$ svnmerge init
$ svn commit -F svnmerge-commit-message.txt</pre>
</div></div>

<h2><a name="SubversionUsage-DeletingaDeveloperBranch"></a>3.2. Deleting a Developer Branch</h2>

<p>To delete a developer branch after you are done with it use the SVN command shown below for your branch name.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: bash; gutter: false">$ svn delete https://origsvn.digium.com/svn/asterisk/team/jdoe/my-fun-branch</pre>
</div></div>

<h2><a name="SubversionUsage-GroupBranches"></a>3.3. Group Branches</h2>

<p>Group branches are developer branches intended to be worked on by more than one developer.  Instead of putting them in <tt>/team/&lt;name&gt;</tt>, they go in the <tt>/team/group</tt> directory, instead.  Otherwise, they're managed in the exact same way as other developer branches.</p>

<h2><a name="SubversionUsage-AutomaticallyKeepingBranchesUptoDateUsing%7B%7Bautomerge%7D%7D"></a>3.4. Automatically Keeping Branches Up to Date Using <tt>automerge</tt></h2>

<p>Our subversion server provides the ability to automatically keep developer branches up to date with their parent.  To enable this feature, set the <tt>automerge</tt> and <tt>automerge-email</tt> properties on the root directory.  Changes from the parent branch will be periodically (once an hour) merged into your branch.  If a change from upstream conflicts with changes in the branch, the <tt>automerge</tt> process will stop and the address(es) listed in the <tt>automerge-email</tt> property will be notified.</p>

<div class='panelMacro'><table class='noteMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/wiki/images/icons/emoticons/warning.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>Running <tt>svnmerge init</tt> and committing those properties is a prerequisite for <tt>automerge</tt> to work for a developer branch.</td></tr></table></div> 

<p>Use the following commands to enable automerge on a developer branch:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: bash; gutter: false">$ cd my-fun-branch
$ svn ps automerge '*' .
$ svn ps automerge-email 'me@example.com' .
$ svn commit -m "initialize automerge"</pre>
</div></div>

<h3><a name="SubversionUsage-Setting%7B%7Bautomergeemail%7D%7DonaGroupBranch"></a>3.4.1. Setting <tt>automerge-email</tt> on a Group Branch</h3>

<p>For a branch with multiple developers working on it, it may be useful to have automerge emails sent to more than one email address.  To do so, just separate the email addresses in the property with commas.  The value of this property is literally used as the content for the <tt>To:</tt> header of the email.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: bash; gutter: false">$ svn ps automerge-email 'me@example.com,you@example.com,him@example.com' .</pre>
</div></div>

<h3><a name="SubversionUsage-Resolving%7B%7Bautomerge%7D%7DConflicts"></a>3.4.2. Resolving <tt>automerge</tt> Conflicts</h3>

<p>If your developer branch goes into conflict with <tt>automerge</tt> on, and the <tt>automerge-email</tt> property has been set, you will receive an email notifying you of the conflict and <tt>automerge</tt> will be disabled.  To resolve it, use the following commands:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: bash; gutter: false">$ cd my-branch
$ svn update
$ svnmerge merge</pre>
</div></div>

<p>Running the <tt>svnmerge</tt> tool will merge in the changes that cause your branch to go into conflict into your local copy.  Edit the files that are in conflict to resolve the problems as appropriate.  Finally, tell SVN that you have resolved the problem, re-enable automerge, and commit.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: bash; gutter: false">$ svn resolved path/to/conflicted/file
$ svn ps automerge '*' .
$ svn commit -m "resolve conflict, enable automerge"</pre>
</div></div>

<h2><a name="SubversionUsage-PrivateBranches"></a>3.5. Private Branches</h2>

<p>A private developer branch is only visible to Digium and the branch owner.  Management of a private branch is exactly the same as any other developer branch.  The only difference is branch location.  Instead of putting the branch in <tt>/team/&lt;name&gt;/</tt> the branch goes in <tt>/team/&lt;name&gt;/private/</tt>.</p>

<h2><a name="SubversionUsage-MergingaDeveloperBranchinto%7B%7Btrunk%7D%7D"></a>3.6. Merging a Developer Branch into <tt>trunk</tt></h2>

<div class='panelMacro'><table class='infoMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/wiki/images/icons/emoticons/information.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>If your branch contains new functionality, please make sure you have made the appropriate modifications to <tt>CHANGES</tt> and/or <tt>UPGRADE.txt</tt>.</td></tr></table></div>

<p>If a developer has a branch that is ready to be merged back into the trunk, here is the process:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: bash; gutter: false">$ svn co https://origsvn.digium.com/svn/asterisk/trunk
$ cd trunk
$ svn merge --ignore-ancestry https://origsvn.digium.com/svn/asterisk/trunk https://origsvn.digium.com/svn/asterisk/team/jdoe/bug12345 .
# Check the diff to see if it merged properly
$ svn diff | less</pre>
</div></div>

<p>Be sure to check the resulting diff to make sure that the merge doesn't overwrite any changes in trunk. If it does, you will have to specify the specific revisions merge needs to base its diff off of.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: bash; gutter: false"># The last change to bug12345 was at r2500.
# trunk r2400 was merged into bug12345@2500.
$ svn merge --ignore-ancestry https://origsvn.digium.com/svn/asterisk/trunk@2400 https://origsvn.digium.com/svn/asterisk/team/jdoe/bug12345@2500 .</pre>
</div></div>

<div class='panelMacro'><table class='noteMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/wiki/images/icons/emoticons/warning.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>This is NOT using the svnmerge script; this is just a normal SVN merge.</td></tr></table></div>

<p>Once this is done, the working copy will contain the trunk plus the changes from the developer branch.  If you follow the above instructions for creating branches, you have probably introduced  properties to the root of the branch that need to be removed.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: bash; gutter: false">$ svn revert .</pre>
</div></div>

<p>If you are purposely introducing new properties, or  purposely introducing new values for existing properties, then you might do the following instead, so as not to destroy your properties:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: bash; gutter: false">$ svn pd svnmerge-integrated .
$ svn pd automerge .
$ svn pd automerge-email .</pre>
</div></div>

<p>If everything merged cleanly, you can test compile and then:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: bash; gutter: false">$ svn commit -m "Merge branch for issue 12345"</pre>
</div></div>

<p>Once the contents of your branch has been merged, please use <tt>svn remove</tt> to remove it from the repository.  It will still be accessible if needed by looking back in the repository history if needed.</p>

    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;" class="grey">
                        <a href="https://wiki.asterisk.org/wiki/users/removespacenotification.action?spaceKey=AST">Stop watching space</a>
            <span style="padding: 0px 5px;">|</span>
                <a href="https://wiki.asterisk.org/wiki/users/editmyemailsettings.action">Change email notification preferences</a>
</div>
        <a href="https://wiki.asterisk.org/wiki/display/AST/Subversion+Usage">View Online</a>
        |
        <a href="https://wiki.asterisk.org/wiki/pages/diffpagesbyversion.action?pageId=5243336&revisedVersion=52&originalVersion=51">View Changes</a>
                |
        <a href="https://wiki.asterisk.org/wiki/display/AST/Subversion+Usage?showComments=true&amp;showCommentArea=true#addcomment">Add Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>