<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Kanru&#039;s 探險日誌 &#187; svn</title>
	<atom:link href="http://blog.kanru.info/archives/tag/svn/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.kanru.info</link>
	<description>當發現美好的事物時，所要做的第一件事，就是把它分享給所有人</description>
	<lastBuildDate>Sun, 23 May 2010 09:51:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>使用 git-svn 整合 git 與 svn</title>
		<link>http://blog.kanru.info/archives/466</link>
		<comments>http://blog.kanru.info/archives/466#comments</comments>
		<pubDate>Sun, 23 Nov 2008 10:03:18 +0000</pubDate>
		<dc:creator>kanru</dc:creator>
				<category><![CDATA[小工具]]></category>
		<category><![CDATA[爬網探險]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://blog.kanru.info/?p=466</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p>git 是目前最紅的分散式 VCS 之一，我很喜歡用 git 因為他預設就有許多方便的特性如：</p>

<ul>
<li>git log/diff/help 都有彩色的 pager 可用，不用再自己 pipe 到 less</li>
<li>git log 的格式一目了然，清晰易懂</li>
<li>git bisect/format-patch/shortlog/stash&#8230; 等趁手工具一堆</li>
<li>速度快</li>
</ul>

<p>而 git 不僅僅是 git，他分成高階的命令如 pull/commit 等，還有低階的命令可以直接操作 ref/object，因此有一些 VCS 就是建立在 git 的檔案系統上，運作起來跟 git 截然不同。</p>

<p>git-svn 是一個可以把 svn 當 git 用的工具，就算專案還在用 svn 也可以享受到 git 的便利。以下簡介一下 git-svn 的使用流程。</p>

<p>首先創造一個實驗用的 svn repository：</p>

<p><pre lang="shell">
bob % cd /tmp/test
bob % svnadmin create hello
bob % svn co file:///tmp/test/hello hello-svn
bob % cd hello-svn
bob % svn mkdir branches tags trunk
bob % svn ci -m'Initial dir setup'
</pre></p>

<p>現在我們有一個傳統的 svn repository 了，加點東西進去吧：</p>

<p><pre lang="shell">
bob % cd trunk
bob % echo "printf("hello\n");" > hello.c
bob % svn add hello.c
bob % svn ci -m'My first program <img src='http://blog.kanru.info/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> '
bob % cd ..
bob % svn cp trunk tags/v0.1
bob % svn ci -m'tag v0.1'
</pre></p>

<p>這時候 Bob 已經建好他的程式 v0.1 版，Alice 知道了他的計劃也想加入，於是她用 git-svn 來取出 repository</p>

<p><pre lang="shell">
alice % git svn clone --stdlayout file:///tmp/test/hello hello-git
Initialized empty Git repository in /tmp/test/hello-git/.git/
r1 = 80a0fc18653e8bc7d3784567b1b7024b20fd8c11 (trunk)
    A   hello.c
r2 = 4a80acebb6a41c208f3427498225f829950ee39e (trunk)
Found possible branch point: file:///tmp/test/hello/trunk => file:///tmp/test/hello/tags/v0.1, 1
Found branch parent: (tags/v0.1) 80a0fc18653e8bc7d3784567b1b7024b20fd8c11
Following parent with do_switch
    A   hello.c
Successfully followed parent
r3 = 24ca9410e9ca78ffa3bffa1c9ef574068d128935 (tags/v0.1)
Checked out HEAD:
  file:///tmp/test/hello/tags/v0.1 r3
alice % git reset --hard remotes/trunk
</pre></p>

<p>因為是使用 stdlayout，所以 tag/branch 等會自動對應到 remote branch</p>

<p><pre lang="shell">
alice % cd hello-git
alice % git branch -r
  tags/v0.1
  trunk
</pre></p>

<p>Alice 發現 Bob 原本的程式無法 compile，因此開始修改，改完之後用 <code>git add -p</code> 挑選要 commit 的部份，然後把剩下的部份 stash 起來，最後用 <code>git svn dcommit</code> 提交給 Bob 的 svn repository</p>

<p><pre lang="shell">
alice % edit hello.c
alice % git add -p
alice % git commit -m'Fix everything'
alice % git stash
alice % git svn dcommit
</pre></p>

<p>隔了幾天，Alice 發現 Bob 有更新，因此開始做同步。同時，因為她有一個 local branch，所以在更新完 master 之後，還需要把 fancy branch 跟 master rebase。</p>

<p><pre lang="shell">
alice % git svn fetch
    M   hello.c
r6 = c43134a98f43dc6507deaa7495bfcd2c906aaa30 (trunk)
alice % git svn rebase
First, rewinding head to replay your work on top of it...
Fast-forwarded master to refs/remotes/trunk.
alice % git checkout fancy
alice % git rebase master
First, rewinding head to replay your work on top of it...
Applying: Inital fancy output branch
</pre></p>

<p>以上就是使用 git-svn 時會用到的大部分指令，其餘的就跟操作一般 git 一樣。</p>

<p>各命令的詳細說明可以參考 <a href="http://www.kernel.org/pub/software/scm/git/docs/git-svn.html">git-svn(1)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kanru.info/archives/466/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Display VCS info in prompts</title>
		<link>http://blog.kanru.info/archives/343</link>
		<comments>http://blog.kanru.info/archives/343#comments</comments>
		<pubDate>Sat, 04 Oct 2008 11:58:58 +0000</pubDate>
		<dc:creator>kanru</dc:creator>
				<category><![CDATA[小工具]]></category>
		<category><![CDATA[爬網探險]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[vcs]]></category>
		<category><![CDATA[zsh]]></category>

		<guid isPermaLink="false">http://blog.kanru.info/?p=343</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p>通常 VCS (Version Control System) 都會在工作目錄底下藏一些特殊目錄用來儲存資訊，如 .svn .git .hg 等，因此我們可以在 shell prompt 上動一些手腳，當我們進到 VCS 工作目錄時，自動顯示相關的訊息在 prompt 上。</p>

<p>而 zsh-beta 4.3.6-dev-0+20080921-1 內建了由 Frank Terbeck 開發的 vcs_info 子系統，可以自動偵測 bzr, cdv, CVS, darcs, git, hg, mtn, p4, svk, svn, tla 等多種 VCS，並設定相關的環境變數可以顯示在 prompt 上。</p>

<p><img src="http://people.debian.org.tw/~koster/blog/2008-09-22-200437_506x113_scrot.png" alt="zsh prompt"/></p>

<p>我的 prompt 設定如下</p>

<p><pre lang="plain">
    autoload -Uz vcs_info &amp;&amp; vcs_info
    zstyle ':vcs_info:<em>' actionformats \
    '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{3}|%F{1}%a%F{5}]%f '
    zstyle ':vcs_info:</em>' formats       \
    '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{5}]%f '
    zstyle ':vcs_info:(sv[nk]|bzr):<em>' branchformat '%b%F{1}:%F{3}%r'
    precmd () { vcs_info }
    EXITCODE="%(?..%?%1v )"
    JOBS="%(1j.%j .)"
    local BLUE="%{^[[1;34m%}"
    local RED="%{^[[1;31m%}"
    local GREEN="%{^[[1;32m%}"
    local CYAN="%{^[[1;36m%}"
    local YELLOW="%{^[[1;33m%}"
    local NO_COLOUR="%{^[[0m%}"
    PROMPT="${RED}${EXITCODE}${CYAN}${JOBS}${YELLOW}%</em> ${RED}%n${BLUE}@%m:${GREEN}%40&lt;...< %B%~%b%&lt;&lt;"'${vcs_info_msg_0_}'"
    ${YELLOW}%# ${NO_COLOUR}"
</pre></pre></p>

<p>詳細的設定請參閱 zshcontrib(3) GATHERING INFORMATION FROM VERSION CONTROL SYSTEMS</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kanru.info/archives/343/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>AnkhSVN 結合 Visual Studio 與 Subversion</title>
		<link>http://blog.kanru.info/archives/297</link>
		<comments>http://blog.kanru.info/archives/297#comments</comments>
		<pubDate>Sat, 31 May 2008 14:34:28 +0000</pubDate>
		<dc:creator>kanru</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[小工具]]></category>
		<category><![CDATA[爬網探險]]></category>
		<category><![CDATA[ankhsvn]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[tortoisesvn]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://blog.kanru.info/?p=297</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p>最近很多時間都是待在 Visual Studio 的環境下寫程式，而 VCS 則是使用 Windows 下很方便的 <a href="http://tortoisesvn.tigris.org/">TortoiseSVN</a>。對於已經習慣在編輯器裡面修改程式，告一段落後到檔案總管(或是 shell)把修改提交到伺服器上的我來說，使用 TortoiseSVN 算是很習慣了。但是對於第一次接觸 VCS 的同學，可能會忘記要提交修改、要寫 Changelog、開始新的修改前要先 update 等。</p>

<p>而 <a href="http://ankhsvn.open.collab.net/">AnkhSVN</a> 則提供了一個與 Visual Studio 整合的方案，1.x 版的 AnkhSVN 可以由 VS 內執行 VCS 的命令，而開發中的 2.x 則實做了 Source Control Provider 的介面，與 VS 的環境更緊密的結合，可以完全取代預設的 Sourcesafe 方案，使用上應該與商業化的 Visual SVN 類似，可以直接 checkout 專案、看 changelog、看 diff 等。</p>

<p><a href="http://www.flickr.com/photos/kanru/2538089627/" title="solution by Kanru Chen, on Flickr"><img src="http://farm3.static.flickr.com/2224/2538089627_549c5a285e_o.png" width="337" height="270" alt="solution" /></a></p>

<p>測試的時候的小插曲：因為 2.x 是 &#8220;stable, but unfinished&#8221;，只有提供 nightly build，但是我抓下來的安裝檔都沒辦法在 VS 2005 上面正常執行，後來直接到 #ankhsvn 求救，也很快獲得回應，原來是因為不小心參考到 2008 才有的介面，修正之後，最新的 snapshot 已經可以正常使用 <img src='http://blog.kanru.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

<p>不過要注意的是，2.x 用的是最新版的 svn，所以 working copy 的 format 是第 9 版，而最新的 TortoiseSVN 的 1.4.x release 用的是第 8 版，會沒辦法共同使用，要把 TortoiseSVN 更新到開發中的 1.5 才能讓 working copy 相容。如果沒辦法接受使用兩個開發中軟體的話，還是可以用最新的 release 版本，還是很好用的 :p</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kanru.info/archives/297/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
