TortoiseSVN 平常操做指南

TortoiseSVNhtml

A Subversion client for Windowsjava

Stefan Küngnode

Lübbe Onkenshell

Simon Largewindows

2005/01/17 19:09:21瀏覽器

二〇〇五年四月 Daan譯服務器

 

Table of Contents網絡

Chapter 4.  平常操做指南... 4 架構

4.1. 使用 TortoiseSVN.. 4 app

4.2. 認證... 5

4.3. 導入數據到倉庫Importing Data Into A Repository. 5

4.3.1. 倉庫規劃Repository Layout 5

4.3.2. 導入Import 7

4.3.3. 特殊文件Special Files. 8

4.3.4. 參考項目Referenced Projects. 9

4.4. 取出工做副本Checking Out A Working Copy. 9

4.5. 獲取狀態信息Getting Status Information. 10

4.5.1. 覆蓋圖標Icon Overlays. 10

4.5.2. 資源管理器中TortoiseSVN的專欄... 12

4.5.3. 倉庫狀態Status Of The Repository. 12

4.5.4. 查看區別Viewing Diffs. 13

4.6. 更新工做副本Update Your Working Copy With Changes From Others. 13

4.7. 解決衝突Resolving Conflicts. 16

4.8. 把你的修改發送到倉庫Sending Your Changes To The Repository. 16

4.9. 獲取(修改)文件(目錄)信息Get/Set Information About Files/Directories. 19

4.10. 整合Bug跟蹤系統Integration with Bugtracking Systems. 21

4.11. 加入新文件和新目錄Adding New Files And Directories. 22

4.12. 忽略文件和目錄Ignoring Files And Directories. 23

4.13. 刪除、重命名、移動Deleting, Renaming And Moving. 24

4.14. 取消改變Undo Changes. 25

4.15. 修訂日誌窗口Revision Log Dialog. 26

4.15.1. 調用日誌窗口Invoking The Log Dialog. 26

4.15.2. 獲取附加信息Getting Additional Information. 27

4.15.3. 獲取全部日誌Getting all log messages. 29

4.15.4. 修改日誌內容和做者Changing the log message and author 29

4.15.5. 統計信息Statistical Information. 29

4.16. 分支/標記Branching / Tagging. 30

4.16.1. 建立分支或標記Creating a Branch or Tag. 30

4.16.2. 取出仍是切換?To Checkout or to Switch... 31

4.17. 合併Merging. 32

4.17.1. Merging a Range of Revisions. 32

4.17.2. Merging Two Different Trees. 34

4.18. 建立和應用補丁Creating and Applying Patches. 35

4.18.1. 建立補丁Creating a Patch File. 35

4.18.2. 應用補丁Applying a Patch File. 35

4.19. 副本重定位Relocating a working copy. 36

4.20. 倉庫瀏覽器The Repository Browser 36

4.21. TSVN的設置TortoiseSVN's Settings. 37

4.21.1. 通常設置... 37

4.21.2. 外觀感覺設置... 40

4.21.3. 網絡設置... 41

4.21.4. 比較/合併設置... 42

4.22. 誰動了哪一行?Who Changed Which Line?. 45

4.23. 版本路線圖Revision Graphs. 46

4.24. 最後Final Step. 48


Chapter 4.  平常操做指南

Table of Contents

這份文檔描述TortoiseSVN的平常用法。注意這裏不介紹CVS或者Subversion。

若是你須要一份Subversion的版本控制介紹,咱們推薦您閱讀Subversion: The Definitive Guide

這份文檔像TortoiseSVN和Subversion同樣,也一直在改進之中。若是發現任何錯誤,請在郵件列表中告訴咱們,以便咱們更新這份文檔。請原諒,下面的一些貼圖可能不是最新軟件版本的貼圖,由於咱們都是在工做之餘來維護的。

4.1. 使用 TortoiseSVN

圖1:在版本控制下的目錄菜單

全部TortoiseSVN命令都集成在Windows的資源管理器的菜單中。當你在一個文件或文件夾單擊鼠標右鍵時,大多數命令都會直接顯示出來。哪些菜單顯示出來,依賴於文件或文件夾是否處於版本控制之下。

在工做副本目錄中,當你用鼠標右鍵拖拽文件或文件夾到一個新目錄,或者把沒有在版本控制下的文件或文件夾拖拽到版本控制下的目錄中,就會顯示另一些命令在右鍵菜單中。

4.2. 認證

假如你試圖訪問一個有密碼保護的倉庫,一個認證對話框會跳出來。

圖2:認證對話框

輸入你的用戶名和密碼。那個複選框可讓TortoiseSVN保存認證信息在Subversion的默認目錄中:$APPDATA\Subversion\auth。

若是你想讓Subversion和TortoiseSVN忘記你的認證信息,你必須刪除相關的文件。

重要信息:

在Windows2000及其以上的系統中,認證信息被加密保存在註冊表中。要刪除認證信息,請選擇settings對話框,而且點擊Clear Auth Cache按鈕。

提示:

若是你是使用WindowsNT域的認證方式,那麼在輸入用戶名時要包括域名,好比:MYDOMAIN/johnd

4.3. 導入數據到倉庫Importing Data Into A Repository

4.3.1. 倉庫規劃Repository Layout

在將數據導入到倉庫以前,你必須先想好如何組織存放你的數據。若是你使用一種咱們推薦的規劃方式,你將在之後的使用中感受到很舒服。

咱們這裏有不少種標準的推薦倉庫組織形式。大多數人會建立一個trunk目錄來存放開發的「主線」,一個branches目錄來存放支線副本,另外還有一個tags目錄來存放標籤副本。假如一個倉庫只保存一個項目,常常會建立這樣的幾個頂級目錄:

/trunk

/branches

/tags

若是一個倉庫存放多個項目,常常會像下面這樣根據分支來規劃:

/trunk/paint

/trunk/calc

/branches/paint

/branches/calc

/tags/paint

/tags/calc

...或者根據項目分紅多個目錄:

/paint/trunk

/paint/branches

/paint/tags

/calc/trunk

/calc/branches

/calc/tags

若是多個項目之間的關係不是很緊密,而且他們都是被單獨取出的,那根據項目來規劃會比較有意義些。For related projects where you may want to check out all projects in one go, or where the projects are all tied together in a single distribution package, it is often better to index by branch. This way you have only one trunk to checkout, and the relationships between the sub-projects is more easily visible.對那些相關的項目(),最好根據分支來組織規劃。這樣的話,你就只有一個trunk須要checkout,並且子項目間的關係會更明顯。

你若是採用/trunk /tags /branches並列於根目錄的方式,那你必須爲每一個branch和tag複製整個trunk,也就是說這種結構顯得更機動些。

對不相干的項目來講,你可使用多個不一樣的倉庫。當你提交一個改動,版本號會是整個倉庫的版本號,而不是項目的版本號。2個不相干的項目共享一個倉庫會在版本號方面致使極大的不方便。Subversion和TortoiseSVN的項目看起來好像在同一個地址,但事實上他們在徹底不一樣的倉庫中研發着,而且在版本號方面徹底的不相干。

固然,你能夠無論上面提到的這些形式。你能夠隨意發揮以知足你或者你的團隊的須要。記住無論你怎麼選擇,那都不會是一個永久的形式,你能夠在任什麼時候候從新組織你的倉庫。由於branches和tags都是很普通的目錄,只要你願意,TortoiseSVN能夠隨時移動它們,或更名。

從一種形式轉換到另外一種形式僅僅須要在服務器端作一些文件或目錄移動操做;若是你不喜歡你倉庫的某種組織形式,儘管大膽的操做那些目錄。

到這裏,若是你尚未在你的倉庫中建立一個基本的目錄架構,接下來你應該這麼作:

1.       在你的硬盤中建立一個空目錄。

2.       在這個目錄中建立一個你中意的目錄組織形式。注意如今不要聽任何文件進去。

3.       接下來把這個結構導入倉庫。在新建的那個目錄上單擊鼠標右鍵,選擇Import…。這樣,就把你剛纔建立的臨時目錄導入到倉庫的根目錄了,並建立了倉庫的基本架構。

