對於每次進行修改和提交,你應該有針對性地留下日誌資訊。這樣,你就可以在以後方便地看到你都做了什麼,為什麼這麼做。當然這麼做還是你擁有了開發過程的詳細日誌。
版本日誌對話方塊可以擷取所有的日誌資訊,並將其顯示出來。對話方塊的視圖分成3個面板。
最上方的面板顯示了版本的列表。這其中包含了日期和時間,以及提交的使用者和日誌資訊開頭的部分內容。
以藍色顯示的行表示某些內容被複製到該開發版本中(可能是從一個分支中複製而來)。
中間的面板顯示了被選中的版本的完整的日誌資訊。
最下面的面板顯示了被選中版本中都對哪裡檔案和檔案夾進行了修改。
當然,對話方塊的作用不止於此——它提供了右鍵菜單,通過它可以擷取更多的項目曆史資訊。
調用版本日誌對話方塊
圖 5.15. 版本日誌對話方塊
有幾種途徑可以調出日誌對話方塊:
版本日誌動作
頂部面板有個動作列,包含了此版本的動作概要表徵圖。有四個不同的表徵圖,每個都在自己的列顯示。
If a revision modified a file or directory, the modified icon is shown in the first column.
If a revision added a file or directory, the added icon is shown in the second column.
If a revision deleted a file or directory, the deleted icon is shown in the third column.
If a revision replaced a file or directory, the replaced icon is shown in the fourth column.
獲得更多資訊
圖 5.16. 版本日誌對話方塊的頂部面板的右鍵菜單
The top pane of the Log dialog has a context menu that allows you to access much more information. Some of these menu entries appear only when the log is shown for a file, and some only when the log is shown for a folder.
將你的工作版本與選中的版本進行比較。預設的比較工具是與TortoiseSNV一同發布的TortoiseMerge,如果日誌對話方塊是針對檔案夾的,那麼就會出現一個被修改的檔案的列表,你可以單獨地查看每個檔案所做的修改。
將選中的版本作為單一差異檔案(GNU補丁格式)查看。相對於可視化的檔案比較子,它更難閱讀,但它將所有的變化顯示在一個格式更為緊湊的檔案中。
比較選擇的版本和以前版本。它與你比較工作複本類似。
追溯選中的版本,和你的工作基礎檔案,使用可視化差異工具比較追溯報告。參閱 “追溯不同點”一節 以獲得更多資訊(僅對於檔案)。
追溯選中的版本和舊版本,用可視化差異工具比較結果(僅對於目錄)。
將選中的版本儲存到檔案,你可以得到一份該檔案的舊版本(僅對於檔案)。
用此檔案類型的預設查看器,或你指定的程式開啟選中的檔案(僅對於檔案)。
追溯檔案直到選中的版本(僅對於檔案)。
開啟版本庫瀏覽器,基於選中的版本,在版本庫中檢查選中的檔案或目錄。
從選中的版本建立一個分支/標記。這個選項很有用。比如: 如果你提交了某些你不想使其進入發行版的修改,卻忘記了為此建立標記。
將你的工作複本更新到選中的版本。如果你想要你的工作複本折返到過去的某個時間,那這個功能就很好用。你最好是更新工作複本的整個目錄而不是單一某個檔案,因為如果只更新某個檔案,你的工作複本就可能不一致,從而導致你無法提交任何修改。
還原選中版本所做的修改。還原的內容只在你的工作複本中,所以此操作完全不會影響版本庫!要注意的是,這個操作僅僅還原該版本中的修改。不是將整個檔案替換成選中的那個版本。它對於已經做過其它無關修改的還原早期修改非常有用。如果你做了本地修改,此命令將會合并修改到工作複本。
恢複到某個以前的版本。如果你做了多處修改,然後決定要返回到版本 N,你就可以使用這個命令。再次說明,恢複的修改位於你的工作複本,在你提交之前,並不會影響版本庫。注意,這將會丟棄從那個版本以來的所有修改,使用選中的版本來替換檔案/檔案夾。
Merge the selected revision(s) into a different working copy. A folder selection dialog allows you to choose the working copy to merge into, but after that there is no confirmation dialog, nor any opportunity to try a dry run. It is a good idea to merge into an unmodified working copy so that you can revert the changes if it doesn't work out! This is a useful feature if you want to merge selected revisions from one branch to another.
檢出你選擇的目錄的選中版本,建立一個全新副本。它彈出對話方塊,讓你確認URL和版本,並且選擇儲存的位置。
匯出選擇的檔案/目錄的選中版本。它彈出對話方塊,讓你確認URL和版本,選擇匯出位置。
編輯之前提交時的日誌資訊或是作者。請閱讀“修改日誌訊息和作者”一節,瞭解其工作原理。
將選中版本的詳細日誌資訊複製到剪貼簿。它會複製版本號碼,作者,日期,日誌資訊,以及每個版本的改變項目列表。
在日誌資訊中搜尋你輸入的的文字。這個操作搜尋日誌資訊,也搜尋由Subversion建立的提交行為總結(最底部的面板中的內容)。搜尋大小寫無關。
圖 5.17. 選種兩個版本的頂部面板的右鍵菜單
如果你使用Ctrl按鍵組合一次選中了兩個版本,右鍵菜單有所改變:
使用可視化差異比較工作比較兩個選中的版本。預設的比較工作是與TortoiseSVN一起提供的TortoiseMerge。
如果你是針對檔案夾選中這個選項,則會彈出一個對話方塊列出修改過的檔案,提供了更多的差異比較選項。請參考比較版本對話方塊獲得詳情: “比較檔案夾”一節。
Blame the two revisions and compare the blame reports using a visual difference tool. Read “追溯不同點”一節 for more detail.
使用單一差異檔案顯示差異。這對檔案和檔案夾都有效。
如前所述將日誌訊息複製到剪貼簿。
如前所述可以搜尋日誌訊息。
If you select two or more revisions (using the usual Ctrl or Shift modifiers), the context menu will include an entry to Revert all changes which were made in the selected revisions. This is the easiest way to rollback a group of revisions in one go.
You can also choose to merge the selected revisions to another working copy, as described above.
圖 5.18. 日誌對話方塊的底部面板的右鍵菜單
日誌對話方塊的底部面板也有右鍵菜單,你可以:
Show changes made in the selected revision for the selected file. This context menu is only available for files shown as modified.
Blame the selected revision and the previous revision for the selected file, and compare the blame reports using a visual diff tool. Read “追溯不同點”一節 for more detail.
用預設查看器或你指定的程式開啟選中檔案的選中版本。
還原選中檔案的選中版本所作的變更。
查看選中項的Subversion屬性。
顯示選中的單個檔案的版本日誌。
將選中的版本儲存成檔案,你可以得到一份該檔案的舊版本。
提示
你可能會注意到,我們有時候說改變,有時候說差異。它們的區別在哪兒?
Subversion uses revision numbers to mean 2 different things. A revision generally represents the state of the repository at a point in time, but it can also be used to represent the changeset which created that revision, eg. “Done in r1234” means that the changes committed in r1234 implement feature X. To make it clearer which sense is being used, we use two different terms.
如果你選擇了兩個版本 N 和 M,操作功能表會顯示這兩個版本的差異。用 Subversion 術語說,就是diff -r M:N。
如果你選擇了一個版本 N,操作功能表會顯示這個版本的改變。用 Subversion 術語說,就是diff -r N-1:N 或 diff -c N。
The bottom pane shows the files changed in all selected revisions, so the context menu always offers to show changes.
擷取更多的日誌資訊
日誌對話方塊並不總是顯示所有曾經的修改,日誌不顯示的可能原因如下:
對於一個大的庫,可能存在幾百上千個改動,全部得到它們可能要花上很久的時間。通常你只關心最近的修改。預設情況下,日誌訊息限制只擷取100條,但你可以在TortoiseSVN → 設定中修改這個值 (“TortoiseSVN的設定”一節),
當複製/重新命名時停止複選框被選中時, 如果選中的檔案或檔案夾是從版本庫中的其他地方複製而來的,顯示日誌將停止在該點。這對於查看分支(或標記)時很有用,因為它會停在分支的根節點上,可以快速查看該分支的修改。
一般情況下你可以不要勾選它。 TortoiseSVN會記住它的狀態,以改進效能。
如果你在從合併交談框中調用的顯示日誌對話方塊,那麼這個複選框預設將總是選中的。這是由於合并通常都是查看分支中的修改, 擷取分支的根之前的日誌在這種情況下通常沒有什麼意義。
注意,Subversion當前是用複製/刪除來實現重新命名的,所以重新命名一個檔案或檔案夾也會造成日誌顯示停止(如果選擇了複製/重新命名時停止)在該點。
如果你要查看更多的日誌資訊,點擊下100個,以擷取下100個日誌資訊。如果有需要你可以多次重複這個操作。
這個按鈕旁邊的是一個多功能按鈕,它可以記住上一次你要它進行的操作。點擊它上面的箭頭,可以看到更多的選項。
如果你要查詢指定範圍的版本,使用顯示範圍 ...。這會出現一個對話方塊,要求輸入開始和結束的版本。
如果你要查詢從最新版本直到版本1的所有的日誌訊息,使用顯示所有。
合并跟蹤特性
Subversion 1.5 and later keeps a record of merges using properties. This allows us to get a more detailed history of merged changes. For example, if you develop a new feature on a branch and then merge that branch back to trunk, the feature development will show up on the trunk log as a single commit for the merge, even though there may have been 1000 commits during branch development.
圖 5.19. 日誌對話方塊顯示合并跟蹤版本
If you want to see the detail of which revisions were merged as part of that commit, use the Include merged revisions checkbox. This will fetch the log messages again, but will also interleave the log messages from revisions which were merged. Merged revisions are shown in grey because they represent changes made on a different part of the tree.
Of course, merging is never simple! During feature development on the branch there will probably be occasional merges back from trunk to keep the branch in sync with the main line code. So the merge history of the branch will also include another layer of merge history. These different layers are shown in the log dialog using indentation levels.
修改日誌訊息和作者
有時你可能想要修改你曾經輸入的日誌訊息,也許是因為有拼字錯誤或是你想改進訊息內容,或是其他別的原因。偶爾你還想修改提交者,可能是你忘了設定認證等原因。
Subversion lets you change both the log message and the author of revisions any time you want. But since such changes can't be undone (those changes are not versioned) this feature is disabled by default. To make this work, you must set up a pre-revprop-change hook. Please refer to the chapter on Hook Scripts in the Subversion Book for details about how to do that. Read “鉤子指令碼”一節 to find some further notes on implementing hooks on a Windows machine.
一旦你按需要為伺服器設定了鉤子,你就可以使用日誌對話方塊頂部面板的右鍵菜單來修改任意版本的作者和日誌資訊了。
警告
由於Subversion的版本屬性不受版本控制,對於這種屬性的修改(如 svn:log提交資訊屬性將永久覆蓋該屬性之前的值。
過濾日誌資訊
如果你只想要顯示上千條日誌中你所感興趣的日誌,你可以使用日誌對話方塊頂部的過濾器控制項。開始和結束日期控制項允許你查看指定日期範圍內的輸出。尋找框幫你查出含有指定內容的資訊。
Click on the search icon to select which information you want to search in, and to choose regex mode. Normally you will only need a simple text search, but if you need to more flexible search terms, you can use regular expressions. If you hover the mouse over the box, a tooltip will give hints on how to use the regex functions. You can also find online documentation and a tutorial at http://www.regular-expressions.info/.
要注意的是,這些過濾器只對已經擷取的資訊有效。它們並不從版本庫中下載資訊。
You can also filter the path names in the bottom pane using the Hide unrelated changed paths checkbox. Related paths are those which contain the path used to display the log. If you fetch the log for a folder, that means anything in that folder or below it. For a file it means just that one file. The checkbox is tristate: you can show all paths, grey out the unrelated ones, or hide the unrelated paths completely.
Sometimes your working practices will require log messages to follow a particular format, which means that the text describing the changes is not visible in the abbreviated summary shown in the top pane. The property tsvn:logsummary can be used to extract a portion of the log message to be shown in the top pane. Read “TortoiseSVN 項目屬性”一節 to find out how to use this property.
統計資訊
統計按扭,可以顯示一些你感興趣的關於日誌對話方塊中版本的資訊。可以顯示已經有幾個作者做了工作,他們各提交了幾次,按周的統計,等等。現在,你可以發現一個大概情況: 誰最勤快,誰偷懶。;-)
統計頁
此頁可以提供所有你可以想到的資料,特別是周期和包括的版本數,還有一些最大/最小/平均值。
作者提交次數統計頁
圖 5.20. 作者提交次數統計柱狀圖
此圖用簡單柱狀圖、疊加柱狀圖或餅圖顯示了哪些作者已經在項目中活躍了。
圖 5.21. 作者提交次數統計餅圖
Where there are a few major authors and many minor contributors, the number of tiny segments can make the graph more difficult to read. The slider at the bottom allows you to set a threshold (as a percentage of total commits) below which any activity is grouped into an Others category.
按日期提交統計頁
圖 5.22. 按日期提交統計圖
本頁圖示了以提交次數和作者作為條件的項目行為統計。這裡可以看出項目什麼時候有人在工作,以及什麼人在什麼時候進行了工作。
如果有多個作者,你就會在圖中看到多行。有兩種視圖可用正常,在這裡,每個作者的行為都相對於基準;疊加,在這裡每個作者的行為是相對於他的下面那條線。後一種視圖避免了線的交叉,對於圖來說更明了,但對查看一個作者的輸出比較不直觀。
By default the analysis is case-sensitive, so users PeterEgan and PeteRegan are treated as different authors. However, in many cases user names are not case-sensitive, and are sometimes entered inconsistently, so you may want DavidMorgan and davidmorgan to be treated as the same person. Use the Authors case insensitive checkbox to control how this is handled.
注意,統計只包括了日誌對話方塊中的那段時期。如果日誌對話方塊中只顯示一個版本,那麼統計就沒有什麼意義了。
離線方式
If the server is not reachable, and you have log caching enabled you can use the log dialog and revision graph in offline mode. This uses data from the cache, which allows you to continue working although the information may not be up-to-date or even complete.
重新整理視圖
If you want to check the server again for newer log messages, you can simply refresh the view using F5. If you are using the log cache (enabled by default), this will check the repository for newer messages and fetch only the new ones. If the log cache was in offline mode, this will also attempt to go back online.
If you are using the log cache and you think the message content or author may have changed, you can use Shift-F5 or Ctrl-F5 to re-fetch the displayed messages from the server and update the log cache. Note that this only affects messages currently shown and does not invalidate the entire cache for that repository.