我想檢查一個同事的補丁。我們無法使用評論工具。所以我想評論他所做的補丁文件。是否可以將內聯註釋寫入(svn)修補程序文件?如何在補丁/ diff文件中寫評論?
我在svn紅皮書上找不到任何信息。我甚至無法找到補丁文件語法來自己弄清楚。
我想檢查一個同事的補丁。我們無法使用評論工具。所以我想評論他所做的補丁文件。是否可以將內聯註釋寫入(svn)修補程序文件?如何在補丁/ diff文件中寫評論?
我在svn紅皮書上找不到任何信息。我甚至無法找到補丁文件語法來自己弄清楚。
diff格式只是unified diff format。如果你想要,你可以在範圍信息後面加上一些文字。考慮這種差異與命令svn diff -c 1544711 https://svn.apache.org/repos/asf/subversion/trunk
生產:
Index: subversion/mod_dav_svn/mod_dav_svn.c
===================================================================
--- subversion/mod_dav_svn/mod_dav_svn.c (revision 1544710)
+++ subversion/mod_dav_svn/mod_dav_svn.c (revision 1544711)
@@ -1097,7 +1097,8 @@
/* Fill the filename on the request with a bogus path since we aren't serving
* a file off the disk. This means that <Directory> blocks will not match and
- * that %f in logging formats will show as "svn:/path/to/repo/path/in/repo". */
+ * %f in logging formats will show as "dav_svn:/path/to/repo/path/in/repo".
+ */
static int dav_svn__translate_name(request_rec *r)
{
const char *fs_path, *repos_basename, *repos_path;
@@ -1146,7 +1147,7 @@
if (repos_path && '/' == repos_path[0] && '\0' == repos_path[1])
repos_path = NULL;
- /* Combine 'svn:', fs_path and repos_path to produce the bogus path we're
+ /* Combine 'dav_svn:', fs_path and repos_path to produce the bogus path we're
* placing in r->filename. We can't use our standard join helpers such
* as svn_dirent_join. fs_path is a dirent and repos_path is a fspath
* (that can be trivially converted to a relpath by skipping the leading
@@ -1154,7 +1155,7 @@
* repository is 'trunk/c:hi' this results in a non canonical dirent on
* Windows. Instead we just cat them together. */
r->filename = apr_pstrcat(r->pool,
- "svn:", fs_path, repos_path, SVN_VA_NULL);
+ "dav_svn:", fs_path, repos_path, SVN_VA_NULL);
/* Leave a note to ourselves so that we know not to decline in the
* map_to_storage hook. */
如果添加選項-x-p
該命令,你會得到:
Index: subversion/mod_dav_svn/mod_dav_svn.c
===================================================================
--- subversion/mod_dav_svn/mod_dav_svn.c (revision 1544710)
+++ subversion/mod_dav_svn/mod_dav_svn.c (revision 1544711)
@@ -1097,7 +1097,8 @@ static int dav_svn__handler(request_rec *r)
/* Fill the filename on the request with a bogus path since we aren't serving
* a file off the disk. This means that <Directory> blocks will not match and
- * that %f in logging formats will show as "svn:/path/to/repo/path/in/repo". */
+ * %f in logging formats will show as "dav_svn:/path/to/repo/path/in/repo".
+ */
static int dav_svn__translate_name(request_rec *r)
{
const char *fs_path, *repos_basename, *repos_path;
@@ -1146,7 +1147,7 @@ static int dav_svn__translate_name(request_rec *r)
if (repos_path && '/' == repos_path[0] && '\0' == repos_path[1])
repos_path = NULL;
- /* Combine 'svn:', fs_path and repos_path to produce the bogus path we're
+ /* Combine 'dav_svn:', fs_path and repos_path to produce the bogus path we're
* placing in r->filename. We can't use our standard join helpers such
* as svn_dirent_join. fs_path is a dirent and repos_path is a fspath
* (that can be trivially converted to a relpath by skipping the leading
@@ -1154,7 +1155,7 @@ static int dav_svn__translate_name(request_rec *r)
* repository is 'trunk/c:hi' this results in a non canonical dirent on
* Windows. Instead we just cat them together. */
r->filename = apr_pstrcat(r->pool,
- "svn:", fs_path, repos_path, SVN_VA_NULL);
+ "dav_svn:", fs_path, repos_path, SVN_VA_NULL);
/* Leave a note to ourselves so that we know not to decline in the
* map_to_storage hook. */
注意函數是怎麼@@
的行範圍後添加。這部分行被任何處理diff的軟件忽略。所以你可以放任何你想要的東西。你可以在那裏發表你的評論。
Unidiff大塊開始' '
(空間)的每一行來表示上下文(如在未改變線),'+'
爲是指添加的行,或'-'
爲是指除去線。很多解析器(包括Subversion的svn補丁命令)會放棄以其他字符開頭的行。所以你可能只需插入一行以其他字符開頭的行。但這並不能保證像上述方法一樣便攜。
+1我想補充一點,使用'@@@'進行評論是有用的,這樣評論中可能包含的任何內容都不會被'patch'意外解析爲重要。 –
這實際上並不是SVN特有的,可以和任何'.patch' /'.diff'文件一起使用。所以我刪除了SVN標籤,以更明顯的方式讓更多用戶瞭解它。 –