注意:你導入的這個目錄的目錄名是不該該出如今倉庫中的,應該只有目錄中的內容會出現。好比,建立下面的目錄結構:

C:\Temp\New\trunk

C:\Temp\New\branches

C:\Temp\New\tags

C:\Temp\New 導入到倉庫的根目錄,那麼根目錄看起來應該是這樣的:

/trunk

/branches

/tags

另外你也可使用倉庫瀏覽器(repository browser)直接在倉庫中建立新目錄。

4.3.2. Import

在把你的項目導入到倉庫以前,下面的工做必須作好:

1.       把項目中不須要的文件刪除。(臨時文件、編譯器建立的文件,好比*.obj、2進制文件等。)

2.       把目錄和子目錄中的全部文件整理一遍。雖然你能夠在導入以後再來進行重命名或刪除等操做,可是仍是推薦你在導入以前把你的項目整理好。

如今,在資源管理器(windows explorer)中選擇項目的根目錄,單擊鼠標右鍵,選擇Import…命令,跳出一個對話框:

在這個對話框中你須要填寫你要將項目導入倉庫的URL地址。

那個Important Message是用來記錄日誌信息的。

重要信息:

和exclude pattern匹配的文件或文件夾不會被導入。

當你按下OK按鈕,TortoiseSVN就開始把整個目錄樹包括全部文件導入到倉庫了。和前面講到的同樣,這個目錄的名字不會出如今倉庫中,只有目錄中的內容會出現。如今,你的這個項目就處於版本控制之下了。請注意,你剛纔導入的這個目錄(在你本地硬盤上的這個)並無處於版本控制下!要獲取一份處於版本控制之下的工做副本,你須要對剛導入的版本作一次取出(Checkout)操做。

4.3.3. Special Files

有時候你須要版本控制一個存儲着用戶個性信息的文件。也就是說這個文件每一個開發者或用戶都會去修改以適應他本地的設置。但每一個用戶在進行提交(commit)操做時都會把這個文件的修改提交給倉庫,這就使得版本控制這樣一個文件很困難。

在這種境況下,建議使用模版文件。你能夠建立一個包含開發人員須要的全部數據的文件,把它添加到版本控制之下,而後讓開發人員取出這份文件。接下來,每一個開發人員就能夠給這個文件作個備份,而後給他改個名字。這樣操做以後,無論怎麼修改這個備份都再也不是什麼問題了。

As an example, you can have a look at TortoiseSVN's build script. It calls a file named TortoiseVars.bat which doesn't exist in the repository. Only the file TortoiseVars.tmpl. TortoiseVars.tmpl is the template file which every developer has to create a copy from and rename that file to TortoiseVars.bat. Inside that file, we added comments so that the users will see which lines they have to edit and change according to their local setup to get it working.

So as not to disturb the users, we also added the file TortoiseVars.bat to the ignore list of its parent folder, i.e. we've set the Subversion property svn:ignored to include that filename. That way it won't show up as unversioned on every commit.

4.3.4. Referenced Projects

Sometimes it is useful to construct a working copy that is made out of a number of different checkouts. For example, you may want different subdirectories to come from different locations in a repository, or perhaps from different repositories altogether. If you want every user to have the same layout, you can define the svn:externals properties.

Let's say you check out a working copy of /project1 to D:\dev\project1. Select the folder D:\dev\project1, right click and choose properties from the context menu. The Properties Dialog comes up. Then go to the Subversion tab. There, you can set properties. Select the svn:externals property from the combobox and write in the edit box the repository url in the format name url. For example

subversion http://svn.collab.net/repos/svn/trunk

Now click Set and commit your changes. If a user updates their working copy the external project is checked out, too.

If you need more information how TortoiseSVN handles Properties read Section 4.9, 「Get/Set Information About Files/Directories」.

4.4. 取出工做副本Checking Out A Working Copy

爲了獲取一個工做副本,你必須從倉庫中作一次取出(checkout)操做。

在資源管理器中選擇一個你想要存放工做副本的目錄。單擊鼠標右鍵跳出菜單,選擇命令Checkout…,再跳出一個窗口:

若是你輸入一個不存在的目錄名,那這個目錄會自動建立。

重要信息

你只能取出到一個空目錄。假如你想要取出到先前導入的原始目錄,Subversion會拋出一個錯誤。你必須取出到另外的一個目錄或者先把原始目錄刪掉。

強烈建議您僅取出trunk部分。假如你堅持要取出父目錄,那你有可能就會把你的硬盤塞滿,由於你將獲得整個倉庫的數據(包括項目的每個branch和tag)。

導出Exporting

有時候你也許須要一份沒有那些.svn目錄的工做副本,好比要建一個源代碼zip壓縮包。TortoiseSVN提供一個導出命令 Export…,能夠免除咱們本身動手來操做(作一個副本,而後手動刪除全部.svn目錄)。若是你在工做副本中執行這個命令,你能夠選擇一個目錄用來存放沒有.svn目錄的乾淨工做副本。一樣,你也能夠指定是導出全部文件仍是那些被版本控制的文件。

導出的另外一種方法是,用鼠標右鍵拖拽一個工做目錄到其餘地方,而後選擇Subversion export here 或者 Subversion export all here

4.5. 獲取狀態信息Getting Status Information

當你在你的工做副本中工做的時候,你常常會須要知道哪些文件被修改過,哪些被增長,哪些被重命名,或者哪些文件是其餘人修改和提交的。

4.5.1. 覆蓋圖標Icon Overlays

圖4.5 覆蓋圖標

在從倉庫中取出工做副本以後,你會發現資源管理器中文件的圖標發生了變化。這就是TortoiseSVN受歡迎的一個緣由。TortoiseSVN爲每一個文件圖標在原來的基礎上增長了一個叫作覆蓋圖標的東東。覆蓋圖標根據Subversion狀態的不一樣而顯示不一樣的圖標。

*

綠色圖標表示這是一個最新取出的工做副本,他的Subversion狀態是normal

*

當你開始編輯一個文件,這個文件的狀態就會變成modified,圖標也會變成紅色圓圈帶一個感嘆號。這樣你就能夠輕易的知道自從上次更新以來都有修改過哪些文件,須要提交哪些文件。

*

這個黃色三角符號帶感嘆號,表示在一次update中產生了一個衝突(conflict)。

*

藍色加號意味着這個文件或文件夾已經被計劃加入到版本控制之下。

紅叉叉表示相應文件或文件夾被計劃刪除(deleted),或者表示文件缺失。

文件夾也有這樣的覆蓋圖標顯示。默認狀況下只會顯示文件夾本身的狀態。但你也能夠在Settings(4.21節,「TortoiseSVN的Settings」)中作一些設置,讓文件夾的圖標遞歸顯示。但這會致使覆蓋圖標顯示緩慢,所以在不太好的機器上或工做副本太大咱們都不推薦這樣。

在這樣設置以後,每一個文件夾都會顯示爲他下面全部文件的狀態,優先顯示順序爲confilct>modified>normal。這樣你就能夠輕鬆的看到一個文件夾是否有衝突或者修改過了。

Slow Overlays

You may notice that if you enable the recursive overlay for folders that the explorer slows down remarkably when browsing working copies. This depends on how big your working copy is and how much RAM Windows can use for file index caching. Usually it's only very slow the first time you browse such a directory - if you browse the same directory later again it's much faster.

If you want to disable the recursive overlays for some folders but not for all then you can do that by creating a file called _tsvnexcluderecursive inside that folder. This will disable the recursive overlays for that folder, but not for the files or folders inside it.

You can also disable the overlays completely for a folder by creating a file called _tsvnexcludethis inside that folder. Again, this disables the overlays only for that folder, not the folders inside it. You can define specific paths to be excluded from showing overlays on the settings page (Section 4.21.2, 「The Settings Dialog, Look and Feel Tab」).

和TortoiseCVS(CVS客戶端)不同,沒有被版本控制的文件是沒有覆蓋圖標的。因此這樣作,是由於覆蓋圖標的數量是有限的,咱們應該節約點使用:)

