quilt 使用积累

1, 基本概念

掌握quilt的关键是了解使用quilt的流程。使用quilt时,我们会在一个完整的源代码树里工作。只要我们在源代码树里使用了quilt命令,quilt就会在源代码树的根目录建立两个特殊目录:patches和.pc。quilt在patches目录保存它管理的所有补丁。quilt用.pc目录保存自己的内部工作状态,用户不需要了解这个目录。

patches/series文件记录了quilt当前管理的补丁。补丁按照加入的顺序排列,早加入的补丁在前。quilt用堆栈的概念管理补丁的应用。

quilt 使用积累_第1张图片

我们在应用补丁A前,必须先应用所有早于补丁A的补丁。所以,patches/series中的补丁总是从上向下应用。

例如:上图中,补丁1到补丁5是已经应用的补丁。我们可以将已应用的补丁想象成一个向下生长的堆栈,栈顶就是已应用的最新补丁。应用补丁就是将补丁入栈,撤销补丁就是将补丁出栈。

我们在源代码树中作任何修改前,必须用"quilt add"命令将要修改的文件与一个补丁联系起来。在完成修改后,用"quilt refresh"命令将修改保存到已联系的补丁。

2,实例:  导入补丁

-bash-4.1$ pwd
/extra/chkq76/DEV_telia42_overblue/applications/3pp/ekioh-webkit/opensource

我们可以用applied命令查询当前已应用的补丁。
-bash-4.1$ quilt applied
No patches applied

unapplied命令查询当前还没有应用的补丁,
-bash-4.1$ quilt unapplied
patches/host_build_fixes.patch
patches/comment_away_dead_code.patch

top命令查询栈顶补丁,即已应用的最新补丁:
-bash-4.1$ quilt top
No patches applied

我们可以使用push命令应用补丁,例如:

$ quilt push -a

push的"-a"参数表示应用所有补丁。

在使用push命令后,prj 目录会多了一个叫.pc的隐含子目录。quilt用这个目录保存内部状态,用户不需要了解这个目录。应用补丁后,我们再使用applied、unapplied和top命令查看:


3, 实例: 修改文件

我们必须将对源代码树所作的任何改动都和一个补丁联系起来。add命令将文件的当前状态与补丁联系起来。add命令的格式为:

quilt add [-P 补丁名] 文件名

如果未指定补丁名,文件就与栈顶补丁联系起来。目前,我们的栈顶补丁是官方补丁。我们不想修改这个补丁,可以用new命令新建一个补丁:

-bash-4.1$ quilt new  merge_test.patch
Patch patches/merge_test.patch is now on top
-bash-4.1$quilt top
patches/merge_test.patch

现在多了一个.pc文件夹与两个文件

-bash-4.1$ cd .pc/
-bash-4.1$ ll
total 8
-rw-r--r--. 1 chkq76 512   17 Sep  1 17:16 applied-patches
drwxr-xr-x. 2 chkq76 512 4096 Sep  1 17:16 merge_test.patch
-bash-4.1$ cat applied-patches
merge_test.patch
-bash-4.1$ quilt applied
patches/merge_test.patch

然后用add命令向栈顶补丁添加一个准备修改的文件:

-bash-4.1$quilt addsrc/3rdParty/webkit/work/WebCore/page/FocusController.h
File src/3rdParty/webkit/work/WebCore/page/FocusController.h added to patch patches/merge_test.patch

-bash-4.1$ls -la .pc/merge_test.patch/src/3rdParty/webkit/work/WebCore/page/FocusController.h
-rw-r--r--. 1 chkq76 512 2387 Jan 29  2010 .pc/merge_test.patch/src/3rdParty/webkit/work/WebCore/page/FocusCo
ntroller.h

add命令为指定补丁保存了指定文件的当前快照,当我们执行refresh命令时,quilt就会检查文件的变化,将差异保存到指定补丁中。使用"quilt diff -z [-P 补丁名] [文件名]"可以查看指定补丁指定文件的当前改动。省略-P参数表示查看当前补丁的改动,省略文件名表示查看所有改动。我们修改drv2.h后,执行diff命令:

