Mercurial > hgbook
comparison en/appA-cmdref.tex @ 649:5cd47f721686
Rename LaTeX input files to have numeric prefixes
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Thu, 29 Jan 2009 22:56:27 -0800 |
parents | en/cmdref.tex@92660e72d6bf |
children | f72b7e6cbe90 |
comparison
equal
deleted
inserted
replaced
648:bc14f94e726a | 649:5cd47f721686 |
---|---|
1 \chapter{Command reference} | |
2 \label{cmdref} | |
3 | |
4 \cmdref{add}{add files at the next commit} | |
5 \optref{add}{I}{include} | |
6 \optref{add}{X}{exclude} | |
7 \optref{add}{n}{dry-run} | |
8 | |
9 \cmdref{diff}{print changes in history or working directory} | |
10 | |
11 Show differences between revisions for the specified files or | |
12 directories, using the unified diff format. For a description of the | |
13 unified diff format, see section~\ref{sec:mq:patch}. | |
14 | |
15 By default, this command does not print diffs for files that Mercurial | |
16 considers to contain binary data. To control this behaviour, see the | |
17 \hgopt{diff}{-a} and \hgopt{diff}{--git} options. | |
18 | |
19 \subsection{Options} | |
20 | |
21 \loptref{diff}{nodates} | |
22 | |
23 Omit date and time information when printing diff headers. | |
24 | |
25 \optref{diff}{B}{ignore-blank-lines} | |
26 | |
27 Do not print changes that only insert or delete blank lines. A line | |
28 that contains only whitespace is not considered blank. | |
29 | |
30 \optref{diff}{I}{include} | |
31 | |
32 Include files and directories whose names match the given patterns. | |
33 | |
34 \optref{diff}{X}{exclude} | |
35 | |
36 Exclude files and directories whose names match the given patterns. | |
37 | |
38 \optref{diff}{a}{text} | |
39 | |
40 If this option is not specified, \hgcmd{diff} will refuse to print | |
41 diffs for files that it detects as binary. Specifying \hgopt{diff}{-a} | |
42 forces \hgcmd{diff} to treat all files as text, and generate diffs for | |
43 all of them. | |
44 | |
45 This option is useful for files that are ``mostly text'' but have a | |
46 few embedded NUL characters. If you use it on files that contain a | |
47 lot of binary data, its output will be incomprehensible. | |
48 | |
49 \optref{diff}{b}{ignore-space-change} | |
50 | |
51 Do not print a line if the only change to that line is in the amount | |
52 of white space it contains. | |
53 | |
54 \optref{diff}{g}{git} | |
55 | |
56 Print \command{git}-compatible diffs. XXX reference a format | |
57 description. | |
58 | |
59 \optref{diff}{p}{show-function} | |
60 | |
61 Display the name of the enclosing function in a hunk header, using a | |
62 simple heuristic. This functionality is enabled by default, so the | |
63 \hgopt{diff}{-p} option has no effect unless you change the value of | |
64 the \rcitem{diff}{showfunc} config item, as in the following example. | |
65 \interaction{cmdref.diff-p} | |
66 | |
67 \optref{diff}{r}{rev} | |
68 | |
69 Specify one or more revisions to compare. The \hgcmd{diff} command | |
70 accepts up to two \hgopt{diff}{-r} options to specify the revisions to | |
71 compare. | |
72 | |
73 \begin{enumerate} | |
74 \setcounter{enumi}{0} | |
75 \item Display the differences between the parent revision of the | |
76 working directory and the working directory. | |
77 \item Display the differences between the specified changeset and the | |
78 working directory. | |
79 \item Display the differences between the two specified changesets. | |
80 \end{enumerate} | |
81 | |
82 You can specify two revisions using either two \hgopt{diff}{-r} | |
83 options or revision range notation. For example, the two revision | |
84 specifications below are equivalent. | |
85 \begin{codesample2} | |
86 hg diff -r 10 -r 20 | |
87 hg diff -r10:20 | |
88 \end{codesample2} | |
89 | |
90 When you provide two revisions, Mercurial treats the order of those | |
91 revisions as significant. Thus, \hgcmdargs{diff}{-r10:20} will | |
92 produce a diff that will transform files from their contents as of | |
93 revision~10 to their contents as of revision~20, while | |
94 \hgcmdargs{diff}{-r20:10} means the opposite: the diff that will | |
95 transform files from their revision~20 contents to their revision~10 | |
96 contents. You cannot reverse the ordering in this way if you are | |
97 diffing against the working directory. | |
98 | |
99 \optref{diff}{w}{ignore-all-space} | |
100 | |
101 \cmdref{version}{print version and copyright information} | |
102 | |
103 This command displays the version of Mercurial you are running, and | |
104 its copyright license. There are four kinds of version string that | |
105 you may see. | |
106 \begin{itemize} | |
107 \item The string ``\texttt{unknown}''. This version of Mercurial was | |
108 not built in a Mercurial repository, and cannot determine its own | |
109 version. | |
110 \item A short numeric string, such as ``\texttt{1.1}''. This is a | |
111 build of a revision of Mercurial that was identified by a specific | |
112 tag in the repository where it was built. (This doesn't necessarily | |
113 mean that you're running an official release; someone else could | |
114 have added that tag to any revision in the repository where they | |
115 built Mercurial.) | |
116 \item A hexadecimal string, such as ``\texttt{875489e31abe}''. This | |
117 is a build of the given revision of Mercurial. | |
118 \item A hexadecimal string followed by a date, such as | |
119 ``\texttt{875489e31abe+20070205}''. This is a build of the given | |
120 revision of Mercurial, where the build repository contained some | |
121 local changes that had not been committed. | |
122 \end{itemize} | |
123 | |
124 \subsection{Tips and tricks} | |
125 | |
126 \subsubsection{Why do the results of \hgcmd{diff} and \hgcmd{status} | |
127 differ?} | |
128 \label{cmdref:diff-vs-status} | |
129 | |
130 When you run the \hgcmd{status} command, you'll see a list of files | |
131 that Mercurial will record changes for the next time you perform a | |
132 commit. If you run the \hgcmd{diff} command, you may notice that it | |
133 prints diffs for only a \emph{subset} of the files that \hgcmd{status} | |
134 listed. There are two possible reasons for this. | |
135 | |
136 The first is that \hgcmd{status} prints some kinds of modifications | |
137 that \hgcmd{diff} doesn't normally display. The \hgcmd{diff} command | |
138 normally outputs unified diffs, which don't have the ability to | |
139 represent some changes that Mercurial can track. Most notably, | |
140 traditional diffs can't represent a change in whether or not a file is | |
141 executable, but Mercurial records this information. | |
142 | |
143 If you use the \hgopt{diff}{--git} option to \hgcmd{diff}, it will | |
144 display \command{git}-compatible diffs that \emph{can} display this | |
145 extra information. | |
146 | |
147 The second possible reason that \hgcmd{diff} might be printing diffs | |
148 for a subset of the files displayed by \hgcmd{status} is that if you | |
149 invoke it without any arguments, \hgcmd{diff} prints diffs against the | |
150 first parent of the working directory. If you have run \hgcmd{merge} | |
151 to merge two changesets, but you haven't yet committed the results of | |
152 the merge, your working directory has two parents (use \hgcmd{parents} | |
153 to see them). While \hgcmd{status} prints modifications relative to | |
154 \emph{both} parents after an uncommitted merge, \hgcmd{diff} still | |
155 operates relative only to the first parent. You can get it to print | |
156 diffs relative to the second parent by specifying that parent with the | |
157 \hgopt{diff}{-r} option. There is no way to print diffs relative to | |
158 both parents. | |
159 | |
160 \subsubsection{Generating safe binary diffs} | |
161 | |
162 If you use the \hgopt{diff}{-a} option to force Mercurial to print | |
163 diffs of files that are either ``mostly text'' or contain lots of | |
164 binary data, those diffs cannot subsequently be applied by either | |
165 Mercurial's \hgcmd{import} command or the system's \command{patch} | |
166 command. | |
167 | |
168 If you want to generate a diff of a binary file that is safe to use as | |
169 input for \hgcmd{import}, use the \hgcmd{diff}{--git} option when you | |
170 generate the patch. The system \command{patch} command cannot handle | |
171 binary patches at all. | |
172 | |
173 %%% Local Variables: | |
174 %%% mode: latex | |
175 %%% TeX-master: "00book" | |
176 %%% End: |