4.5.2. 資源管理器中TortoiseSVN的專欄

和覆蓋圖標同樣有用(或更有用)的信息能夠顯示在瀏覽器詳細資料視圖方式時的附加欄中。

Simply right click on one of the headings of a column, choose More... from the context menu displayed. A dialog will appear where you can specify the columns and their order, which is displayed in the "Detailed View". Scroll down until the entries starting with SVN come into view. Check the ones you would like to have displayed and close the dialog by pressing OK. The columns will be appended to the right of those currently displayed. You can reorder them by drag and drop, or resize them, so that they fit your needs.

技巧Tip

If you want the current layout to be displayed in all your working copies, you may want to make this the default view.

4.5.3. 倉庫狀態Status Of The Repository

圖 4.6. 檢查修改Check for Modifications

清楚地知道本身修改了哪些文件以及別人修改提交了哪些文件是頗有用的。這就是命令Check For Modifications用的着的地方了。這個對話框顯示出你的工做副本中修改過的每個文件,沒有在版本控制下的文件也會被顯示出來。點擊Check Repository按鈕,能夠檢查倉庫中的改動。在作update以前,你能夠這麼作一下,來檢查是否有衝突的可能。

在其中選擇文件或文件夾單擊鼠標右鍵,在菜單中咱們能夠選擇查看文件的差異,或者把本地的修改取消。TortoiseSVN會從倉庫中自動下載最新的版原本進行比較。

4.5.4. Viewing Diffs

咱們常常會想要在文件裏面查看哪些地方修改了。你能夠先選擇已經修改的文件,單擊鼠標右鍵,選擇TortoiseSVN的命令Diff。而後會打開一個比較查看器,它會對本地的文件和倉庫中最新版本的內容進行詳細的對比。

技巧Tip

不在工做目錄中,或者你有多個版本的文件在一塊兒的時候,你也可使用比較功能:

在資源管理器中選中你要進行比較的兩個文件(使用Ctrl鍵和鼠標),而後選擇TortoiseSVN的菜單命令Diff。最後被點選的文件(焦點所在的那個,也就被虛線矩形框住的那個)將被認爲是被修改過的那個。

4.6. 更新工做副本Update Your Working Copy With Changes From Others

圖 4.7. 已完成更新的對話框

有時候你想要把別人作的修改融合到本身的本地副本當中。這個把改動從服務器拿到本地的過程就是咱們已經知道的updating。Updating操做能夠針對一個文件,或幾個被選擇的文件,或某個目錄中的全部文件。選擇你想要進行update操做的文件和(或)文件夾,單擊鼠標右鍵,在菜單中選擇Update。這時會跳出一個窗口顯示正在update的進程。別人作的修改會合併到你的文件中,而你所作的修改會被保留。Update操做對倉庫是不會產生任何影響的。

進程對話框用不一樣顏色的文字來表示不一樣的update動做。

藍色

加入到你的工做副本中的新條目。

深紅

從你的副本中刪除的條目。

綠色

成功將改動合併到本地的條目。

亮紅

合併改動到本地,可是有衝突須要解決。

黑色

全部其它的。

若是你在更新中產生了衝突(當你和別人同時修改了同一個文件的同一行而且改動的不一樣會發生這種狀況),對話框中會用紅色文字顯示出衝突。雙擊對應的行就能夠啓動外掛程序來解決衝突。

TortoiseSVN 同時也容許你更新工做副本到一個特定的版本,並不只僅是最新的版本。這個命令就是Update to Revision…,他會跳出一個對話框來讓你輸入你須要的版本。

當心Caution

If you update a file or folder to a specific revision, you will get out of date error messages when you try to commit them! If you want to undo changes to a file and start afresh from an earlier revision, you must either use the Revert changes from this revision command from the log dialog or the Merge... menu command.

命令Update to Revision...可讓你的工做回覆到之前的版本。好比說你的工做副本如今的版本是100,但你想要看看版本爲50的時候是什麼樣子,那就能夠簡單的將版本更新到50便可。

通常來講,更新一個單獨的文件到之前的版本並不太好,由於這會致使你的工做副本處於一個不一致的狀態。假如你更新的文件改過名字,有可能你只是發現那個文件消失了,由於在之前的那個版本,根本不存在那個名字的文件。若是你只是須要某個文件的老版本副本,最好在日誌對話框中使用Save revision to...命令來搞定。

警告Warning

If you updated your working copy to an earlier revision, you must not make changes to the files! You will get out of date errors if you try to commit those changes. If you want to revert some changes in your working copy, then use the repository browser and save the file in question over the file in your working copy. Or you can use the log dialog and use the command Revert changes in this revision. This will undo only those changes made in the selected revision. Changes made after that revision will be retained. For reverting multiple revisions, you should use the merge command, where you can specify the range of revisions you want to undo.

多個文件或文件夾Multiple Files/Folders

If you select multiple files and folders in the explorer and then select Update, all of those files/folders are updated one by one. TortoiseSVN makes sure that all files/folders which are from the same repository are updated to the exact same revision! Even if between those updates another commit occurred.

本地文件已存在Local File Already Exists

Sometimes when you try to update, the update fails with a message to say that there is already a local file of the same name. This typically happens when Subversion tries to checkout a newly versioned file, and finds that an unversioned file of the same name already exists in your working folder. Subversion will never overwrite an unversioned file - it might contain something you are working on, which coincidentally has the same filename as another developer has used for his newly committed file.

If you get this error message, the solution is simply to rename the local unversioned file. After completing the update, you can check whether the renamed file is still needed.

If you keep getting error messages, use Check for modifications instead to list all the problem files. That way you can deal with them all at once.

4.7. 解決衝突Resolving Conflicts

有時候,你從倉庫更新文件時會發生一些衝突。當兩個或更多開發人員對同一個文件的某幾行作了修改,就會產生衝突。由於Subversion對你的項目一無所知,他會把衝突留給開發人員來解決。只要衝突產生了,你就應該打開有問題的文件,而後找到以「<<<<<<<」開頭的那幾行,有衝突的區域會被下面這樣標示:

<<<<<<< filename

    your changes

=======

    code merged from repository

>>>>>>> revision

另外,對每個有衝突的文件,Subversion都會在你的目錄中放三個另外的文件:

filename.ext.mine

這個文件是更新工做副本以前,衝突文件在你的工做副本中原來的樣子。其中沒有任何衝突標記。

filename.ext.rOLDREV

這個文件是版本號爲OLDREV時的文件。也就是你作修改以前最後一次取出的文件。

filename.ext.rNEWREV

這是你更新時Subversion客戶端從服務器收到的最新版本的文件。他是倉庫的最新版本。

你能夠在菜單中選擇Edit Conflict來打開一個合併工具或衝突編輯器,或者用其餘編輯器來解決這個衝突。你必須決定這些代碼到底該是什麼樣子,作一些必要的修改,而後保存文件。

而後選擇菜單中的Resolved命令執行,接着提交修改到倉庫。請注意,命令Resolved並無真正的解決衝突,它只不過是把filename.ext.minefilename.ext.r*刪除,並容許你提交修改而已。

4.8. 把你的修改發送到倉庫Sending Your Changes To The Repository

發送你對工做副本的修改就是提交修改。在提交以前,你應該確認你的工做副本是最新的。你能夠直接做一次Update操做,或者先Check for Modifications看看在本地或在服務器上哪些文件修改過。

若是你的副本是最新的,而且沒有衝突,你就能夠提交你的修改了。選中你想要提交的任意文件或文件夾,而後選擇在菜單中選擇Commit…

圖 4.8. 提交對話框

提交對話框會顯示每個有修改的文件,包括新增的,刪除的,還有沒有版本控制的。若是你不想提交某個有修改的文件,只要不勾選那個文件就行了。若是你要提交某個沒有作版本控制的文件,只要勾選它就能夠提交了。

Commit files or folders?

When you commit files, the commit dialog shows only the files you have selected. When you commit a folder the commit dialog will select the changed files automatically. If you forget about a new file you created, committing the folder will find it anyway. Committing a folder does not mean that every file gets marked as changed; It just makes your life easier by doing more work for you.

