📄 main.tex
字号:
location.While patches are applied to the source tree, the \textsf{.pc} directoryis essential for many operations, including taking patches off the stack(\quilt{pop}), and refreshing patches (\quilt{refresh}). Files in the\textsf{.pc} directory are automatically removed when they are no longerneeded, so usually there is no need to clean up manually. The\textsf{QUILT\_PC} environment variable can be used to override thelocation of the \textsf{.pc} directory.\section{An Example}This section demonstrates how new patches are created and updated, andhow conflicts are resolved. Let's start with a short text file:\begin{small}\begin{Verbatim}Yet mark'd I where the bolt of Cupid fell:It fell upon a little western flower,Before milk-white, now purple with love's wound,And girls call it love-in-idleness.\end{Verbatim}\end{small}New patches are created with \quilt{new}. A new patch automaticallybecomes the topmost patch on the stack. Files must be addedwith \quilt{add} before they are modified. Note that this is slightlydifferent from the CVS style of interaction: with CVS, files are in therepository, and adding them before committing (but after modifying them)is enough. Files are usually added and immediately modified. Thecommand \quilt{edit} adds a file and loads it into the default editor.(The environment variable \textsf{EDITOR} specifies which is the defaulteditor. If \textsf{EDITOR} is not set, \prog{vi} is used.)\begin{small}\begin{Verbatim}\sh{$ quilt new flower.diff}Patch flower.diff is now on top\sh{$ quilt edit Oberon.txt}File Oberon.txt added to patch flower.diff\end{Verbatim}\end{small}Let's assume that the following lines were added to \textsf{Oberon.txt}during editing:\begin{small}\begin{Verbatim}The juice of it on sleeping eye-lids laidWill make a man or woman madly doteUpon the next live creature that it sees.\end{Verbatim}\end{small}The actual patch file is created (and later updated) with\quilt{refresh}. The result is as follows:\footnote{ Timestamps in patches are omitted from the output in the examples.}\begin{small}\begin{Verbatim}\sh{$ quilt refresh}\sh{$ cat patches/flower.diff}Index: example1/Oberon.txt===================================================================--- example1.orig/Oberon.txt+++ example1/Oberon.txt@@ -2,3 +2,6 @@ It fell upon a little western flower, Before milk-white, now purple with love's wound, And girls call it love-in-idleness.+The juice of it on sleeping eye-lids laid+Will make a man or woman madly dote+Upon the next live creature that it sees.\end{Verbatim}\end{small}Now let's assume that a line in the text has been overlooked, and mustbe inserted. The file \textsf{Oberon.txt} is already part of the patch\textsf{flower.diff}, so it can immediately be modified in an editor.Alternatively, \quilt{edit} can be used; it simply opens up the defaulteditor if the file is already part of the patch.After the line is added, we use \quilt{diff -z} to see a diff of thechanges we made:\begin{small}\begin{Verbatim}\sh{$ quilt diff -z}Index: example1/Oberon.txt===================================================================--- example1.orig/Oberon.txt+++ example1/Oberon.txt@@ -2,6 +2,7 @@ It fell upon a little western flower, Before milk-white, now purple with love's wound, And girls call it love-in-idleness.+Fetch me that flower; the herb I shew'd thee once: The juice of it on sleeping eye-lids laid Will make a man or woman madly dote Upon the next live creature that it sees.\end{Verbatim}\end{small}A diff of the topmost patch can be generated with \quilt{diff} withoutarguments. This does not modify the actual patch file. The changes areonly added to the patch file by updating it with \quilt{refresh}. Thenwe remove the patch from the stack with \quilt{pop}:\begin{small}\begin{Verbatim}\sh{$ quilt refresh}Refreshed patch flower.diff\sh{$ quilt pop}Removing flower.diffRestoring Oberon.txtNo patches applied\end{Verbatim}\end{small}Next, let's assume that \textsf{Oberon.txt} was modified ``upstream'':The word \textit{girl} did not fit very well, and so it was replacedwith \textit{maiden.} \textsf{Oberon.txt} now contains:\begin{small}\begin{Verbatim}Yet mark'd I where the bolt of Cupid fell:It fell upon a little western flower,Before milk-white, now purple with love's wound,And maidens call it love-in-idleness.\end{Verbatim}\end{small}This causes \textsf{flower.diff} to no longer apply cleanly. When wetry to push \textsf{flower.diff} on the stack with \quilt{push}, we getthe following result:\begin{small}\begin{Verbatim}\sh{$ quilt push}Applying flower.diffpatching file Oberon.txtHunk #1 FAILED at 2.1 out of 1 hunk FAILED -- rejects in file Oberon.txtPatch flower.diff does not apply (enforce with -f)\end{Verbatim}\end{small}Quilt does not automatically apply patches that have rejects. Patchesthat do not apply cleanly can be ``force-applied'' with \quilt{push -f},which leaves reject files in the source tree for each file that hasconflicts. Those conflicts must be resolved manually, after which thepatch can be updated (\quilt{refresh}). Quilt remembers when a patch hasbeen force-applied. It refuses to push further patches on top of suchpatches, and it does not remove them from the stack. A force-appliedpatch may be ``force-removed'' from the stack with \quilt{pop -f},however. Here is what happens when force-applying \textsf{flower.diff}:\begin{small}\begin{Verbatim}\sh{$ quilt push -f}Applying flower.diffpatching file Oberon.txtHunk #1 FAILED at 2.1 out of 1 hunk FAILED -- saving rejects to file Oberon.txt.rejApplied flower.diff (forced; needs refresh)\end{Verbatim}\end{small}After re-adding the lines of verse from \textsf{flower.diff} to\textsf{Oberon.txt}, we update the patch with \quilt{refresh}.\begin{small}\begin{Verbatim}\sh{$ quilt edit Oberon.txt}\sh{$ quilt refresh}Refreshed patch flower.diff\end{Verbatim}\end{small}Our final version of \textsf{Oberon.txt} contains:\begin{small}\begin{Verbatim}Yet mark'd I where the bolt of Cupid fell:It fell upon a little western flower,Before milk-white, now purple with love's wound,And maidens call it love-in-idleness.Fetch me that flower; the herb I shew'd thee once:The juice of it on sleeping eye-lids laidWill make a man or woman madly doteUpon the next live creature that it sees.\end{Verbatim}\end{small}\section{Further Commands and Concepts}This section introduces a few more basic commands, and then describesadditional concepts that may not be immediately obvious. We do notdescribe all of the features of quilt here since many quilt commands arequite intuitive; furthermore, help text that describes the availableoptions for each command is available via \quilt{\textit{cmd} -h}.The \quilt{top} command shows the name of the topmost patch. The\quilt{files} command shows which files a patch contains. The\quilt{patches} command shows which patches modify a specified file.With our previous example, we get the following results:\begin{small}\begin{Verbatim}\sh{$ quilt top}flower.diff\sh{$ quilt files}Oberon.txt\sh{$ quilt patches Oberon.txt}flower.diff\end{Verbatim}\end{small}The \quilt{push} and \quilt{pop} commands optionally take a number ora patch name as argument. If a number is given, the specified number ofpatches is added (\quilt{push}) or removed (\quilt{pop}). If a patchname is given, patches are added (\quilt{push}) or removed (\quilt{pop})until the specified patch is on top of the stack. With the \textsf{-a}option, all patches in the series file are added (\quilt{push}), or allapplied patches are removed from the stack (\quilt{pop}).\subsection{Patch Strip Levels}Quilt assumes that patches are applied with a strip level of one (the\textsf{-p1} option of \prog{GNU patch}) by default: the topmost directorylevel of file names in patches is stripped off. Quilt remembers thestrip level of each patch in the \textsf{series} file. When generating adiff (\quilt{diff}) or updating a patch (\quilt{refresh}), a differentstrip level can be specified, and the series file will be updatedaccordingly. Quilt can apply patches with an arbitrary strip level, andproduces patches with a strip level of zero or one. With a strip levelof one, the name of the directory that contains the working tree is usedas the additional path component. (So in our example,\textsf{Oberon.txt} is contained in directory \textsf{example1}.) \subsection{Importing Patches}The \quilt{import} command automates the importing of patches into thequilt system. The command copies a patch into the \textsf{patches}directory and adds it to the \textsf{series} file. For patch striplevels other than one, the strip level is added after the patch filename. (An entry for \textsf{a.diff} with strip level zero might read``{\small \verb|a.diff -p0|}''.)Another common operation is to incorporate a fix or similar that comesas a patch into the topmost patch. This can be done by hand by firstadding all the files contained in the additional patch to the topmostpatch with \quilt{add},\footnote{ The \prog{lsdiff} utility, which is part of the \textit{patchutils} package, generates a list of files affected by a patch.} and then applying the patch to the working tree. The \quilt{fold}command combines these steps.\subsection{Sharing patches with others}For sharing a set of patches with someone else, the series file whichcontains the list of patches and how they are applied, and the patches
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -