rev |
line source |
bos@559
|
1 <!-- vim: set filetype=docbkxml shiftwidth=2 autoindent expandtab tw=77 : -->
|
bos@559
|
2
|
bos@559
|
3 <appendix id="cmdref">
|
bos@594
|
4 <?dbhtml filename="command-reference.html"?>
|
bos@559
|
5 <title>Command reference</title>
|
bos@559
|
6
|
bos@584
|
7 <para id="x_653">\cmdref{add}{add files at the next commit}
|
bos@133
|
8 \optref{add}{I}{include}
|
bos@133
|
9 \optref{add}{X}{exclude}
|
bos@559
|
10 \optref{add}{n}{dry-run}</para>
|
bos@559
|
11
|
bos@584
|
12 <para id="x_654">\cmdref{diff}{print changes in history or working directory}</para>
|
bos@584
|
13
|
bos@584
|
14 <para id="x_655">Show differences between revisions for the specified files or
|
bos@132
|
15 directories, using the unified diff format. For a description of the
|
bos@592
|
16 unified diff format, see <xref linkend="sec:mq:patch"/>.</para>
|
bos@559
|
17
|
bos@584
|
18 <para id="x_656">By default, this command does not print diffs for files that Mercurial
|
bos@672
|
19 considers to contain binary data. To control this behavior, see the
|
bos@559
|
20 <option role="hg-opt-diff">-a</option> and <option role="hg-opt-diff">--git</option> options.</para>
|
bos@559
|
21
|
bos@559
|
22 <sect2>
|
bos@559
|
23 <title>Options</title>
|
bos@594
|
24 x
|
bos@584
|
25 <para id="x_657">\loptref{diff}{nodates}</para>
|
bos@584
|
26
|
bos@584
|
27 <para id="x_658">Omit date and time information when printing diff headers.</para>
|
bos@584
|
28
|
bos@584
|
29 <para id="x_659">\optref{diff}{B}{ignore-blank-lines}</para>
|
bos@584
|
30
|
bos@584
|
31 <para id="x_65a">Do not print changes that only insert or delete blank lines. A line
|
bos@133
|
32 that contains only whitespace is not considered blank.
|
bos@559
|
33 </para>
|
bos@559
|
34
|
bos@584
|
35 <para id="x_65b">\optref{diff}{I}{include}
|
bos@584
|
36 </para>
|
bos@584
|
37
|
bos@584
|
38 <para id="x_65c">Include files and directories whose names match the given patterns.
|
bos@584
|
39 </para>
|
bos@584
|
40
|
bos@584
|
41 <para id="x_65d">\optref{diff}{X}{exclude}
|
bos@584
|
42 </para>
|
bos@584
|
43
|
bos@584
|
44 <para id="x_65e">Exclude files and directories whose names match the given patterns.
|
bos@584
|
45 </para>
|
bos@584
|
46
|
bos@584
|
47 <para id="x_65f">\optref{diff}{a}{text}
|
bos@584
|
48 </para>
|
bos@584
|
49
|
bos@584
|
50 <para id="x_660">If this option is not specified, <command role="hg-cmd">hg diff</command> will refuse to print
|
bos@559
|
51 diffs for files that it detects as binary. Specifying <option role="hg-opt-diff">-a</option>
|
bos@559
|
52 forces <command role="hg-cmd">hg diff</command> to treat all files as text, and generate diffs for
|
bos@132
|
53 all of them.
|
bos@559
|
54 </para>
|
bos@559
|
55
|
bos@584
|
56 <para id="x_661">This option is useful for files that are <quote>mostly text</quote> but have a
|
bos@133
|
57 few embedded NUL characters. If you use it on files that contain a
|
bos@133
|
58 lot of binary data, its output will be incomprehensible.
|
bos@559
|
59 </para>
|
bos@559
|
60
|
bos@584
|
61 <para id="x_662">\optref{diff}{b}{ignore-space-change}
|
bos@584
|
62 </para>
|
bos@584
|
63
|
bos@584
|
64 <para id="x_663">Do not print a line if the only change to that line is in the amount
|
bos@133
|
65 of white space it contains.
|
bos@559
|
66 </para>
|
bos@559
|
67
|
bos@584
|
68 <para id="x_664">\optref{diff}{g}{git}
|
bos@584
|
69 </para>
|
bos@584
|
70
|
bos@584
|
71 <para id="x_665">Print <command>git</command>-compatible diffs. XXX reference a format
|
bos@133
|
72 description.
|
bos@559
|
73 </para>
|
bos@559
|
74
|
bos@584
|
75 <para id="x_666">\optref{diff}{p}{show-function}
|
bos@584
|
76 </para>
|
bos@584
|
77
|
bos@584
|
78 <para id="x_667">Display the name of the enclosing function in a hunk header, using a
|
bos@133
|
79 simple heuristic. This functionality is enabled by default, so the
|
bos@559
|
80 <option role="hg-opt-diff">-p</option> option has no effect unless you change the value of
|
bos@559
|
81 the <envar role="rc-item-diff">showfunc</envar> config item, as in the following example.</para>
|
bos@559
|
82
|
bos@559
|
83 <!-- &interaction.cmdref.diff-p; -->
|
bos@559
|
84
|
bos@584
|
85 <para id="x_668">\optref{diff}{r}{rev}
|
bos@584
|
86 </para>
|
bos@584
|
87
|
bos@584
|
88 <para id="x_669">Specify one or more revisions to compare. The <command role="hg-cmd">hg diff</command> command
|
bos@559
|
89 accepts up to two <option role="hg-opt-diff">-r</option> options to specify the revisions to
|
bos@133
|
90 compare.
|
bos@559
|
91 </para>
|
bos@559
|
92
|
bos@559
|
93 <orderedlist>
|
bos@584
|
94 <listitem><para id="x_66a">Display the differences between the parent revision of the
|
bos@133
|
95 working directory and the working directory.
|
bos@559
|
96 </para>
|
bos@559
|
97 </listitem>
|
bos@584
|
98 <listitem><para id="x_66b">Display the differences between the specified changeset and the
|
bos@132
|
99 working directory.
|
bos@559
|
100 </para>
|
bos@559
|
101 </listitem>
|
bos@584
|
102 <listitem><para id="x_66c">Display the differences between the two specified changesets.
|
bos@559
|
103 </para>
|
bos@559
|
104 </listitem></orderedlist>
|
bos@559
|
105
|
bos@584
|
106 <para id="x_66d">You can specify two revisions using either two <option role="hg-opt-diff">-r</option>
|
bos@132
|
107 options or revision range notation. For example, the two revision
|
bos@132
|
108 specifications below are equivalent.
|
bos@559
|
109 </para>
|
bos@559
|
110 <programlisting>hg diff -r 10 -r 20
|
bos@559
|
111 hg diff -r10:20</programlisting>
|
bos@559
|
112
|
bos@584
|
113 <para id="x_66e">When you provide two revisions, Mercurial treats the order of those
|
bos@559
|
114 revisions as significant. Thus, <command role="hg-cmd">hg diff -r10:20</command> will
|
bos@132
|
115 produce a diff that will transform files from their contents as of
|
bos@559
|
116 revision 10 to their contents as of revision 20, while
|
bos@559
|
117 <command role="hg-cmd">hg diff -r20:10</command> means the opposite: the diff that will
|
bos@559
|
118 transform files from their revision 20 contents to their revision 10
|
bos@132
|
119 contents. You cannot reverse the ordering in this way if you are
|
bos@132
|
120 diffing against the working directory.
|
bos@559
|
121 </para>
|
bos@559
|
122
|
bos@584
|
123 <para id="x_66f">\optref{diff}{w}{ignore-all-space}
|
bos@584
|
124 </para>
|
bos@584
|
125
|
bos@584
|
126 <para id="x_670">\cmdref{version}{print version and copyright information}
|
bos@584
|
127 </para>
|
bos@584
|
128
|
bos@584
|
129 <para id="x_671">This command displays the version of Mercurial you are running, and
|
bos@133
|
130 its copyright license. There are four kinds of version string that
|
bos@133
|
131 you may see.
|
bos@559
|
132 </para>
|
bos@559
|
133 <itemizedlist>
|
bos@584
|
134 <listitem><para id="x_672">The string <quote><literal>unknown</literal></quote>. This version of Mercurial was
|
bos@133
|
135 not built in a Mercurial repository, and cannot determine its own
|
bos@133
|
136 version.
|
bos@559
|
137 </para>
|
bos@559
|
138 </listitem>
|
bos@584
|
139 <listitem><para id="x_673">A short numeric string, such as <quote><literal>1.1</literal></quote>. This is a
|
bos@133
|
140 build of a revision of Mercurial that was identified by a specific
|
bos@133
|
141 tag in the repository where it was built. (This doesn't necessarily
|
bos@133
|
142 mean that you're running an official release; someone else could
|
bos@133
|
143 have added that tag to any revision in the repository where they
|
bos@133
|
144 built Mercurial.)
|
bos@559
|
145 </para>
|
bos@559
|
146 </listitem>
|
bos@584
|
147 <listitem><para id="x_674">A hexadecimal string, such as <quote><literal>875489e31abe</literal></quote>. This
|
bos@133
|
148 is a build of the given revision of Mercurial.
|
bos@559
|
149 </para>
|
bos@559
|
150 </listitem>
|
bos@584
|
151 <listitem><para id="x_675">A hexadecimal string followed by a date, such as
|
bos@559
|
152 <quote><literal>875489e31abe+20070205</literal></quote>. This is a build of the given
|
bos@133
|
153 revision of Mercurial, where the build repository contained some
|
bos@133
|
154 local changes that had not been committed.
|
bos@559
|
155 </para>
|
bos@559
|
156 </listitem></itemizedlist>
|
bos@559
|
157
|
bos@559
|
158 </sect2>
|
bos@559
|
159 <sect2>
|
bos@559
|
160 <title>Tips and tricks</title>
|
bos@559
|
161
|
bos@559
|
162 <sect3 id="cmdref:diff-vs-status">
|
bos@559
|
163 <title>Why do the results of <command role="hg-cmd">hg diff</command> and <command role="hg-cmd">hg status</command> differ?</title>
|
bos@559
|
164
|
bos@584
|
165 <para id="x_676">When you run the <command role="hg-cmd">hg status</command> command, you'll see a list of files
|
bos@132
|
166 that Mercurial will record changes for the next time you perform a
|
bos@559
|
167 commit. If you run the <command role="hg-cmd">hg diff</command> command, you may notice that it
|
bos@559
|
168 prints diffs for only a <emphasis>subset</emphasis> of the files that <command role="hg-cmd">hg status</command>
|
bos@132
|
169 listed. There are two possible reasons for this.
|
bos@559
|
170 </para>
|
bos@559
|
171
|
bos@584
|
172 <para id="x_677">The first is that <command role="hg-cmd">hg status</command> prints some kinds of modifications
|
bos@559
|
173 that <command role="hg-cmd">hg diff</command> doesn't normally display. The <command role="hg-cmd">hg diff</command> command
|
bos@132
|
174 normally outputs unified diffs, which don't have the ability to
|
bos@132
|
175 represent some changes that Mercurial can track. Most notably,
|
bos@132
|
176 traditional diffs can't represent a change in whether or not a file is
|
bos@132
|
177 executable, but Mercurial records this information.
|
bos@559
|
178 </para>
|
bos@559
|
179
|
bos@584
|
180 <para id="x_678">If you use the <option role="hg-opt-diff">--git</option> option to <command role="hg-cmd">hg diff</command>, it will
|
bos@559
|
181 display <command>git</command>-compatible diffs that <emphasis>can</emphasis> display this
|
bos@132
|
182 extra information.
|
bos@559
|
183 </para>
|
bos@559
|
184
|
bos@584
|
185 <para id="x_679">The second possible reason that <command role="hg-cmd">hg diff</command> might be printing diffs
|
bos@559
|
186 for a subset of the files displayed by <command role="hg-cmd">hg status</command> is that if you
|
bos@559
|
187 invoke it without any arguments, <command role="hg-cmd">hg diff</command> prints diffs against the
|
bos@559
|
188 first parent of the working directory. If you have run <command role="hg-cmd">hg merge</command>
|
bos@132
|
189 to merge two changesets, but you haven't yet committed the results of
|
bos@559
|
190 the merge, your working directory has two parents (use <command role="hg-cmd">hg parents</command>
|
bos@559
|
191 to see them). While <command role="hg-cmd">hg status</command> prints modifications relative to
|
bos@559
|
192 <emphasis>both</emphasis> parents after an uncommitted merge, <command role="hg-cmd">hg diff</command> still
|
bos@132
|
193 operates relative only to the first parent. You can get it to print
|
bos@132
|
194 diffs relative to the second parent by specifying that parent with the
|
bos@559
|
195 <option role="hg-opt-diff">-r</option> option. There is no way to print diffs relative to
|
bos@132
|
196 both parents.
|
bos@559
|
197 </para>
|
bos@559
|
198
|
bos@559
|
199 </sect3>
|
bos@559
|
200 <sect3>
|
bos@559
|
201 <title>Generating safe binary diffs</title>
|
bos@559
|
202
|
bos@584
|
203 <para id="x_67a">If you use the <option role="hg-opt-diff">-a</option> option to force Mercurial to print
|
bos@559
|
204 diffs of files that are either <quote>mostly text</quote> or contain lots of
|
bos@132
|
205 binary data, those diffs cannot subsequently be applied by either
|
bos@559
|
206 Mercurial's <command role="hg-cmd">hg import</command> command or the system's <command>patch</command>
|
bos@559
|
207 command.
|
bos@559
|
208 </para>
|
bos@559
|
209
|
bos@584
|
210 <para id="x_67b">If you want to generate a diff of a binary file that is safe to use as
|
bos@559
|
211 input for <command role="hg-cmd">hg import</command>, use the <command role="hg-cmd">hg diff</command>{--git} option when you
|
bos@559
|
212 generate the patch. The system <command>patch</command> command cannot handle
|
bos@132
|
213 binary patches at all.
|
bos@559
|
214 </para>
|
bos@559
|
215
|
bos@559
|
216 </sect3>
|
bos@559
|
217 </sect2>
|
bos@559
|
218 </appendix>
|
bos@559
|
219
|
bos@559
|
220 <!--
|
bos@559
|
221 local variables:
|
bos@559
|
222 sgml-parent-document: ("00book.xml" "book" "appendix")
|
bos@559
|
223 end:
|
bos@559
|
224 -->
|