Many unversioned files in the commit dialog

If you think that the TSVN commit dialog shows you too many unversioned (e.g. compiler generated or editor backup) files, there are several ways to handle this. You can:

add the file (or a wildcard extension) to the list of files to exclude on the settings page. This will affect every working copy you have.

add the file to the svn:ignore list using the Add to ignore list context menu. This will only affect the directory on which you set the svn:ignore property. Using the SVN Property Dialog, you can alter the svn:ignore property for a directory.

Read Section 4.12, 「Ignoring Files And Directories」 for more information.

在提交對話框中雙擊一個有修改的文件,能夠啓動外掛的比較工具來顯示修改細節。

在按下OK按鈕以後,會出來一個顯示提交進程的對話框。

圖 4.9. 顯示提交進程的對話框

這個顯示進程的窗口中採用了不一樣顏色的文字來表示不一樣的提交動做。

藍色Blue

提交一個修改的或新的條目。

深紅Dark red

提交一個刪除或覆蓋操做。

黑色Black

其它全部條目。

Special Folder Properties

There are several special folder properties which can be used to help give more control over the formatting of commit log messages. Read Section 4.9, 「Get/Set Information About Files/Directories」 for further information.

Integration with Bugtracking Tools

If you have activated the bugtracking system, you could set one or more Issues in the Bug-ID / Issue-Nr: Textfield. Several Issues should be comma separated. Learn more Section 4.10, 「Integration with Bugtracking Systems」.

4.9. Get/Set Information About Files/Directories

圖4.10. Subversion屬性頁

有時你想獲得一個文件或文件夾更細節的,比覆蓋圖標更多的信息。你能夠在瀏覽器屬性對話框中獲得Subversion提供的全部信息。選擇文件或文件夾,而後在菜單中選擇屬性(注意:這個屬性是資源管理器提供的那個菜單中的屬性,不在TortoiseSVN子菜單裏面)。在屬性對話框中TortoiseSVN爲在Subversion控制下的文件或文件夾加入了一個新的屬性頁。

在Subversion的屬性頁,你能夠看到選中文件或文件夾全部的相關信息。另外你還能夠讀到或設置它的subversion屬性。你能夠加入你本身的屬性,或者一些在subversion中有特殊含義的屬性。那些以svn:svn:externals就是這樣的屬性。如何使用這些擴展信息請參看4.3.4節, 「Referenced Projects」。更多subversion屬性信息,請參看Subversion Manual

要設置一個屬性,先在下拉框選擇須要的屬性名,而後在下方的輸入框中鍵入值。那些有多個值得屬性,好比忽略列表,能夠分紅多行來輸入。單擊Set按鈕來添加屬性到列表中。

若是你要應用一個屬性到一個目錄下的每個文件和目錄,注意選中Recursive複選框。

若是你要修改一個已存在的屬性,先在列表中選中他,而後就能夠修改了。

一樣,要刪除一個已存在的屬性,能夠先在列表中選中他,再單擊Remove按鈕。

TortoiseSVN也有一些本身的特殊屬性,他們以tsvn:打頭:

●              tsvn:minlogmsgsize設置了提交時日誌的最小長度。若是你沒有輸入指定長度的信息,是不能提交的。這個功能對你在每一次作提交操做時提醒你寫一些合適的描述信息是頗有用的。若是這個屬性沒有設置,或者他的值爲0,那表示不填日誌信息也能夠。

●              tsvn:logwidthmarker用在須要有必定格式日誌信息的項目中,日誌信息每行的寬度有限制(常見的是80個字符)。設置這個屬性爲一個非零值,將致使2個現象:出現一個灰色線條指示最寬的寬度,還有,自動換行沒有了。這樣你就能看到本身的文字是否是寫的太長了。注意:這個功能只有在給日誌顯示選擇了固定寬度字體時才能正常工做。

●              tsvn:logtemplate用在一些有日誌格式規範的項目中。這個屬性包含多行的文本,當進行一個commit操做時,這些文本就會自動插入到提交信息窗口中。接下來,你就能夠在其中再加入必要的信息。注意:若是你還使用了tsvn:minlogmsgsize屬性,那必定要保證設置的長度比模板中的長,不然你將失去這個保護機制。(Note: if you are also using tsvn:minlogmsgsize, be sure to set the length longer than the template or you will lose the protection mechanism.)

●              在提交對話框中,你能夠把有改動的文件列表粘貼進來,包括每一個文件的狀態(added,modified,等)。tsvn:logfilelistenglish定義了顯示的文件狀態文字是英文仍是本地語言。若是這個屬性沒有設置,默認爲true

●              TortoiseSVN可使用拼寫檢查模塊,就像OpenOffice和Mozilla使用的。若是你安裝了這些東東,這個屬性能夠決定使用哪一個拼寫檢查模塊,好比你的項目的日誌信息應該用哪一種語言來寫。tsvn:projectlanguage設置了日誌信息中拼寫檢查器要使用的語言模塊。在這裏能夠找到你的語言要使用的值:MSDN: Language Identifiers

某些tsvn:屬性須要一個true或者false的值。另外,TSVN會懂得把yes看成true,把no看成false

Set the tsvn: properties on folders

These tsvn: properties must be set on folders for the system to work. When you commit a file or folder the properties are read from that folder. If the properties are not found there, TortoiseSVN will search upwards through the folder tree to find them until it comes to an unversioned folder, or the tree root (eg. C:\) is found. If you can be sure that each user checks out only from e.g trunk/ and not some subfolder, then it is sufficient to set the properties on trunk/. If you can't be sure, you should set the properties recursively on each subfolder. A property setting deeper in the project hierarchy overrides settings on higher levels (closer to trunk/).

For tsvn: properties only you can use the Recursive checkbox to set the property to all subfolders in the hierarchy, without also setting it on all files.

Commit properties

Subversion properties are versioned. After you change or add a property you have to commit your changes.

Conflicts on properties

If there's a conflict on committing the changes, because another user has changed the same property, Subversion generates a .prej file. Delete this file after you have resolved the conflict.

Automatic property setting

You can configure subversion to set properties automatically on files and folders when they are added to the repository. Read Section 4.21, 「TortoiseSVN's Settings」 for further information.

TortoiseSVN可以和一些bug跟蹤系統整合到一塊兒。這須要使用那些bugtraq:開頭的屬性。更多相關信息請閱讀第4.10節 「整合BUG跟蹤系統Integration with Bugtracking Systems」

4.10. Bug跟蹤系統Integration with Bugtracking Systems

你能夠選擇爲TortoiseSVN整合一套Bug跟蹤系統。要達到這個目的,你必須爲目錄定義一些以bugtraq:開頭的屬性(第4.9節 獲取(修改)文件(目錄)信息):

bugtraq: message

這個屬性可以激活Bug跟蹤系統。一旦這個屬性被設置,提交修改時,TortoiseSVN會要求你輸入一個流水號。而這個屬性的值將被放在日誌信息的末尾,其中必須包含%BUGID%,這個%BUGID%在提交時會被流水號替換掉。這就能保證你提交的日誌信息中包括Bug流水號,這個流水號常常會有一個特定的格式,而且與你的Bug跟蹤系統協調工做。好比,咱們的TortoiseSVN項目就正在使用這樣的流水號:%BUGID%。(e.g the TortoiseSVN project is using Issue : %BUGID%, but this depends on your Tool.)

bugtraq: append

當這個屬性爲true時,上面提到的BUGID將出如今日誌的末尾,當爲false時,BUGID將出如今日誌的開頭。該屬性的有效值爲true或false。假如沒有定義,系統將默認爲true,這樣可以保證已有項目正常運行。

bugtraq: url

將這個屬性設置爲你的Bug跟蹤系統的url。這個url應該被合適的編碼過而且包含%BUGID%,%BUGID%會被輸入的流水號替換掉的。這樣,TortoiseSVN就會在日誌對話框中顯示一個連接,你就能夠經過點擊這個連接直接跳到Bug跟蹤系統。若是你不提供這個屬性,TortoiseSVN將只顯示那個流水號,也不會連接到哪裏。好比:TortoiseSVN項目使用的是http://tortoisesvn.tigris.org/issues/show_bug.cgi?id=%BUGID%