-bash-4.1$ quilt diff -z
-bash-4.1$ quilt diff
-bash-4.1$ vim src/3rdParty/webkit/work/WebCore/page/FocusController.h
-bash-4.1$ quilt diff
Index: opensource/src/3rdParty/webkit/work/WebCore/page/FocusController.h
===================================================================
--- opensource.orig/src/3rdParty/webkit/work/WebCore/page/FocusController.h
+++ opensource/src/3rdParty/webkit/work/WebCore/page/FocusController.h
@@ -55,7 +55,7 @@ namespace WebCore {

         void setFocused(bool);
         bool isFocused() const { return m_isFocused; }
-
+leosu  test!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! quilt test
     private:
         Page* m_page;
         RefPtr<Frame> m_focusedFrame;


只要文件已经与我们希望保存改动的补丁联系过了,我们就可以多次修改文件。

使用"quilt files [补丁名]"命令可以查看与指定补丁关联的文件。使用"quilt files -val"可以查看所有补丁联系的所有文件。"-v"参数表示更友好的显示,"-a"参数表示显示所有补丁,"-l"参数显示补丁名。例如:

-bash-4.1$ quilt files
src/3rdParty/webkit/work/WebCore/page/FocusController.h

"quilt refresh [补丁名]"刷新补丁,即将指定补丁的文件变化保存到补丁。省略文件名表示刷新栈顶补丁。我们refresh后,查看补丁文件:

-bash-4.1$ quilt refresh
Refreshed patch patches/merge_test.patch
-bash-4.1$ cat patches/merge_test.patch
Index: opensource/src/3rdParty/webkit/work/WebCore/page/FocusController.h
===================================================================
--- opensource.orig/src/3rdParty/webkit/work/WebCore/page/FocusController.h
+++ opensource/src/3rdParty/webkit/work/WebCore/page/FocusController.h
@@ -55,7 +55,7 @@ namespace WebCore {

         void setFocused(bool);
         bool isFocused() const { return m_isFocused; }
-
+leosu  test!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! quilt test
     private:
         Page* m_page;
         RefPtr<Frame> m_focusedFrame;

"quilt diff -z"命令不会显示已经保存的差异。"quilt diff"显示所有的差异,不管是否保存过。

-bash-4.1$ quilt diff
Index: opensource/src/3rdParty/webkit/work/WebCore/page/FocusController.h
===================================================================
--- opensource.orig/src/3rdParty/webkit/work/WebCore/page/FocusController.h
+++ opensource/src/3rdParty/webkit/work/WebCore/page/FocusController.h
@@ -55,7 +55,7 @@ namespace WebCore {

         void setFocused(bool);
         bool isFocused() const { return m_isFocused; }
-
+leosu  test!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! quilt test
     private:
         Page* m_page;
         RefPtr<Frame> m_focusedFrame;
-bash-4.1$ quilt diff -z
-bash-4.1$


4, 实例: 添加/删除文件

-bash-4.1$quilt add  src/3rdParty/webkit/work/WebCore/page/FocusController.h___bak
File src/3rdParty/webkit/work/WebCore/page/FocusController.h___bak added to patch patches/merge_test.patch
-bash-4.1$ll  .pc/merge_test.patch/src/3rdParty/webkit/work/WebCore/page/FocusController.*
-rw-r--r--. 1 chkq76 512 2387 Jan 29  2010 .pc/merge_test.patch/src/3rdParty/webkit/work/WebCore/page/FocusController.h
----------. 1 chkq76 512    0 Sep  1 17:33 .pc/merge_test.patch/src/3rdParty/webkit/work/WebCore/page/FocusController.h___bak   //new add file

-bash-4.1$ quilt files
src/3rdParty/webkit/work/WebCore/page/FocusController.h
src/3rdParty/webkit/work/WebCore/page/FocusController.h___bak  //new add file

-bash-4.1$ vim  src/3rdParty/webkit/work/WebCore/page/FocusController.h___bak

-bash-4.1$ quilt refresh
Refreshed patch patches/merge_test.patch

再次编辑文件

-bash-4.1$ quilt edit src/3rdParty/webkit/work/WebCore/page/FocusController.h___bak
File src/3rdParty/webkit/work/WebCore/page/FocusController.h___bak is already in patch patches/merge_test.patch
-bash-4.1$ quilt refresh

哎呀,文件名写错了。我们可以用"remove"命令从补丁中删除关联文件

【注意,没有remove文件】,如果不小心多quilt add添加了一个文件,如果没有变化,用quilt refresh的时候,则此内容不会出现在patchs/***里面;  所以remove 命令没有必要;


5, 实例: 管理补丁

quilt series 查看所有series里面的文件内容

$ quilt series


"quilt patches 文件名"显示修改了指定文件的所有补丁,例如:

-bash-4.1$ quilt patches src/3rdParty/webkit/work/WebCore/page/FocusController.h
patches/merge_test.patch

"quilt annotate 文件名"显示指定文件的修改情况,它会指出哪个补丁修改了哪一行。例如:

-bash-4.1$ quilt annotate src/3rdParty/webkit/work/WebCore/page/FocusController.h
1      leosu  test!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! quilt test
            private:
                Page* m_page;
                RefPtr<Frame> m_focusedFrame;
                bool m_isActive;
                bool m_isFocused;
            };

        } // namespace WebCore
           
        #endif // FocusController_h

1       patches/merge_test.patch

我们可以使用push和pop命令应用补丁或撤销补丁,例如:

$ quilt pop -a

-bash-4.1$ quilt top
patches/merge_test.patch

"quilt pop -a"撤销所有补丁。

top命令显示栈顶命令,即当前应用的最新的补丁。

next命令显示下一个可以应用的补丁。

previous显示上一条应用过的补丁。

"push 补丁A"将从上到下依次应用所有早于补丁A的补丁,最后应用补丁A。

-bash-4.1$ quilt top
patches/merge_test.patch
-bash-4.1$ quilt pop  -a    #########此时补丁文件patches/merge_test.patch还是存在的!!!!! 只不过不在 .pc 文件夹里面了!!
Removing patch patches/merge_test.patch
Removing src/3rdParty/webkit/work/WebCore/page/FocusController.h___bak
Restoring src/3rdParty/webkit/work/WebCore/page/FocusController.h

No patches applied

-bash-4.1$quilt top
No patches applied

-bash-4.1$  quilt next
patches/merge_test.patch
-bash-4.1$ quilt previous
No patches applied

bash-4.1$ quilt push patches/merge_test.patch
Applying patch patches/merge_test.patch
patching file src/3rdParty/webkit/work/WebCore/page/FocusController.h
patching file src/3rdParty/webkit/work/WebCore/page/FocusController.h___bak

Now at patch patches/merge_test.patch
-bash-4.1$ quilt top
patches/merge_test.patch

删除补丁:

-bash-4.1$ quilt delete
Removing patch patches/merge_test.patch
No patches applied
Removed patch patches/merge_test.patch
-bash-4.1$ quilt top
No patches applied
-bash-4.1$ quilt files
No patches applied

revert 某个修改的文件(包括所有patch里面的此文件的变更):

-bash-4.1$ quilt revert src/3rdParty/webkit/work/JavaScriptCore/interpreter/Interpre999999999999.txt
Changes to src/3rdParty/webkit/work/JavaScriptCore/interpreter/Interpre999999999999.txt in patch patches/testttttttttttt.patch reverted

revert某个patch的某个文件:

-bash-4.1$ quilt revert -P patches/testttttttttttt.patch  src/3rdParty/webkit/work/JavaScriptCore/interpreter/Interpre999999999999.txt
File src/3rdParty/webkit/work/JavaScriptCore/interpreter/Interpre999999999999.txt is unchanged

 

你可能感兴趣的:(quilt 使用积累)