hgbook

diff en/mq.tex @ 233:696b1e0c01df

Tag all MQ commands as belonging to the mq extension.
author Bryan O'Sullivan <bos@serpentine.com>
date Sun May 27 09:41:55 2007 -0700 (2007-05-27)
parents 28ddbf9f3729
children 30e97616d808
line diff
     1.1 --- a/en/mq.tex	Sun May 27 09:39:58 2007 -0700
     1.2 +++ b/en/mq.tex	Sun May 27 09:41:55 2007 -0700
     1.3 @@ -227,7 +227,7 @@
     1.4  
     1.5  Once the extension is enabled, it will make a number of new commands
     1.6  available.  To verify that the extension is working, you can use
     1.7 -\hgcmd{help} to see if the \hgcmd{qinit} command is now available; see
     1.8 +\hgcmd{help} to see if the \hgxcmd{mq}{qinit} command is now available; see
     1.9  the example in figure~\ref{ex:mq:enabled}.
    1.10  
    1.11  \begin{figure}[ht]
    1.12 @@ -238,10 +238,10 @@
    1.13  
    1.14  You can use MQ with \emph{any} Mercurial repository, and its commands
    1.15  only operate within that repository.  To get started, simply prepare
    1.16 -the repository using the \hgcmd{qinit} command (see
    1.17 +the repository using the \hgxcmd{mq}{qinit} command (see
    1.18  figure~\ref{ex:mq:qinit}).  This command creates an empty directory
    1.19  called \sdirname{.hg/patches}, where MQ will keep its metadata.  As
    1.20 -with many Mercurial commands, the \hgcmd{qinit} command prints nothing
    1.21 +with many Mercurial commands, the \hgxcmd{mq}{qinit} command prints nothing
    1.22  if it succeeds.
    1.23  
    1.24  \begin{figure}[ht]
    1.25 @@ -258,7 +258,7 @@
    1.26  
    1.27  \subsection{Creating a new patch}
    1.28  
    1.29 -To begin work on a new patch, use the \hgcmd{qnew} command.  This
    1.30 +To begin work on a new patch, use the \hgxcmd{mq}{qnew} command.  This
    1.31  command takes one argument, the name of the patch to create.  MQ will
    1.32  use this as the name of an actual file in the \sdirname{.hg/patches}
    1.33  directory, as you can see in figure~\ref{ex:mq:qnew}.
    1.34 @@ -286,7 +286,7 @@
    1.35  \subsection{Refreshing a patch}
    1.36  
    1.37  When you reach a point where you want to save your work, use the
    1.38 -\hgcmd{qrefresh} command (figure~\ref{ex:mq:qnew}) to update the patch
    1.39 +\hgxcmd{mq}{qrefresh} command (figure~\ref{ex:mq:qnew}) to update the patch
    1.40  you are working on.  This command folds the changes you have made in
    1.41  the working directory into your patch, and updates its corresponding
    1.42  changeset to contain those changes.
    1.43 @@ -297,7 +297,7 @@
    1.44    \label{ex:mq:qrefresh}
    1.45  \end{figure}
    1.46  
    1.47 -You can run \hgcmd{qrefresh} as often as you like, so it's a good way
    1.48 +You can run \hgxcmd{mq}{qrefresh} as often as you like, so it's a good way
    1.49  to ``checkpoint'' your work.  Refresh your patch at an opportune
    1.50  time; try an experiment; and if the experiment doesn't work out,
    1.51  \hgcmd{revert} your modifications back to the last time you refreshed.
    1.52 @@ -311,7 +311,7 @@
    1.53  \subsection{Stacking and tracking patches}
    1.54  
    1.55  Once you have finished working on a patch, or need to work on another,
    1.56 -you can use the \hgcmd{qnew} command again to create a new patch.
    1.57 +you can use the \hgxcmd{mq}{qnew} command again to create a new patch.
    1.58  Mercurial will apply this patch on top of your existing patch.  See
    1.59  figure~\ref{ex:mq:qnew2} for an example.  Notice that the patch
    1.60  contains the changes in our prior patch as part of its context (you
    1.61 @@ -323,24 +323,24 @@
    1.62    \label{ex:mq:qnew2}
    1.63  \end{figure}
    1.64  
    1.65 -So far, with the exception of \hgcmd{qnew} and \hgcmd{qrefresh}, we've
    1.66 +So far, with the exception of \hgxcmd{mq}{qnew} and \hgxcmd{mq}{qrefresh}, we've
    1.67  been careful to only use regular Mercurial commands.  However, MQ
    1.68  provides many commands that are easier to use when you are thinking
    1.69  about patches, as illustrated in figure~\ref{ex:mq:qseries}:
    1.70  
    1.71  \begin{itemize}
    1.72 -\item The \hgcmd{qseries} command lists every patch that MQ knows
    1.73 +\item The \hgxcmd{mq}{qseries} command lists every patch that MQ knows
    1.74    about in this repository, from oldest to newest (most recently
    1.75    \emph{created}).
    1.76 -\item The \hgcmd{qapplied} command lists every patch that MQ has
    1.77 +\item The \hgxcmd{mq}{qapplied} command lists every patch that MQ has
    1.78    \emph{applied} in this repository, again from oldest to newest (most
    1.79    recently applied).
    1.80  \end{itemize}
    1.81  
    1.82  \begin{figure}[ht]
    1.83    \interaction{mq.tutorial.qseries}
    1.84 -  \caption{Understanding the patch stack with \hgcmd{qseries} and
    1.85 -    \hgcmd{qapplied}}
    1.86 +  \caption{Understanding the patch stack with \hgxcmd{mq}{qseries} and
    1.87 +    \hgxcmd{mq}{qapplied}}
    1.88    \label{ex:mq:qseries}
    1.89  \end{figure}
    1.90  
    1.91 @@ -353,7 +353,7 @@
    1.92  An \emph{applied} patch has a corresponding changeset in the
    1.93  repository, and the effects of the patch and changeset are visible in
    1.94  the working directory.  You can undo the application of a patch using
    1.95 -the \hgcmd{qpop} command.  MQ still \emph{knows about}, or manages, a
    1.96 +the \hgxcmd{mq}{qpop} command.  MQ still \emph{knows about}, or manages, a
    1.97  popped patch, but the patch no longer has a corresponding changeset in
    1.98  the repository, and the working directory does not contain the changes
    1.99  made by the patch.  Figure~\ref{fig:mq:stack} illustrates the
   1.100 @@ -366,13 +366,13 @@
   1.101    \label{fig:mq:stack}
   1.102  \end{figure}
   1.103  
   1.104 -You can reapply an unapplied, or popped, patch using the \hgcmd{qpush}
   1.105 +You can reapply an unapplied, or popped, patch using the \hgxcmd{mq}{qpush}
   1.106  command.  This creates a new changeset to correspond to the patch, and
   1.107  the patch's changes once again become present in the working
   1.108 -directory.  See figure~\ref{ex:mq:qpop} for examples of \hgcmd{qpop}
   1.109 -and \hgcmd{qpush} in action.  Notice that once we have popped a patch
   1.110 -or two patches, the output of \hgcmd{qseries} remains the same, while
   1.111 -that of \hgcmd{qapplied} has changed.
   1.112 +directory.  See figure~\ref{ex:mq:qpop} for examples of \hgxcmd{mq}{qpop}
   1.113 +and \hgxcmd{mq}{qpush} in action.  Notice that once we have popped a patch
   1.114 +or two patches, the output of \hgxcmd{mq}{qseries} remains the same, while
   1.115 +that of \hgxcmd{mq}{qapplied} has changed.
   1.116  
   1.117  \begin{figure}[ht]
   1.118    \interaction{mq.tutorial.qpop}
   1.119 @@ -382,10 +382,10 @@
   1.120  
   1.121  \subsection{Pushing and popping many patches}
   1.122  
   1.123 -While \hgcmd{qpush} and \hgcmd{qpop} each operate on a single patch at
   1.124 +While \hgxcmd{mq}{qpush} and \hgxcmd{mq}{qpop} each operate on a single patch at
   1.125  a time by default, you can push and pop many patches in one go.  The
   1.126 -\hgopt{qpush}{-a} option to \hgcmd{qpush} causes it to push all
   1.127 -unapplied patches, while the \hgopt{qpop}{-a} option to \hgcmd{qpop}
   1.128 +\hgopt{qpush}{-a} option to \hgxcmd{mq}{qpush} causes it to push all
   1.129 +unapplied patches, while the \hgopt{qpop}{-a} option to \hgxcmd{mq}{qpop}
   1.130  causes it to pop all applied patches.  (For some more ways to push and
   1.131  pop many patches, see section~\ref{sec:mq:perf} below.)
   1.132  
   1.133 @@ -401,7 +401,7 @@
   1.134  anything, and fail if they find any modifications.  They do this to
   1.135  ensure that you won't lose any changes that you have made, but not yet
   1.136  incorporated into a patch.  Figure~\ref{ex:mq:add} illustrates this;
   1.137 -the \hgcmd{qnew} command will not create a new patch if there are
   1.138 +the \hgxcmd{mq}{qnew} command will not create a new patch if there are
   1.139  outstanding changes, caused in this case by the \hgcmd{add} of
   1.140  \filename{file3}.
   1.141  
   1.142 @@ -422,7 +422,7 @@
   1.143  
   1.144  \subsection{Working on several patches at once}
   1.145  
   1.146 -The \hgcmd{qrefresh} command always refreshes the \emph{topmost}
   1.147 +The \hgxcmd{mq}{qrefresh} command always refreshes the \emph{topmost}
   1.148  applied patch.  This means that you can suspend work on one patch (by
   1.149  refreshing it), pop or push to make a different patch the top, and
   1.150  work on \emph{that} patch for a while.
   1.151 @@ -433,9 +433,9 @@
   1.152  top of the first---changes the user interface to use the code you just
   1.153  added to the core.  If you notice a bug in the core while you're
   1.154  working on the UI patch, it's easy to fix the core.  Simply
   1.155 -\hgcmd{qrefresh} the UI patch to save your in-progress changes, and
   1.156 -\hgcmd{qpop} down to the core patch.  Fix the core bug,
   1.157 -\hgcmd{qrefresh} the core patch, and \hgcmd{qpush} back to the UI
   1.158 +\hgxcmd{mq}{qrefresh} the UI patch to save your in-progress changes, and
   1.159 +\hgxcmd{mq}{qpop} down to the core patch.  Fix the core bug,
   1.160 +\hgxcmd{mq}{qrefresh} the core patch, and \hgxcmd{mq}{qpush} back to the UI
   1.161  patch to continue where you left off.
   1.162  
   1.163  \section{More about patches}
   1.164 @@ -487,11 +487,11 @@
   1.165  
   1.166  If you receive a patch from someone that you want to add to your patch
   1.167  queue, and the patch needs a strip count other than one, you cannot
   1.168 -just \hgcmd{qimport} the patch, because \hgcmd{qimport} does not yet
   1.169 +just \hgxcmd{mq}{qimport} the patch, because \hgxcmd{mq}{qimport} does not yet
   1.170  have a \texttt{-p} option (see~\bug{311}).  Your best bet is to
   1.171 -\hgcmd{qnew} a patch of your own, then use \cmdargs{patch}{-p\emph{N}}
   1.172 +\hgxcmd{mq}{qnew} a patch of your own, then use \cmdargs{patch}{-p\emph{N}}
   1.173  to apply their patch, followed by \hgcmd{addremove} to pick up any
   1.174 -files added or removed by the patch, followed by \hgcmd{qrefresh}.
   1.175 +files added or removed by the patch, followed by \hgxcmd{mq}{qrefresh}.
   1.176  This complexity may become unnecessary; see~\bug{311} for details.
   1.177  \subsection{Strategies for applying a patch}
   1.178  
   1.179 @@ -557,7 +557,7 @@
   1.180  be completely successful, these inexact techniques naturally leave
   1.181  open the possibility of corrupting the patched file.  The most common
   1.182  cases typically involve applying a patch twice, or at an incorrect
   1.183 -location in the file.  If \command{patch} or \hgcmd{qpush} ever
   1.184 +location in the file.  If \command{patch} or \hgxcmd{mq}{qpush} ever
   1.185  mentions an offset or fuzz factor, you should make sure that the
   1.186  modified files are correct afterwards.  
   1.187  
   1.188 @@ -573,7 +573,7 @@
   1.189  
   1.190  \subsection{Handling rejection}
   1.191  
   1.192 -If \hgcmd{qpush} fails to apply a patch, it will print an error
   1.193 +If \hgxcmd{mq}{qpush} fails to apply a patch, it will print an error
   1.194  message and exit.  If it has left \sfilename{.rej} files behind, it is
   1.195  usually best to fix up the rejected hunks before you push more patches
   1.196  or do any further work.
   1.197 @@ -627,24 +627,24 @@
   1.198  \hgcmdargs{qpush}{\hgopt{qpush}{-a}} all 1,738 patches in 3.5 minutes,
   1.199  and \hgcmdargs{qpop}{\hgopt{qpop}{-a}} them all in 30 seconds.  (On a
   1.200  newer laptop, the time to push all patches dropped to two minutes.)  I
   1.201 -could \hgcmd{qrefresh} one of the biggest patches (which made 22,779
   1.202 +could \hgxcmd{mq}{qrefresh} one of the biggest patches (which made 22,779
   1.203  lines of changes to 287 files) in 6.6 seconds.
   1.204  
   1.205  Clearly, MQ is well suited to working in large trees, but there are a
   1.206  few tricks you can use to get the best performance of it.
   1.207  
   1.208  First of all, try to ``batch'' operations together.  Every time you
   1.209 -run \hgcmd{qpush} or \hgcmd{qpop}, these commands scan the working
   1.210 +run \hgxcmd{mq}{qpush} or \hgxcmd{mq}{qpop}, these commands scan the working
   1.211  directory once to make sure you haven't made some changes and then
   1.212 -forgotten to run \hgcmd{qrefresh}.  On a small tree, the time that
   1.213 +forgotten to run \hgxcmd{mq}{qrefresh}.  On a small tree, the time that
   1.214  this scan takes is unnoticeable.  However, on a medium-sized tree
   1.215  (containing tens of thousands of files), it can take a second or more.
   1.216  
   1.217 -The \hgcmd{qpush} and \hgcmd{qpop} commands allow you to push and pop
   1.218 +The \hgxcmd{mq}{qpush} and \hgxcmd{mq}{qpop} commands allow you to push and pop
   1.219  multiple patches at a time.  You can identify the ``destination
   1.220 -patch'' that you want to end up at.  When you \hgcmd{qpush} with a
   1.221 +patch'' that you want to end up at.  When you \hgxcmd{mq}{qpush} with a
   1.222  destination specified, it will push patches until that patch is at the
   1.223 -top of the applied stack.  When you \hgcmd{qpop} to a destination, MQ
   1.224 +top of the applied stack.  When you \hgxcmd{mq}{qpop} to a destination, MQ
   1.225  will pop patches until the destination patch is at the top.
   1.226  
   1.227  You can identify a destination patch using either the name of the
   1.228 @@ -668,7 +668,7 @@
   1.229  repository, and finally \hgcmdargs{qpush}{\hgopt{qpop}{-a}} your
   1.230  patches again.  MQ will stop pushing any time it runs across a patch
   1.231  that fails to apply during conflicts, allowing you to fix your
   1.232 -conflicts, \hgcmd{qrefresh} the affected patch, and continue pushing
   1.233 +conflicts, \hgxcmd{mq}{qrefresh} the affected patch, and continue pushing
   1.234  until you have fixed your entire stack.
   1.235  
   1.236  This approach is easy to use and works well if you don't expect
   1.237 @@ -700,13 +700,13 @@
   1.238    \hgcmdargs{update}{\hgopt{update}{-C}} to override the patches you
   1.239    have pushed.
   1.240  \item Merge all patches using \hgcmdargs{qpush}{\hgopt{qpush}{-m}
   1.241 -    \hgopt{qpush}{-a}}.  The \hgopt{qpush}{-m} option to \hgcmd{qpush}
   1.242 +    \hgopt{qpush}{-a}}.  The \hgopt{qpush}{-m} option to \hgxcmd{mq}{qpush}
   1.243    tells MQ to perform a three-way merge if the patch fails to apply.
   1.244  \end{enumerate}
   1.245  
   1.246  During the \hgcmdargs{qpush}{\hgopt{qpush}{-m}}, each patch in the
   1.247  \sfilename{series} file is applied normally.  If a patch applies with
   1.248 -fuzz or rejects, MQ looks at the queue you \hgcmd{qsave}d, and
   1.249 +fuzz or rejects, MQ looks at the queue you \hgxcmd{mq}{qsave}d, and
   1.250  performs a three-way merge with the corresponding changeset.  This
   1.251  merge uses Mercurial's normal merge machinery, so it may pop up a GUI
   1.252  merge tool to help you to resolve problems.
   1.253 @@ -725,7 +725,7 @@
   1.254  
   1.255  MQ commands that work with patches let you refer to a patch either by
   1.256  using its name or by a number.  By name is obvious enough; pass the
   1.257 -name \filename{foo.patch} to \hgcmd{qpush}, for example, and it will
   1.258 +name \filename{foo.patch} to \hgxcmd{mq}{qpush}, for example, and it will
   1.259  push patches until \filename{foo.patch} is applied.  
   1.260  
   1.261  As a shortcut, you can refer to a patch using both a name and a
   1.262 @@ -734,7 +734,7 @@
   1.263  after \texttt{bar.patch}''.
   1.264  
   1.265  Referring to a patch by index isn't much different.  The first patch
   1.266 -printed in the output of \hgcmd{qseries} is patch zero (yes, it's one
   1.267 +printed in the output of \hgxcmd{mq}{qseries} is patch zero (yes, it's one
   1.268  of those start-at-zero counting systems); the second is patch one; and
   1.269  so on
   1.270  
   1.271 @@ -789,7 +789,7 @@
   1.272  one place.
   1.273  
   1.274  \begin{itemize}
   1.275 -\item Normally, when you \hgcmd{qpop} a patch and \hgcmd{qpush} it
   1.276 +\item Normally, when you \hgxcmd{mq}{qpop} a patch and \hgxcmd{mq}{qpush} it
   1.277    again, the changeset that represents the patch after the pop/push
   1.278    will have a \emph{different identity} than the changeset that
   1.279    represented the hash beforehand.  See
   1.280 @@ -811,7 +811,7 @@
   1.281  This presents the interesting possibility of managing the contents of
   1.282  the patch directory as a Mercurial repository in its own right.  This
   1.283  can be a useful way to work.  For example, you can work on a patch for
   1.284 -a while, \hgcmd{qrefresh} it, then \hgcmd{commit} the current state of
   1.285 +a while, \hgxcmd{mq}{qrefresh} it, then \hgcmd{commit} the current state of
   1.286  the patch.  This lets you ``roll back'' to that version of the patch
   1.287  later on.
   1.288  
   1.289 @@ -833,7 +833,7 @@
   1.290  
   1.291  MQ helps you to work with the \sdirname{.hg/patches} directory as a
   1.292  repository; when you prepare a repository for working with patches
   1.293 -using \hgcmd{qinit}, you can pass the \hgopt{qinit}{-c} option to
   1.294 +using \hgxcmd{mq}{qinit}, you can pass the \hgopt{qinit}{-c} option to
   1.295  create the \sdirname{.hg/patches} directory as a Mercurial repository.
   1.296  
   1.297  \begin{note}
   1.298 @@ -851,7 +851,7 @@
   1.299  directory is a repository, it will automatically \hgcmd{add} every
   1.300  patch that you create and import.
   1.301  
   1.302 -Finally, MQ provides a shortcut command, \hgcmd{qcommit}, that runs
   1.303 +Finally, MQ provides a shortcut command, \hgxcmd{mq}{qcommit}, that runs
   1.304  \hgcmd{commit} in the \sdirname{.hg/patches} directory.  This saves
   1.305  some cumbersome typing.
   1.306  
   1.307 @@ -911,15 +911,15 @@
   1.308  \filename{rework-device-alloc.patch}, because it will immediately give
   1.309  you a hint what the purpose of the patch is.  Long names shouldn't be
   1.310  a problem; you won't be typing the names often, but you \emph{will} be
   1.311 -running commands like \hgcmd{qapplied} and \hgcmd{qtop} over and over.
   1.312 +running commands like \hgxcmd{mq}{qapplied} and \hgxcmd{mq}{qtop} over and over.
   1.313  Good naming becomes especially important when you have a number of
   1.314  patches to work with, or if you are juggling a number of different
   1.315  tasks and your patches only get a fraction of your attention.
   1.316  
   1.317 -Be aware of what patch you're working on.  Use the \hgcmd{qtop}
   1.318 +Be aware of what patch you're working on.  Use the \hgxcmd{mq}{qtop}
   1.319  command and skim over the text of your patches frequently---for
   1.320  example, using \hgcmdargs{tip}{\hgopt{tip}{-p}})---to be sure of where
   1.321 -you stand.  I have several times worked on and \hgcmd{qrefresh}ed a
   1.322 +you stand.  I have several times worked on and \hgxcmd{mq}{qrefresh}ed a
   1.323  patch other than the one I intended, and it's often tricky to migrate
   1.324  changes into the right patch after making them in the wrong one.
   1.325  
   1.326 @@ -960,14 +960,14 @@
   1.327  \subsection{Combining entire patches}
   1.328  \label{sec:mq:combine}
   1.329  
   1.330 -MQ provides a command, \hgcmd{qfold} that lets you combine entire
   1.331 +MQ provides a command, \hgxcmd{mq}{qfold} that lets you combine entire
   1.332  patches.  This ``folds'' the patches you name, in the order you name
   1.333  them, into the topmost applied patch, and concatenates their
   1.334  descriptions onto the end of its description.  The patches that you
   1.335  fold must be unapplied before you fold them.
   1.336  
   1.337  The order in which you fold patches matters.  If your topmost applied
   1.338 -patch is \texttt{foo}, and you \hgcmd{qfold} \texttt{bar} and
   1.339 +patch is \texttt{foo}, and you \hgxcmd{mq}{qfold} \texttt{bar} and
   1.340  \texttt{quux} into it, you will end up with a patch that has the same
   1.341  effect as if you applied first \texttt{foo}, then \texttt{bar},
   1.342  followed by \texttt{quux}.
   1.343 @@ -983,8 +983,8 @@
   1.344  out of one patch, concatenating its output onto the end of the patch
   1.345  you want to merge into.  You usually won't need to modify the patch
   1.346  you've merged the changes from.  Instead, MQ will report some rejected
   1.347 -hunks when you \hgcmd{qpush} it (from the hunks you moved into the
   1.348 -other patch), and you can simply \hgcmd{qrefresh} the patch to drop
   1.349 +hunks when you \hgxcmd{mq}{qpush} it (from the hunks you moved into the
   1.350 +other patch), and you can simply \hgxcmd{mq}{qrefresh} the patch to drop
   1.351  the duplicate hunks.
   1.352  
   1.353  If you have a patch that has multiple hunks modifying a file, and you