bugtraq: label

這個屬性用來指定將顯示在提交窗口中流水號輸入框前的標籤裏的文字。若是沒有設置的話,默認顯示的是Bug-ID/Issue-Nr:。注意,窗口不會變化大小去適應這個標籤的,因此要保證文字不要超過20-25個字符。

bugtraq: number

該屬性爲true時,流水號將只容許數字輸入。逗號是個例外,你能夠輸入多個用逗號隔開的數字。有效的屬性值爲true或者false。若是沒有定義,默認爲true。

bugtraq: warnifnoissue

若是想要讓TortoiseSVN提醒不要輸入空流水號,那就把這個屬性設置爲true。有效的屬性值爲true或者false。若是沒有定義,默認爲false。

某些tsvn:屬性須要一個true或者false的值。另外,TSVN會懂得把yes看成true,把no看成false

Set the Properties on Folders

These properties must be set on folders for the system to work. When you commit a file or folder the properties are read from that folder. If the properties are not found there, TortoiseSVN will search upwards through the folder tree to find them until it comes to an unversioned folder, or the tree root (eg. C:\) is found. If you can be sure that each user checks out only from e.g trunk/ and not some subfolder, then it's enough if you set the properties on trunk/. If you can't be sure, you should set the properties recursively on each subfolder. A property setting deeper in the project hierarchy overrides settings on higher levels (closer to trunk/).

For tsvn: properties only you can use the Recursive checkbox to set the property to all subfolders in the hierarchy, without also setting it on all files.

4.11. 加入新文件和新目錄Adding New Files And Directories

圖4.11. 沒有版本控制文件的菜單

若是你想把在開發過程當中建立了新文件或新的目錄加入到源代碼控制之下,能夠這樣作:選中文件或目錄,而後在菜單中選擇Add命令。

在把文件或目錄加入到控制之下後,這些文件或目錄就會顯示爲一個added覆蓋圖標的樣子,這就意味着你應該趕忙把你的工做副本commit一下,以便其餘開發人員可以看到這些文件或目錄。添加一個文件或目錄並不會影響到倉庫!

Many Adds

You can also use the Add command on already versioned folders. In that case, the add dialog will show you all unversioned files inside that versioned folder. This helps if you have many new files and need them to add at once.

要把工做副本以外的文件加入進來,可使用拖拽來搞定:

1.  選中你要添加的文件先。

2.  按下鼠標右鍵將文件拖拽到工做副本中的某個地方。

3.  鬆開鼠標右鍵。

4.  在跳出來的菜單中選擇add files to Subversion here。這些文件立刻就會被複制到工做副本中而且加入到了版本控制。

4.12. 忽略文件和目錄Ignoring Files And Directories

圖4.12. 沒有版本控制文件的菜單

在不少項目中,有一些文件或目錄是不該該被版本控制影響到的。包括那些編譯器產生的*.obj, *.lst,還有一些存放可執行文件的輸出目錄。當提交修改時,TSVN就會把沒有版本控制的文件列出來,佔滿了提交窗口的文件列表。固然你能夠選擇不顯示他們,但這樣可能會把一些須要添加的新加入的源代碼文件漏掉。

避免這個問題的最好辦法就是把這些文件加入項目的忽略列表。這樣他們就不會再在提交窗口中出現了,而真正沒有版本控制的源文件仍是會被標記顯示出來。

在沒有版本控制的一個文件上單擊鼠標右鍵,而後在TSVN的菜單中選擇Ignore命令,這時會有一個子菜單出現,可讓你選擇僅僅是這個文件,或者全部這個擴展名的文件。若是你最開始選中的是多個文件,那就不會有這個子菜單出現,而只能選擇把這些選中的文件或目錄加入忽略列表。

要把一個文件從忽略列表中去掉,必須編輯父目錄的屬性,把文件名從svn:ignore屬性中移除。更多信息請閱讀第4.9節 獲取(修改)文件(目錄)信息Get/Set Information About Files/Directories

The Global Ignore List

Another way to ignore files is to add them to the global ignore list. The big difference here is that the global ignore list is a client property. It applies to all subversion projects, but on the client PC only. In general it is better to use the svn:ignore property where possible, because it can be applied to specific project areas, and it works for everyone who checks out the project. Read Section 4.21, 「TortoiseSVN's Settings」 for more information.

4.13. 刪除、重命名、移動Deleting, Renaming And Moving

和CVS不同,Subversion容許對文件和目錄進行更名和移動操做。所以在TortoiseSVN的子菜單中有delete和rename。

圖4.13. 版本控制下文件的菜單

若是使用TSVN刪除了一個文件或目錄,這個文件就已經從工做副本中刪除了,並被標記爲刪除狀態。這個文件的父目錄將顯示爲一個「deleted」覆蓋圖標。要恢復這個文件,只需對他的父目錄進行revert操做便可。

若是要在工做副本內移動文件,可使用鼠標來拖拽:

1.  選中要移動的文件或目錄。

2.  用鼠標右鍵拖拽他們到工做副本中一個新的目錄。

3.  鬆開鼠標右鍵。

4.  在跳出的菜單中選擇move files in Subversion to here

若是一個刪除操做不是在版本控制下完成的,好比就像日常刪除文件那樣刪除的。提交時,對話框窗口仍是會顯示這些刪除的文件,並讓你把他們從版本控制下刪除。因此若是忘記使用TortoiseSVN來刪除這些文件,這些都不是什麼大不了的問題。

Commit the parent folder

Since renames and moves are done as a delete followed by an add you must commit the parent folder of the renamed/moved file. Only that way the deleted part of the rename/move will show up in the commit dialog. If you don't commit the removed part of the rename/move, it will stay behind in the repository and an update of your coworkers won't remove the old file.

Getting a deleted file or folder back

If you have deleted a file or a folder and already committed that delete operation to the repository, then a normal Revert can't bring it back anymore. But the file or folder is not lost at all. If you know the revision the file or folder got deleted (if you don't, use the log dialog to find out) open the repository browser and switch to that revision. Then select the file or folder you deleted, right-click and select Copy to... as the target for that copy operation select the path to your working copy.

4.14. 取消改變Undo Changes

若是要取消對一個文件所作的修改,只需用鼠標右鍵單擊該文件,選擇TSVN子菜單中的revert命令,在跳出的窗口中會顯示你選擇的文件,這時能夠再次勾選文件,而後按下OK按鈕就行了。注意這裏所作的取消修改只能返回到該文件上次update時的狀態。

圖4.14. Revert dialog

Undoing Changes which have been Committed

Revert will only undo your local changes. It does not undo any changes which have already been committed. If you want to undo all the changes which were committed in a particular revision, read Section 4.15, 「Revision Log Dialog」 for further information.

4.15. 修訂日誌窗口Revision Log Dialog

每一次修改和提交,都應該作好日誌記錄。這樣開發過程當中就有了一個詳細的記錄,之後即可找出每個修改是如何修改以及爲何這樣修改的。

日誌對話框會顯示全部日誌信息。顯示分紅3個部分:

1.              最上面部分顯示的是全部被提交的版本列表。顯示有日期時間、提交者、修訂版本號和日誌信息的前面一部分。
用藍色顯示的行表示有某些文件被複制到了這個版本。(也許是從一個分支來的)Lines shown in blue indicate that something has been copied to this development line (perhaps from a branch).

2.              中間部分顯示的是選中版本的全部日誌信息。

3.              底部顯示的是選中版本所作修改的文件和目錄列表。

還不只僅是這些,對話框中還提供了不少的菜單命令可使用。

4.15.1. Invoking The Log Dialog

圖4.15. 日誌窗口

有不少個地方能夠調出這個日誌窗口:

1.  從TortoiseSVN的菜單。

2.  從文件的屬性頁。

3.  完成update操做以後的窗口。這個窗口將只顯示自上次更新以來有過的版本。

4.15.2. Getting Additional Information

圖4.16. 日誌窗口頂部窗格的右鍵菜單

