Kevin Deldycke - ackhttps://kevin.deldycke.com/2010-04-15T15:30:59+02:00Subversion Commands2010-04-15T15:30:59+02:002010-04-15T15:30:59+02:00Kevin Deldycketag:kevin.deldycke.com,2010-04-15:/2010/04/subversion-commands/<h2 id="native-commands">Native Commands<a class="headerlink" href="#native-commands" title="Permanent link">&para;</a></h2> <ul> <li> <p>Produce a patch file of changes commited in revision&nbsp;1377:</p> <div class="highlight"><pre><span></span>$ svn diff -r <span class="m">1376</span>:1377 &gt; diff.patch </pre></div> </li> <li> <p>Merge revision <code>3403</code> of the trunk into the &ldquo;1.0&rdquo;&nbsp;branch:</p> <div class="highlight"><pre><span></span>$ <span class="nb">cd</span> branches/1.0 $ svn merge -c3403 https://svn.example.com/my_project/trunk $ svn commit -m <span class="s2">&quot;Merge r3403 into the …</span></pre></div></li></ul><h2 id="native-commands">Native Commands<a class="headerlink" href="#native-commands" title="Permanent link">&para;</a></h2> <ul> <li> <p>Produce a patch file of changes commited in revision&nbsp;1377:</p> <div class="highlight"><pre><span></span>$ svn diff -r <span class="m">1376</span>:1377 &gt; diff.patch </pre></div> </li> <li> <p>Merge revision <code>3403</code> of the trunk into the &ldquo;1.0&rdquo;&nbsp;branch:</p> <div class="highlight"><pre><span></span>$ <span class="nb">cd</span> branches/1.0 $ svn merge -c3403 https://svn.example.com/my_project/trunk $ svn commit -m <span class="s2">&quot;Merge r3403 into the 1.0 branch.&quot;</span> </pre></div> </li> <li> <p>Revert current local folder to revision&nbsp;666:</p> <div class="highlight"><pre><span></span>$ svn merge -rHEAD:666 ./ </pre></div> </li> <li> <p>Create an empty&nbsp;repository:</p> <div class="highlight"><pre><span></span>$ svnadmin create ./my-repo </pre></div> </li> <li> <p>Dump a repository (a sure way to migrate a subversion repository from one version to&nbsp;another):</p> <div class="highlight"><pre><span></span>$ svnadmin dump ./my-repo &gt; ./my-repo.dmp </pre></div> </li> <li> <p>Migrate a remote Subversion repository without creating an intermediate dump&nbsp;file:</p> <div class="highlight"><pre><span></span>$ ssh -C user@myserver.com <span class="s2">&quot;svnadmin dump /home/user/my-repo&quot;</span> <span class="p">|</span> svnadmin load /home/user2/my-new-repo </pre></div> </li> <li> <p>Launch a standalone Subversion server listening on port 3690 and serving all repositories located in <code>./repos/</code>:</p> <div class="highlight"><pre><span></span>$ svnserve --daemon --listen-port <span class="m">3690</span> --root ./repos/ </pre></div> </li> </ul> <h2 id="local-working-copy-hacking">Local Working Copy Hacking<a class="headerlink" href="#local-working-copy-hacking" title="Permanent link">&para;</a></h2> <ul> <li> <p>Recursive and case insensitive content search on non-binary files from the current folder, while ignoring <code>.svn</code> folders and their&nbsp;content:</p> <div class="highlight"><pre><span></span>$ find ./ -type f -not -regex <span class="s2">&quot;.*\/.svn\/.*&quot;</span> -exec grep -Iil <span class="s2">&quot;string to search&quot;</span> <span class="o">{}</span> <span class="se">\;</span> </pre></div> </li> <li> <p>Same thing as above but with an alternative approach (that don&rsquo;t work with large folder&nbsp;content):</p> <div class="highlight"><pre><span></span>$ grep -Ii <span class="s2">&quot;string to search&quot;</span> <span class="k">$(</span>find . <span class="p">|</span> grep -v .svn<span class="k">)</span> </pre></div> </li> </ul> <p>Other alternative: use <a href="https://petdance.com/ack/">ack</a>.</p> <ul> <li> <p>Use <code>sed</code> to replace text in all files except in subversion&nbsp;metadatas:</p> <div class="highlight"><pre><span></span>$ find ./ -type f -not -regex <span class="s2">&quot;.*\/.svn\/.*&quot;</span> -print -exec sed -i <span class="s1">&#39;s/str1/str2/g&#39;</span> <span class="s2">&quot;{}&quot;</span> <span class="se">\;</span> </pre></div> </li> <li> <p>Use <code>svn delete</code> to remove all files containing a tilde in their name without touching local subversion&nbsp;metadatas:</p> <div class="highlight"><pre><span></span>$ find -type f -not -regex <span class="s2">&quot;.*\/.svn\/.*&quot;</span> -name <span class="s2">&quot;*˜*&quot;</span> -print -exec svn delete <span class="s2">&quot;{}&quot;</span> <span class="se">\;</span> </pre></div> </li> <li> <p>In a repository structure containing sub-projects (thinks of <a href="https://svn.plone.org/svn/collective/">Plone&rsquo;s collective repository</a> as an example), get the list of all folders in all trunks, while ignoring subversion metadata&nbsp;folders:</p> <div class="highlight"><pre><span></span>$ find ./ -type d -regex <span class="s2">&quot;.*\/trunk\/?.*&quot;</span> -not -regex <span class="s2">&quot;.*\/.svn\/?.*&quot;</span> -print </pre></div> </li> <li> <p>Similarly to the command above, replace all occurrences of the string <code>@coolcavemen.fr</code> by <code>@coolcavemen.com</code> in all <code>trunk</code> subfolders while ignoring <code>.svn</code> content:</p> <div class="highlight"><pre><span></span>$ find ./ -type f -regex <span class="s2">&quot;.*\/trunk\/.*&quot;</span> -not -regex <span class="s2">&quot;.*\/.svn\/.*&quot;</span> -print -exec sed -i <span class="s1">&#39;s/@coolcavemen\.fr/@coolcavemen\.com/g&#39;</span> <span class="s2">&quot;{}&quot;</span> <span class="se">\;</span> </pre></div> </li> <li> <p>Set a svn property to ignore all <code>.mo</code> files during commit in every folder of our local working copy containing <code>.po</code> files:</p> <div class="highlight"><pre><span></span>$ find ./ -type f -name <span class="s2">&quot;*.po&quot;</span> -regex <span class="s2">&quot;.*\/trunk\/.*&quot;</span> -not -regex <span class="s2">&quot;.*\/.svn\/.*&quot;</span> -printf <span class="s2">&quot;%h\n&quot;</span> <span class="p">|</span> uniq <span class="p">|</span> xargs svn propset <span class="s2">&quot;svn:ignore&quot;</span> <span class="s2">&quot;*.mo&quot;</span> </pre></div> </li> </ul>