頂部窗格中的右鍵菜單功能以下:

1.              Compare with working copy 對選中版本與本地副本進行比較。默認的比較工具是TSVN提供的TortoiseMerge。若是是某個目錄的日誌,就會顯示有改動文件的列表,接下來能夠選擇單個文件進行改動查看。

2.              Show Differences as Unified Diff 在一個文件裏面顯示全部的改動。這個操做比上面那個調用外部的比較查看器要快多了,由於TSVN只須要拿到不一樣,而再也不須要獲取全部的文件。

3.              保存選中版本爲一個文件,這樣就能夠獲得這個文件的一個老版本了。這個選項只有當你選中的版本中只有一個文件被改動時纔有效。

4.              Browse Repository打開倉庫瀏覽器,檢查選中的目錄。這個選項只有當日志只有一個目錄時纔有效。

5.              Create tag from Revision 從選中版本建立branch或tag。這個功能頗有用的。好比當你忘記建立一個tag而已經提交了一些改動,但這些改動你又不想包含到那個版本中去時。

6.              更新工做副本到選中版本。當想把工做副本回復到之前的某個狀態,這個選項是頗有用的。最好是更新整個目錄而不是隻更新一個文件,不然你的工做副本就會不一致,並且你也將沒辦法提交任何改動。

7.              恢復改動到選中版本。這個操做對倉庫沒有一點影響,只會在本地副本中進行改動的恢復。注意,它只取消那個版本的全部改動,沒有用老版本的整個文件來替換你的副本。這在要取消一個之前的改動時頗有用。

8.              檢索日誌信息。這個功能能夠在輸入的日誌信息和Subversion建立的動做摘要中進行查找。注意:大小寫是不敏感的。

圖4.17. 頂部窗格中選中2個文件時的菜單

若是你一次選中兩個版本,菜單就會只剩下三個選項了:

1.              用可視化工具來比較選中的2個版本。默認的比較工具是TSVN提供的TMerge。這個功能只對文件有效,對目錄沒用。

2.              在一個文件中顯示這2個版本的不一樣點。這個對文件和目錄都有效。

3.              檢索日誌信息。和前面講到的同樣。

圖4.18. 底部窗格的菜單

底部窗格菜單的做用以下:

1.  查看選中文件在那個版本中所做的改動。這個菜單隻有當文件爲Modified時纔有效。

2.  保存選中文件的相關版本。

3.  查看選中條目的Subversion屬性。

4.15.3. Getting all log messages

日誌窗口通常不會顯示全部的日誌的:

1.              對一個大型倉庫來講,顯示成千上萬的改動須要花太多時間。正常狀況下,開發人員只關注最近的修改。默認狀況,最多會顯示100條日誌。你也能夠在Settings中修改這個值(見第4.21節,「TortoiseSVN的設置」)。

2.              當查看一個branch或者tag的日誌時,只會顯示建立這個特定branch的目錄到根的日誌。這樣的好處是不會顯示多餘的其餘無關的日誌信息。
注意這隻對本地副本有效。若是使用倉庫瀏覽器,日誌信息會從分支的地方繼續顯示更多。

若是想獲得全部日誌,先回到版本1,再按Get All

4.15.4. Changing the log message and author

有時候須要修改早先輸入的日誌,由於各類各樣的緣由,好比一個拼寫錯誤,或者要改進一些說法等等。另外還有可能須要修改提交修改的做者,好比因爲忘記設置認證等等緣由。

Subversion容許任意的修改日誌內容或版本做者。但這個功能默認是關閉的,由於這些修改是不能取消的(這些修改沒有在版本控制之下)。要讓這個功能起做用,必須先設置好pre-revprop-change hook。關於如何設置的細節請查閱Subversion的Hook Scripts一節。關於如何在Windows環境如何實現hooks請閱讀第3.5節「Repository Hooks」。

爲服務器配置好必需的hooks以後,就能夠修改每一個版本的做者和日誌內容了。用TSVN修改的方法是,在先按住SHIFT鍵,再用鼠標雙擊須要修改的做者或日誌欄。若是沒有按住SHIFT鍵,或沒有點擊在這2個欄上,那默認的雙擊動做(顯示選中版本的區別)就會被執行了。

Warning

Because Subversion's revision properties are not versioned, making modifications to such a property (for example, the svn:log commit message property) will overwrite the previous value of that property forever.

4.15.5. Statistical Information

按下統計按鈕(Statistics)會顯示一些關於修訂版本的有趣信息。顯示的內容包括,有多少做者在工做,他們提交了多少內容,每週的進展,等等。如今就能夠知道誰在努力工做誰在偷懶了:)

注意,這個統計頁面數據的範圍和前一個界面裏日誌的範圍是同樣的。因此若是隻是一個版本的日誌,那這裏的統計信息就不會有太大的意義了。

4.16. 分支/標記Branching / Tagging

版本控制的一個重要特性是能將變動隔離成獨立的開發線路。這就是所謂的分支(branch)。分支經常使用來測試新功能,但又不會由於編譯錯誤或BUG干擾開發主線。一旦分支穩定下來,就能夠把分支合併(merge)回主線(the trunk)了。

版本控制的另外一個特性是標記特殊版本(好比一個能夠發佈的版本),這樣有利於在任什麼時候候從新建立一個特定的build或開發環境。這就是所謂的標記(tagging)。

Subversion沒有什麼專門的命令來branching或者tagging,而使用cheap copies來代替。Cheap copies有點像links(譯者注:就像windows系統的快捷方式),並無真正的進行復制操做。

4.16.1. Creating a Branch or Tag

在從副本建立分支或標記前,最好先確保本地與倉庫的版本一致。

若是你是按先前的推薦組織方式存放倉庫的,那建立分支或標記會很是簡單:

圖4.19. 分支/標記

選中工做副本父目錄,調出菜單,選擇命令Branch/Tag。輸入分支或標記的倉庫路徑URL。把原來輸入的trunk 換成tags/tagname ,這裏tagname 多是ProjectName_v1.10.

    C:/SVNRepository/trunk/ProjectName/...

    C:/SVNRepository/trunk/AnotherProject/...

    C:/SVNRepository/branches/ProjectName_SpecialDebugBuildBasedOn_v1.09/

    C:/SVNRepository/tags/ProjectName_v1.10

按下OK鈕,Subversion就在倉庫中用指定的目錄建立了一個cheap copy。建立分支或標記都不影響本地副本。

若是本地有沒有提交的改動,TortoiseSVN會在建立標記時一塊兒提交改動。

4.16.2. To Checkout or to Switch...

這是(不是真的)個問題。因爲checkout會取出全部的數據,而switch只會傳輸修改的內容。Good for the network load, good for your patience. :-)

爲了可以獲得最新的副本進行工做,你能夠:

1.  再次執行checkout。你能夠任意次的取出副本到本地的任意地方。

2.  轉換當前副本到新建立的倉庫。只需再對項目的父目錄執行Switch命令。
在下一個窗口輸入剛纔建立的branch地址。選擇Head version。點擊OK。本地副本就切換到新branch或tag了。
轉換就像更新同樣,不會丟掉本地的任何修改,而是將未提交修改合併。若是不想這樣,那就在轉換(switch)以前進行提交(commit)操做,或恢復(revert)副本到某個已提交版本(通常都選head版本)。

圖4.20. 轉換窗口

Subversion是不明白tags與branches的不一樣的。下面列出幾點區別:

1.              標記用於建立項目在一個特殊階段的靜態快照,一般再也不用於開發,而分支是用於開發的。這就是先前推薦使用/trunk /branches /tags結構的理由。固然你也能夠修改/tags/中的副本,但提交時TortoiseSVN會有警告。

2.              若是一個已經標記過的還發布了的版本,還要進行修改,正確的方法是建立一個新的分支,在新分支上作修改,再根據這個分支建立新標記。好比Version_1.0.1

3.              若是在副本上修改並提交,則修改只體如今分支上而不是主幹上。

4.17. 合併Merging

Where branches are used to maintain separate lines of development, at some stage you will want to merge the changes made on one branch back into the trunk, or vice versa.

在進行合併操做以前,理解subversion中分支與合併如何工做是蠻重要的,不然可能致使很複雜的狀況出現。強烈建議各位去閱讀Subversion BookBranching and Merging這一節,那裏有詳細的描述和不少例子。

There are two common use cases for merging which are handled in slightly different ways, as described below.

4.17.1. Merging a Range of Revisions

This method covers the case when you have made one or more revisions to a branch (or to the trunk) and you want to port those changes across to a different branch.

Figure 4.21. The Merge Dialog

To merge revisions you need to go to a working copy of the branch in which you want to receive the changes, often the trunk. Select Merge... from the context menu.

In the From: field enter the full folder url of the branch or tag containing the changes you want to port into your working copy. You may also click ... to browse the repository and find the desired branch.

Because you are porting a range of revisions from the same branch into your working copy, make sure the Use "From:" URL checkbox is checked.

In the From Revision field enter the initial revision number. This is the revision before the changes you want to merge. Revision numbers are auto-incremented after each commit. You want to start merging the changes before the revision number is auto-incremented. For example, if your log messages look something like this:

Rev Comments

39. Working on MyBranch

38. Working on trunk

37. Working on MyBranch

36. Create branch MyBranch

35. Working on trunk

34. Working on trunk

         ...

If you now want to merge the changes from MyBranch into the trunk you have to choose 36 as the From Revision. Not 37 as you might think.

The easiest way to find the revision you need is to click on Show Log, as this will list recent changes with their log comments. Select the revision you require in the Show Log dialog, then click on OK.

In the To Revision field enter the last revision number in the range you want to merge. Often this will be the HEAD revision, although it doesn't need to be - you can just want to merge a single revision.

Click OK to complete the merge.

The merge is now complete. It's a good idea to have a look at the merge and see if it's as expected. Merging is usually quite complicated. Conflicts often arise if the branch has drifted far from the trunk.

When you have tested the changes and come to commit this revision, your commit log message should always include the revision numbers which have been ported in the merge. If you want to apply another merge at a later time you will need to know what you have already merged, as you do not want to port a change more than once. Unfortunately merge information is not stored by Subversion. For more information about this, refer to Tracking Merges Manually in the Subversion Book

If you want to keep this branch up to date with the trunk, you should immediately merge changes from trunk back to the this branch. Use this method and local changes won't get in your way. Of course, you should still avoid repeated merging of trunk changes, as explained above.

If you want to see what changes will be made by a merge and see where possible conflicts may occur you can check the option Dry Run . This will force the merge command to do a merge, but not modify the working copy at all.

Important

Subversion can't merge a file with a folder and vice versa - only folders to folders and files to files. If you click on a file and open up the merge dialog, then you have to give a path to a file in that dialog. If you select a folder and bring up the dialog, then you must specify a folder url for the merge.

4.17.2. Merging Two Different Trees

This method covers the case when you have made a feature branch as discussed in the Subversion book. All trunk changes have been ported to the feature branch, week by week, and now the feature is complete you want to merge it back into the trunk. Because you have kept the feature branch synchronized with the trunk, the latest versions of branch and trunk will be absolutely identical except for your branch changes. So in this special case, you would merge by comparing the branch with the trunk.

To merge the feature branch back into the trunk you need to go to a working copy of the trunk. Select Merge... from the context menu.

In the From: field enter the full folder url of the trunk. This may sound wrong, but remember that the trunk is the start point to which you want to add the branch changes. You may also click ... to browse the repository.

Because you are comparing two different trees, make sure the Use "From:" URL checkbox is not checked.

In the To: field enter the full folder url of the feature branch.

In both the From Revision field and the To Revision field, enter the last revision number at which the two trees were synchronized. If you are sure no-one else is making commits you can use the HEAD revision in both cases. If there is a chance that someone else may have made a commit since that synchronization, use the specific revision number to avoid losing more recent commits.

Click OK to complete the merge.

In this case you will not need the feature branch again because the new feature is now integrated into the trunk. The feature branch is redundant and can be deleted from the repository if required.

4.18. 建立和應用補丁Creating and Applying Patches

若是誰均可以隨便修改,項目將沒完沒了,永遠無法穩定下來。怎麼辦呢?經過「補丁patch」!將補丁送交給具備寫權限的開發團隊,他們先審查補丁,再決定是否提交,或者打回給做者。

補丁文件只保存有副本與基礎版本的差別。

4.18.1. Creating a Patch File

First you need to make and test your changes. Then instead of using Commit... on the parent folder, you select Create Patch... This will produce a single file containing a summary of all the changes you have made since the last update from the repository. If you create a patch file, make some more changes and then create another patch, the second patch file will include both sets of changes.

Just save the file using a filename of your choice. Patch files can have any extension you like, but by convention they should use the .patch or .diff extension. You are now ready to submit your patch file.

4.18.2. Applying a Patch File

Patch files are applied to your working copy. This should be done from the same folder level as was used to create the patch. If you are not sure what this is, just look at the first line of the patch file. For example, if the first file being worked on was doc/source/english/chapter1.xml and the first line in the patchfile is Index: english/chapter1.xml then you need to apply the patch to the english folder.

In order to apply a patch file to your working copy, you need to have at least read access to the repository. The reason for this is that the merge program must reference the changes back to the revision against which they were made by the remote developer.

From the context menu for that folder, click on Apply Patch... This will bring up a file open dialog allowing you to select the patch file to apply. By default only .patch or .diff files are shown, but you can opt for "All files". Open the file and TortoiseMerge runs to merge the changes from the patch file with your working copy. A small window lists the files which have been changed. Double click on each one in turn, review the changes and save the merged files.

The remote developer's patch has now been applied to your working copy, so you need to commit to allow everyone else to access the changes from the repository.

4.19. 副本重定位Relocating a working copy

Figure 4.22. The Relocate Dialog

If your repository has for some reason changed it's location (IP/URL). Maybe you're even stuck and can't commit and you don't want to checkout your working copy again from the new location and to move all your changed data back into the new working copy, relocate is the command you are looking for. It basically does very little: it scans all "entries" files in the .svn folder and changes the URL of the entries to the new value.

Warning

Don't use the relocate command to switch your working copy to a different branch! If you do that, then you will get many unexplainable error messages while updating, committing, ...

The relocate command must only be used if the URL of the server changed!

4.20. 倉庫瀏覽器The Repository Browser

Sometimes you need to work directly on the repository, without having a working copy. That's what the Repository Browser is for. What the explorer and the icon overlays are for your working copy is the Repository Browser for the repository.

Figure 4.23. The Repository Browser

With the Repository Browser you can execute commands like copy, move, rename, ... directly on the repository.

On the top of the Repository Browser Window you can enter the URL of the repository and the revision you want to browse. Browsing an older revision is useful if you want to e.g. recover a previously deleted file. Use the Copy To... command to do that and enter the full working copy path to where you want to recover your deleted file.

4.21. TSVN的設置TortoiseSVN's Settings

To find out what the different settings are for, just leave your mouse pointer a second on the editbox/checkbox... and a helpful tooltip will popup.

4.21.1.

圖4.24. 設置主界面

Apart from setting your preferred language, this dialog allows you to specify (almost) every setting TortoiseSVN has.

Language

Selects your user interface language. What else did you expect?

Exclude/Ignore pattern

Exclude patterns are used to prevent unversioned files from showing up e.g. in the commit dialog. Files matching the patterns are also ignored by an import. Exclude files or directories by typing in the names or extensions. Patterns are separated by spaces e.g. bin obj *.bak *.~?? *.jar *.[Tt]mp. The first two entries refer to directories, the other four to files.

 Warning

If you use the subversion configuration file to set a global-ignores pattern, it will override the settings you made here. The Subversion configuration file is accessed using the Edit as described below. 

This exclude pattern will affect all your projects. It is not versioned, so it will not affect other users. By contrast you can also use the versioned svn:ignore property to exclude files or directories from version control. You can set the svn:ignore property using the Add to Ignore List command. After commiting every other user will have the same svn:ignore property set for this project / directory as you. If you want to remove an ignored file from svn:ignore, you have to edit the parent folder properties. Read Section 4.12, 「Ignoring Files And Directories」 and Section 4.9, 「Get/Set Information About Files/Directories」 for more information.

Default number of log messages

Limits the number of log messages that TortoiseSVN fetches when you first select Show Log Useful for slow connections / servers. You can always Fetch All messages.

Edit...

... the subversion configuration file directly. Some settings cannot be modified directly by TortoiseSVN, and need to be set here instead. For more information about the subversion config file see the Subversion Manual . The section on Automatic Property Setting is of particular interest, and that is configured here.

Short date / time format in log messages

If the standard long messages use up too much space on your screen use the short format.

Set filedates to "last commit time"

This option tells TortoiseSVN to set the filedates to the last commit time when doing a checkout or an update. Otherwise TortoiseSVN will use the current date. If you are developing software it is generally best to use the current date because build systems normally look at the datestamps to decide which files need compiling. If you use "last commit time" and revert to an older file revision, your project may not compile as you expect it to.

Close windows automatically

TortoiseSVN will automatically close all progress dialogs when the action is finished without error.

Don't close on conflicts

Automatic window closing is suppressed if there were conflicts during an update. This option is highly recommended to avoid missing conflict reports.

Check for newer versions

If checked, TortoiseSVN will check once a week to see if an update is available

Force shell icon refresh

If checked, TortoiseSVN will refresh all the overlay icons after every operation without you having to press F5.

 Warning

Explorer will refresh every visible icon, not just the status overlays. If you have a network share, or a CD-ROM or floppy showing, then explorer will go and update all the icons from their original source files, and that can be very slow, blocking the explorer process completely for many seconds. 

4.21.2.

Figure 4.25. The Settings Dialog, Look and Feel Tab

This tab allows you to choose the items for which TortoiseSVN will display icon overlays. If you feel that your icon overlays are very slow (explorer is not responsive), uncheck the "Recurse into folders to fetch the status" box. You can even disable all icon overlays, but where's the fun in that?

Figure 4.26. The Settings Dialog, Overlay Chooser Dialog

You can also change the overlay icon set by clicking on Select Overlay Set. Note that if you change overlay set, you have to restart your computer for the changes to take effect.

The Exclude Paths are used to tell TortoiseSVN for which paths not to show icon overlays and status columns. This is useful if you have some very big working copies containing only libraries which you won't change at all and therefore don't need the overlays. For example:

f:\development\SVN\Subversion will disable the overlays on only that specific folder. You still can see the overlays on all files and folder inside that folder.

f:\development\SVN\Subversion* will disable the overlays on all files and folders whose path starts with f:\development\SVN\Subversion. That means you won't see overlays for any files and folders below that path.

The same applies to the Include Paths. Only that for those paths the overlays are shown even if the overlays are disabled for that specific drive type.

You can also specify here which of the TortoiseSVN context menu entries will show up in the main context menu.

4.21.3.

Figure 4.27. The Settings Dialog, Network Tab

Here you can configure your proxy server, if you need one to get through your company's firewall.

You can also specify which program TortoiseSVN should use to establish a secure connection to a svn+ssh repository.

4.21.4. /合併設置

Figure 4.28. The Settings Dialog, Diff/Merge Tab

Here you can define your own diff/merge programs that TortoiseSVN should use. The basic setting is to use the builtin TortoiseMerge which is installed alongside TortoiseSVN.

Diff Program

An external diff program used for comparing different revisions of files. You can specify the following parameters to the path:

%base

The original file without your changes

%bname

The window title for the base file

%mine

Your own file, with your changes

%yname

The window title for your file

The window titles are not pure filenames. TortoiseSVN treats that as a name to display and creates the names accordingly. So e.g. if you're doing a diff from a file in revision 123 with a file in your working copy, the names will be filename : revision 123 and filename : working copy

Merge Program

An external merge program used to resolve conflicted files. You can specify the following parameters to the path. The order of the parameters depends on the merge program you use.

%base

the original file without your or the others changes

%bname

The window title for the base file

%mine

your own file, with your changes

%yname

The window title for your file

%theirs

the file as it is in the repository

%tname

The window title for the file in the repository

%merged

the conflicted file, the result of the merge operation

%mname

The window title for the merged file

Diff Viewer

A viewer program for unified-diff files (patch files). If you don't have one the builtin option is to use NotePad. No Parameters.

The original Windows NotePad program does not behave well on files which do not have standard CR-LF line-endings. Since most unified diff files have pure LF line-endings, they do not view well in NotePad. However, you can download a free NotePad replacement Notepad2 which not only displays the line-endings correctly, but also colour codes the added and removed lines.

Figure 4.29. The Settings Dialog, Diff/Merge Advanced Dialog

In the advanced settings, you can define a different diff and merge program for every file extension. For instance you could associate Photoshop as the "Diff" Program for .jpg files :-)

4.22. 誰動了哪一行?Who Changed Which Line?

Figure 4.30. The Annotate / Blame Dialog

Sometimes you need to know not only what lines have changed, but also who exactly changed specific lines in a file. That's when the Blame... command, sometimes also referred to as annotate command comes in handy.

This command lists, for every line in a file, the author and the revision the line was changed.

If you're not interested in changes from earlier revisions you can set the revision from which the blame should start. Set this to 1, if you want the blame for every revision.

By default the blame file is viewed using TortoiseBlame, which highlights the different revisions to make it easier to read. If you wish to print or edit the blame file, select Use Text viewer to view blames

Once you press OK TortoiseSVN starts retrieving the data to create the blame file. Please note: This can take several minutes to finish, depending on how much the file has changed and of course your network connection to the repository. Once the blame process has finished the result is written into a temporary file and you can view the results.

Figure 4.31. TortoiseBlame

TortoiseBlame, which is included with TortoiseSVN, makes the blame file easier to read. When you hover the mouse over a line in the blame info column, all lines with the same revision are shown with a darker background. Lines from other revisions which were changed by the same author are shown with a light background. The colouring may not work as clearly if you have your display set to 256 colour mode.

If you left click on a line, all lines with the same revision are highlighted, and lines from other revisions by the same author are highlighted in a lighter colour. This highlighting is sticky, allowing you to move the mouse without losing the highlights. Click on that revision again to turn off highlighting.

The revision comments are shown in a hint box whenever the mouse hovers over the blame info column.

4.23. 版本路線圖Revision Graphs

Figure 4.32. A Revision Graph

Sometimes you need to know where branches and tags were taken from the trunk, and the ideal way to view this sort of information is as a graph or tree structure. That's when you need to use Revision Graph...

This command analyses the revision history and attempts to create a tree showing the points at which copies were taken, and when branches/tags were deleted. Please note: It can take several minutes to retrieve all the data needed to create the revision graph, depending on how much the project has changed and of course your network connection to the repository.

The revision graph shows several types of node:

Added file/folder

Items which have been added, or created by copying another file/folder are shown using a rounded rectangle.

Deleted file/folder

Deleted items eg. a branch which is no longer required, are shown using an octagon (rectangle with corners cut off).

Normal file/folder

All other items are shown using a plain rectangle.

Note that the graph only shows the points at which items were added or deleted. Showing every revision of a project would generate an impossibly large graph for non-trivial cases.

The revision date, author and comments are shown in a hint box whenever the mouse hovers over a revision box.

Warning

Because subversion cannot provide all the information required, a certain amount of interpretation is required, which can sometimes give strange results. Nevertheless, the output for the trunk will generally give useful results. 

4.24. 最後Final Step

Wishlist

Even though TortoiseSVN and TortoiseMerge are free, you can support the developers by sending in patches and play an active role in the development. You can also help to cheer us up during the endless hours we spend in front of our computers.

While working on TortoiseSVN we love to listen to music. And since we spend many hours on the project we need a lot of music. Therefore we have set up some wish-lists with our favourite music CD's and DVD's: http://tortoisesvn.tigris.org/donate.html Please also have a look at the list of people who contributed to the project by sending in patches or translations.

 

文章引自---www.blogjava.net/jelver/articles/88124.html

相關文章
相關標籤/搜索