Mercurial > hgbook
comparison ja/filenames.tex @ 364:1b372620963a
finished filenames.tex
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Mon, 20 Oct 2008 15:22:06 +0900 |
parents | 3b1291f24c0d |
children | 5276f40fca1c |
comparison
equal
deleted
inserted
replaced
363:bc92b28fc970 | 364:1b372620963a |
---|---|
1 \chapter{File names and pattern matching} | 1 %\chapter{File names and pattern matching} |
2 \chapter{$B%U%!%$%kL>$H%Q%?!<%s%^%C%A%s%0(B} | |
2 \label{chap:names} | 3 \label{chap:names} |
3 | 4 |
4 Mercurial provides mechanisms that let you work with file names in a | 5 %Mercurial provides mechanisms that let you work with file names in a |
5 consistent and expressive way. | 6 %consistent and expressive way. |
6 | 7 |
7 \section{Simple file naming} | 8 Mercurial$B$O%U%!%$%kL>$K$D$$$F0l4S@-$N$"$jJ,$+$j$d$9$$%a%+%K%:%`$rDs6!$9(B |
8 | 9 $B$k!%(B |
9 Mercurial uses a unified piece of machinery ``under the hood'' to | 10 |
10 handle file names. Every command behaves uniformly with respect to | 11 %\section{Simple file naming} |
11 file names. The way in which commands work with file names is as | 12 \section{$B%7%s%W%k$J%U%!%$%kL?L>(B} |
12 follows. | 13 |
13 | 14 %Mercurial uses a unified piece of machinery ``under the hood'' to |
14 If you explicitly name real files on the command line, Mercurial works | 15 %handle file names. Every command behaves uniformly with respect to |
15 with exactly those files, as you would expect. | 16 %file names. The way in which commands work with file names is as |
17 %follows. | |
18 | |
19 Mercurial$B$O%U%!%$%kL>$r<h$j07$&FbIt$N%a%+%K%:%`$r;}$C$F$$$k!%$"$i$f$k%3%^(B | |
20 $B%s%I$O%U%!%$%kL>$KBP$7$FF10l$K$U$k$^$&!%%3%^%s%I$,%U%!%$%kL>$r07$&$d$jJ}(B | |
21 $B$r0J2<$K<($9!%(B | |
22 | |
23 %If you explicitly name real files on the command line, Mercurial works | |
24 %with exactly those files, as you would expect. | |
25 $B%3%^%s%I%i%$%s$K<B:]$N%U%!%$%kL>$rL@<(E*$KM?$($?;~$O!$(BMercurial$B$O$=$l$i(B | |
26 $B$N%U%!%$%k$=$N$b$N$r07$&!%(B | |
16 \interaction{filenames.files} | 27 \interaction{filenames.files} |
17 | 28 |
18 When you provide a directory name, Mercurial will interpret this as | 29 %When you provide a directory name, Mercurial will interpret this as |
19 ``operate on every file in this directory and its subdirectories''. | 30 %``operate on every file in this directory and its subdirectories''. |
20 Mercurial traverses the files and subdirectories in a directory in | 31 %Mercurial traverses the files and subdirectories in a directory in |
21 alphabetical order. When it encounters a subdirectory, it will | 32 %alphabetical order. When it encounters a subdirectory, it will |
22 traverse that subdirectory before continuing with the current | 33 %traverse that subdirectory before continuing with the current |
23 directory. | 34 %directory. |
35 | |
36 $B%G%#%l%/%H%jL>$rM?$($?>l9g$O!$(BMercurial$B$O(B``$B$3$N%G%#%l%/%H%j$H%5%V%G%#%l%/(B | |
37 $B%H%jFb$N$9$Y$F$N%U%!%$%k$KBP$7$F=hM}$r9T$&(B''$B$H2r<a$9$k!%(B | |
38 Mercurial$B$O%G%#%l%/%H%jFb$N%U%!%$%k$H%5%V%G%#%l%/%H%j$r%"%k%U%!%Y%C%H=g(B | |
39 $B$KEO$jJb$/!%%5%V%G%#%l%/%H%j$r8+$D$1$k$H!$%+%l%s%H%G%#%l%/%H%j$N=hM}$rB3(B | |
40 $B$1$k$N$G$O$J$/!$%5%V%G%#%l%/%H%jFb$r8+$K9T$/!%(B | |
24 \interaction{filenames.dirs} | 41 \interaction{filenames.dirs} |
25 | 42 |
26 \section{Running commands without any file names} | 43 %\section{Running commands without any file names} |
27 | 44 \section{$B%U%!%$%kL>$J$7$G%3%^%s%I$r<B9T$9$k(B} |
28 Mercurial's commands that work with file names have useful default | 45 |
29 behaviours when you invoke them without providing any file names or | 46 %Mercurial's commands that work with file names have useful default |
30 patterns. What kind of behaviour you should expect depends on what | 47 %behaviours when you invoke them without providing any file names or |
31 the command does. Here are a few rules of thumb you can use to | 48 %patterns. What kind of behaviour you should expect depends on what |
32 predict what a command is likely to do if you don't give it any names | 49 %the command does. Here are a few rules of thumb you can use to |
33 to work with. | 50 %predict what a command is likely to do if you don't give it any names |
51 %to work with. | |
52 | |
53 $B%U%!%$%kL>$r<h$k(BMercurial$B%3%^%s%I$O%U%!%$%kL>$d%Q%?!<%s$rM?$($J$$$G5/F0$7(B | |
54 $B$?>l9g$G$bM-MQ$J%G%U%)%k%H$N?6Iq$r;}$D!%4|BT$9$k5sF0$O!$2?$r$9$k%3%^%s%I(B | |
55 $B$+$K$h$k!%%3%^%s%I$K%U%!%$%kL>Ey$rM?$($J$+$C$?>l9g$K%3%^%s%I$,$I$N$h$&$K(B | |
56 $BF0$/$+?dB,$9$kBg$^$+$J%k!<%k$r$$$/$D$+5s$2$k!%(B | |
57 | |
34 \begin{itemize} | 58 \begin{itemize} |
35 \item Most commands will operate on the entire working directory. | 59 %\item Most commands will operate on the entire working directory. |
36 This is what the \hgcmd{add} command does, for example. | 60 % This is what the \hgcmd{add} command does, for example. |
37 \item If the command has effects that are difficult or impossible to | 61 \item $BBgH>$N%3%^%s%I$O%o!<%-%s%0%G%#%l%/%H%jA4BN$KBP$7$FF/$/!%Nc$($P(B |
38 reverse, it will force you to explicitly provide at least one name | 62 \hgcmd{add}$B%3%^%s%I$N$U$k$^$$$,$3$l$K$"$?$k!%(B |
39 or pattern (see below). This protects you from accidentally | 63 |
40 deleting files by running \hgcmd{remove} with no arguments, for | 64 %\item If the command has effects that are difficult or impossible to |
41 example. | 65 % reverse, it will force you to explicitly provide at least one name |
66 % or pattern (see below). This protects you from accidentally | |
67 % deleting files by running \hgcmd{remove} with no arguments, for | |
68 % example. | |
69 \item $BI|85$,Fq$7$+$C$?$jIT2DG=$G$"$k$h$&$J8z2L$r;}$D%3%^%s%I$N>l9g!$:GDc(B | |
70 1$B$D$NL>A0$d%Q%?!<%s$rM[$KMW5a$9$k!%!J2<5-$r;2>H!%!K$3$l$K$h$j!$Nc(B | |
71 $B$($P(B\hgcmd{remove}$B$K0z?t$rM?$($J$+$C$?$3$H$K$h$C$F8m$C$F%U%!%$%k$r(B | |
72 $B$9$Y$F>C$7$?$j$9$k$3$H$,$J$/$J$k!%(B | |
42 \end{itemize} | 73 \end{itemize} |
43 | 74 |
44 It's easy to work around these default behaviours if they don't suit | 75 %It's easy to work around these default behaviours if they don't suit |
45 you. If a command normally operates on the whole working directory, | 76 %you. If a command normally operates on the whole working directory, |
46 you can invoke it on just the current directory and its subdirectories | 77 %you can invoke it on just the current directory and its subdirectories |
47 by giving it the name ``\dirname{.}''. | 78 %by giving it the name ``\dirname{.}''. |
79 %\interaction{filenames.wdir-subdir} | |
80 | |
81 $B%G%U%)%k%H$N5sF0$,5$$KF~$i$J$$>l9g!$$3$l$rJQ99$9$k$N$O$?$d$9$$!%(B | |
82 $B%3%^%s%I$,DL>o%o!<%-%s%0%G%#%l%/%H%jA4BN$KBP$7$FF0:n$9$k$H$7$h$&!%(B | |
83 $B$3$l$r%+%l%s%H%G%#%l%/%H%j$H$=$N%5%V%G%#%l%/%H%j$KBP$7$F$N$_F0:n$9$k$h$&(B | |
84 $B$KJQ$($k$K$O!$(B``\dirname{.}''$B$rEO$;$PNI$$!%(B | |
48 \interaction{filenames.wdir-subdir} | 85 \interaction{filenames.wdir-subdir} |
49 | 86 |
50 Along the same lines, some commands normally print file names relative | 87 %Along the same lines, some commands normally print file names relative |
51 to the root of the repository, even if you're invoking them from a | 88 %to the root of the repository, even if you're invoking them from a |
52 subdirectory. Such a command will print file names relative to your | 89 %subdirectory. Such a command will print file names relative to your |
53 subdirectory if you give it explicit names. Here, we're going to run | 90 |
54 \hgcmd{status} from a subdirectory, and get it to operate on the | 91 %subdirectory if you give it explicit names. Here, we're going to run |
55 entire working directory while printing file names relative to our | 92 |
56 subdirectory, by passing it the output of the \hgcmd{root} command. | 93 %\hgcmd{status} from a subdirectory, and get it to operate on the |
57 \interaction{filenames.wdir-relname} | 94 %entire working directory while printing file names relative to our |
58 | 95 |
59 \section{Telling you what's going on} | 96 %subdirectory, by passing it the output of the \hgcmd{root} command. |
60 | 97 %\interaction{filenames.wdir-relname} |
61 The \hgcmd{add} example in the preceding section illustrates something | 98 |
62 else that's helpful about Mercurial commands. If a command operates | 99 $B%5%V%G%#%l%/%H%j$+$i5/F0$7$F$b%j%]%8%H%j$N%k!<%H$X$NAjBP%Q%9$G%U%!%$%kL>(B |
63 on a file that you didn't name explicitly on the command line, it will | 100 $B$rI=<($9$k%3%^%s%I$b$"$k!%$=$N$h$&$J%3%^%s%I$G$O!$%5%V%G%#%l%/%H%j$NL>A0(B |
64 usually print the name of the file, so that you will not be surprised | 101 $B$rL@<(E*$KM?$($k$H!$%5%V%G%#%l%/%H%j$+$i$NAjBP%Q%9$rI=<($9$k$h$&$K$J$k!%(B |
65 what's going on. | 102 |
66 | 103 $B$3$3$G$O%5%V%G%#%l%/%H%j$+$i(B\hgcmd{status}$B$r<B9T$9$k:]$K!$(B |
67 The principle here is of \emph{least surprise}. If you've exactly | 104 |
68 named a file on the command line, there's no point in repeating it | 105 |
69 back at you. If Mercurial is acting on a file \emph{implicitly}, | 106 $B$7$F!$(B |
70 because you provided no names, or a directory, or a pattern (see | 107 $B%3%^%s%I$,%o!<%-%s%0%G%#%l%/%H%jA4BN$N%U%!%$%kL>$r%5%V%G%#%l%/%H%j$KBP$7$FAjBPE*$K(B |
71 below), it's safest to tell you what it's doing. | 108 $BI=<($9$kMM$r8+$F$_$h$&!%(B |
72 | 109 |
73 For commands that behave this way, you can silence them using the | 110 |
74 \hggopt{-q} option. You can also get them to print the name of every | 111 |
75 file, even those you've named explicitly, using the \hggopt{-v} | 112 |
76 option. | 113 %\section{Telling you what's going on} |
77 | 114 \section{$B2?$,5/$-$F$$$k$N$+(B} |
78 \section{Using patterns to identify files} | 115 |
79 | 116 %The \hgcmd{add} example in the preceding section illustrates something |
80 In addition to working with file and directory names, Mercurial lets | 117 %else that's helpful about Mercurial commands. If a command operates |
81 you use \emph{patterns} to identify files. Mercurial's pattern | 118 %on a file that you didn't name explicitly on the command line, it will |
82 handling is expressive. | 119 %usually print the name of the file, so that you will not be surprised |
83 | 120 %what's going on. |
84 On Unix-like systems (Linux, MacOS, etc.), the job of matching file | 121 |
85 names to patterns normally falls to the shell. On these systems, you | 122 $BA0%;%/%7%g%s$N(B\hgcmd{add}$B$NNc$O(BMercurial$B%3%^%s%I$K$D$$$FJL$NM-MQ$J>pJs$r(B |
86 must explicitly tell Mercurial that a name is a pattern. On Windows, | 123 $B<($7$F$$$k!%%3%^%s%I%i%$%s$GL@<(E*$KL>A0$r;XDj$7$J$+$C$?%U%!%$%k$KBP$7$F(B |
87 the shell does not expand patterns, so Mercurial will automatically | 124 $B%3%^%s%I=hM}$r9T$&>l9g!$%U%!%$%kL>$rI=<($7!$2?$,5/$3$C$F$$$k$N$+J,$+$i$J(B |
88 identify names that are patterns, and expand them for you. | 125 $B$/$J$i$J$$$h$&$K$7$F$$$k!%(B |
89 | 126 |
90 To provide a pattern in place of a regular name on the command line, | 127 %The principle here is of \emph{least surprise}. If you've exactly |
91 the mechanism is simple: | 128 %named a file on the command line, there's no point in repeating it |
129 %back at you. If Mercurial is acting on a file \emph{implicitly}, | |
130 %because you provided no names, or a directory, or a pattern (see | |
131 %below), it's safest to tell you what it's doing. | |
132 | |
133 \emph{$B$G$-$k$@$1$S$C$/$j$5$;$J$$(B}$B$H$$$&$N$,$3$3$G$N86B'$G$"$k!%%3%^%s%I%i(B | |
134 $B%$%s$G%U%!%$%kL>$r40A4$K;XDj$7$?>l9g!$%U%!%$%kL>$,I=<($5$l$k$3$H$O$J$$!%(B | |
135 Mercurial$B$O!$L>A0$rM?$($J$$$+!$%G%#%l%/%H%jL>!$0J2<$G2r@b$9$k%Q%?!<%s$rM?(B | |
136 $B$($?$?$a$K(B\emph{$B0EL[E*$K(B}$B;XDj$5$l$?%U%!%$%k$KBP$7$F%"%/%7%g%s$9$k>l9g$O!$(B | |
137 $B:G$b0BA4$J$d$jJ}$H$7$F!$8=:_$7$F$$$k$3$H$rI=<($9$k!%(B | |
138 | |
139 %For commands that behave this way, you can silence them using the | |
140 %\hggopt{-q} option. You can also get them to print the name of every | |
141 %file, even those you've named explicitly, using the \hggopt{-v} | |
142 %option. | |
143 | |
144 $B$3$N$h$&$K?6Iq$&%3%^%s%I$r!$(B\hggopt{-q}$B%*%W%7%g%s$rM?$($k$3$H$GD@L[$5$;$k(B | |
145 $B$3$H$b$G$-$k!%5U$KL@<(E*$K;XDj$7$?%U%!%$%k$X$NF0:n$G$"$C$F$b(B\hggopt{-v}$B%*(B | |
146 $B%W%7%g%s$rM?$($k$3$H$G$9$Y$F$N%U%!%$%kL>$rI=<($5$;$k$3$H$b$G$-$k!%(B | |
147 | |
148 %\section{Using patterns to identify files} | |
149 \section{$B%U%!%$%kL><1JL$K%Q%?!<%s$rMQ$$$k(B} | |
150 | |
151 %In addition to working with file and directory names, Mercurial lets | |
152 %you use \emph{patterns} to identify files. Mercurial's pattern | |
153 %handling is expressive. | |
154 | |
155 $B%U%!%$%k$d%G%#%l%/%H%jL>$r;H$C$?F0:n$NB>$K!$(BMercurial$B$G$O(B\emph{patterns} | |
156 $B$r;H$C$F%U%!%$%k$r<1JL$9$k$3$H$b$G$-$k!%(BMercurial$B$N%Q%?!<%s=hM}$O6/NO$G(B | |
157 $B$"$k!%(B | |
158 | |
159 %On Unix-like systems (Linux, MacOS, etc.), the job of matching file | |
160 %names to patterns normally falls to the shell. On these systems, you | |
161 %must explicitly tell Mercurial that a name is a pattern. On Windows, | |
162 %the shell does not expand patterns, so Mercurial will automatically | |
163 %identify names that are patterns, and expand them for you. | |
164 | |
165 Unix$B7O$N%7%9%F%`(B(Linux, MacOS$BEy(B)$B$G$O%U%!%$%kL>$H%Q%?!<%s$r%^%C%A$5$;$k;E(B | |
166 $B;v$O%7%'%k$KG$$5$l$k!%$3$l$i$N%7%9%F%`$G$O!$L>A0$,%Q%?!<%s$G$"$k$3$H$rL@(B | |
167 $B<(E*$K(BMercurial$B$K<($5$J$1$l$P$J$i$J$$!%(B Windows$B$G$O%7%'%k$O%Q%?!<%s$rE83+(B | |
168 $B$7$J$$$N$G!$(BMercurial$B$OM?$($i$l$?L>A0$,<+F0E*$K%Q%?!<%s$G$"$k$3$H$rG'<1(B | |
169 $B$7!$E83+$9$k!%(B | |
170 | |
171 %To provide a pattern in place of a regular name on the command line, | |
172 %the mechanism is simple: | |
173 | |
174 $B%3%^%s%I%i%$%s$GDL>o$NL>A0$NBe$o$j$K%Q%?!<%s$rEO$9$?$a$N%a%+%K%:%`$O%7%s(B | |
175 $B%W%k$G$"$k!%(B: | |
92 \begin{codesample2} | 176 \begin{codesample2} |
93 syntax:patternbody | 177 syntax:patternbody |
94 \end{codesample2} | 178 \end{codesample2} |
95 That is, a pattern is identified by a short text string that says what | 179 %That is, a pattern is identified by a short text string that says what |
96 kind of pattern this is, followed by a colon, followed by the actual | 180 %kind of pattern this is, followed by a colon, followed by the actual |
97 pattern. | 181 %pattern. |
98 | 182 |
99 Mercurial supports two kinds of pattern syntax. The most frequently | 183 $B$I$N$h$&$J%Q%?!<%s$J$N$+$r<1JL$9$k$?$a$NC;$$%F%-%9%H$N8e$m$K%3%m%s$r64$s(B |
100 used is called \texttt{glob}; this is the same kind of pattern | 184 $B$G<B:]$N%Q%?!<%s$,B3$/!%(B |
101 matching used by the Unix shell, and should be familiar to Windows | 185 |
102 command prompt users, too. | 186 %Mercurial supports two kinds of pattern syntax. The most frequently |
103 | 187 %used is called \texttt{glob}; this is the same kind of pattern |
104 When Mercurial does automatic pattern matching on Windows, it uses | 188 %matching used by the Unix shell, and should be familiar to Windows |
105 \texttt{glob} syntax. You can thus omit the ``\texttt{glob:}'' prefix | 189 %command prompt users, too. |
106 on Windows, but it's safe to use it, too. | 190 |
107 | 191 Mercurial$B$O(B2$BDL$j$N%Q%?!<%s9=J8$r%5%]!<%H$9$k!%:G$b$h$/;H$o$l$k$N$O(B |
108 The \texttt{re} syntax is more powerful; it lets you specify patterns | 192 \texttt{glob};$B$G!$(BUnix$B%7%'%k$,%Q%?!<%s%^%C%A%s%0$K;HMQ$7$F$$$k$b$N$HF1MM(B |
109 using regular expressions, also known as regexps. | 193 $B$N%Q%?!<%s$G$"$j!$$3$l$O(BWindows$B$N%3%^%s%I%W%m%s%W%H%f!<%6$K$H$C$F$b?F$7(B |
110 | 194 $B$_?<$$$b$N$G$"$k!%(B |
111 By the way, in the examples that follow, notice that I'm careful to | 195 |
112 wrap all of my patterns in quote characters, so that they won't get | 196 %When Mercurial does automatic pattern matching on Windows, it uses |
113 expanded by the shell before Mercurial sees them. | 197 %\texttt{glob} syntax. You can thus omit the ``\texttt{glob:}'' prefix |
114 | 198 %on Windows, but it's safe to use it, too. |
115 \subsection{Shell-style \texttt{glob} patterns} | 199 |
116 | 200 Mercurial$B$O(BWindows$B$G$O<+F0E*$K%Q%?!<%s%^%C%A%s%0$r9T$&$H$-(B |
117 This is an overview of the kinds of patterns you can use when you're | 201 $B$O!$(B\texttt{glob}$B9=J8$rMQ$$$k!%=>$C$F(BWindows$B$G$O(B``\texttt{glob:}''$B%W%l%U%#(B |
118 matching on glob patterns. | 202 $B%/%9$r>JN,$7$F$b0BA4$G$"$k!%(B |
119 | 203 |
120 The ``\texttt{*}'' character matches any string, within a single | 204 %The \texttt{re} syntax is more powerful; it lets you specify patterns |
121 directory. | 205 %using regular expressions, also known as regexps. |
206 | |
207 \texttt{re}$B9=J8$O$h$j6/NO$G!$@55,I=8=$rMQ$$$k$3$H$,$G$-$k!%(B | |
208 | |
209 %By the way, in the examples that follow, notice that I'm careful to | |
210 %wrap all of my patterns in quote characters, so that they won't get | |
211 %expanded by the shell before Mercurial sees them. | |
212 | |
213 $B8e$G<($9Nc$G$O!$(BMercurial$B$,8+$kA0$K%7%'%k$GE83+$5$l$k$N$rKI$0$?$a$K%Q%?!<(B | |
214 $B%s$r0zMQJ8;z$G$/$k$s$G$$$k$3$H$KCm0U$5$l$?$$!%(B | |
215 | |
216 %\subsection{Shell-style \texttt{glob} patterns} | |
217 \subsection{$B%7%'%k7A<0$N(B\texttt{glob}$B%Q%?!<%s(B} | |
218 | |
219 %This is an overview of the kinds of patterns you can use when you're | |
220 %matching on glob patterns. | |
221 | |
222 glob$B%Q%?!<%s$G%^%C%A%s%0$r9T$&;~$K;H$($k%Q%?!<%s$N35N,$r<($9!%(B | |
223 | |
224 %The ``\texttt{*}'' character matches any string, within a single | |
225 %directory. | |
226 | |
227 ``\texttt{*}''$BJ8;z$O%G%#%l%/%H%jFb$NG$0U$NJ8;zNs$H%^%C%A$9$k!%(B | |
228 | |
122 \interaction{filenames.glob.star} | 229 \interaction{filenames.glob.star} |
123 | 230 |
124 The ``\texttt{**}'' pattern matches any string, and crosses directory | 231 %The ``\texttt{**}'' pattern matches any string, and crosses directory |
125 boundaries. It's not a standard Unix glob token, but it's accepted by | 232 %boundaries. It's not a standard Unix glob token, but it's accepted by |
126 several popular Unix shells, and is very useful. | 233 %several popular Unix shells, and is very useful. |
234 %\interaction{filenames.glob.starstar} | |
235 | |
236 ``\texttt{**}''$B%Q%?!<%s$O%G%#%l%/%H%j$r1[$($FG$0U$NJ8;zNs$K%^%C%A$9$k!%$3(B | |
237 $B$l$O(BUnix$BI8=`$N(Bglob$B%H!<%/%s$G$O$J$$$,!$$$$/$D$+$N?M5$$N$"$k(BUnix$B%7%'%k$G;H(B | |
238 $B$&$3$H$,$G$-!$$H$F$bM-MQ$G$"$k!%(B | |
127 \interaction{filenames.glob.starstar} | 239 \interaction{filenames.glob.starstar} |
128 | 240 |
129 The ``\texttt{?}'' pattern matches any single character. | 241 %The ``\texttt{?}'' pattern matches any single character. |
242 %\interaction{filenames.glob.question} | |
243 | |
244 ``\texttt{?}''$B%Q%?!<%s$OG$0U$N(B1$BJ8;z$K%^%C%A$9$k!%(B | |
130 \interaction{filenames.glob.question} | 245 \interaction{filenames.glob.question} |
131 | 246 |
132 The ``\texttt{[}'' character begins a \emph{character class}. This | 247 %The ``\texttt{[}'' character begins a \emph{character class}. This |
133 matches any single character within the class. The class ends with a | 248 %matches any single character within the class. The class ends with a |
134 ``\texttt{]}'' character. A class may contain multiple \emph{range}s | 249 %``\texttt{]}'' character. A class may contain multiple \emph{range}s |
135 of the form ``\texttt{a-f}'', which is shorthand for | 250 %of the form ``\texttt{a-f}'', which is shorthand for |
136 ``\texttt{abcdef}''. | 251 %``\texttt{abcdef}''. |
252 | |
253 ``\texttt{[}''$BJ8;z$O(B\emph{$BJ8;z%/%i%9(B}$B$r3+;O$9$k!%$3$l$O%/%i%9Fb$NG$0U$N(B1 | |
254 $BJ8;z$K%^%C%A$9$k!%%/%i%9$O(B``\texttt{]}''$BJ8;z$G=*$k!%%/%i%9$O(B | |
255 ``\texttt{a-f}''$B$N$h$&$JHO0O$rJ#?t;}$D$3$H$,$G$-$k!%$3$NHO0O$O(B | |
256 ``\texttt{abcdef}''$B$NC;=L7A$KAjEv$9$k!%(B | |
137 \interaction{filenames.glob.range} | 257 \interaction{filenames.glob.range} |
138 If the first character after the ``\texttt{[}'' in a character class | 258 |
139 is a ``\texttt{!}'', it \emph{negates} the class, making it match any | 259 %If the first character after the ``\texttt{[}'' in a character class |
140 single character not in the class. | 260 %is a ``\texttt{!}'', it \emph{negates} the class, making it match any |
141 | 261 %single character not in the class. |
142 A ``\texttt{\{}'' begins a group of subpatterns, where the whole group | 262 |
143 matches if any subpattern in the group matches. The ``\texttt{,}'' | 263 $BJ8;z%/%i%9$G(B``\texttt{[}''$B$N8e$K(B``\texttt{!}''$B$,Mh$?>l9g!$$3$l$O%/%i%9$N(B |
144 character separates subpatterns, and ``\texttt{\}}'' ends the group. | 264 $BH]Dj$H$J$j!$%/%i%9$K4^$^$l$J$$G$0U$N(B1$BJ8;z$H%^%C%A$9$k!%(B |
265 | |
266 %A ``\texttt{\{}'' begins a group of subpatterns, where the whole group | |
267 %matches if any subpattern in the group matches. The ``\texttt{,}'' | |
268 %character separates subpatterns, and ``\texttt{\}}'' ends the group. | |
269 | |
270 ``\texttt{\{}''$B$O%5%V%Q%?!<%s$N%0%k!<%W$r3+;O$9$k!%%0%k!<%W$G$O!$%0%k!<%W(B | |
271 $BFb$NG$0U$N%5%V%Q%?!<%s$,%^%C%A$9$l$P%0%k!<%WA4BN$,%^%C%A$7$?$3$H$K$J$k!%(B | |
272 ``\texttt{,}''$BJ8;z$O%5%V%Q%?!<%s$rJ,N%$7!$(B``\texttt{\}}''$B$O%0%k!<%W$r=*N;(B | |
273 $B$9$k!%(B | |
145 \interaction{filenames.glob.group} | 274 \interaction{filenames.glob.group} |
146 | 275 |
147 \subsubsection{Watch out!} | 276 %\subsubsection{Watch out!} |
148 | 277 \subsubsection{$B$3$3$KCm0U!*(B} |
149 Don't forget that if you want to match a pattern in any directory, you | 278 |
150 should not be using the ``\texttt{*}'' match-any token, as this will | 279 %Don't forget that if you want to match a pattern in any directory, you |
151 only match within one directory. Instead, use the ``\texttt{**}'' | 280 %should not be using the ``\texttt{*}'' match-any token, as this will |
152 token. This small example illustrates the difference between the two. | 281 %only match within one directory. Instead, use the ``\texttt{**}'' |
282 %token. This small example illustrates the difference between the two. | |
283 | |
284 $BG$0U$N%G%#%l%/%H%j$G%Q%?!<%s$r%^%C%A$5$;$k>l9g!$(B``\texttt{*}''$B$rA4$F$H%^%C(B | |
285 $B%A$9$k%H!<%/%s$H$7$F;H$&$3$H$O$G$-$J$$!%$3$NJ8;z$O(B1$B$D$N%G%#%l%/%H%jFb$G$N(B | |
286 $B$_%^%C%A$9$k!%$=$NBe$o$j!$(B``\texttt{**}''$B%H!<%/%s$r;H$&!%$3$l$i$N0c$$$r@b(B | |
287 $BL@$9$k$?$a$KNc$r<($9!%(B | |
288 | |
153 \interaction{filenames.glob.star-starstar} | 289 \interaction{filenames.glob.star-starstar} |
154 | 290 |
155 \subsection{Regular expression matching with \texttt{re} patterns} | 291 %\subsection{Regular expression matching with \texttt{re} patterns} |
156 | 292 \subsection{\texttt{re}$B%Q%?!<%s$r;H$C$?@55,I=8=%^%C%A(B} |
157 Mercurial accepts the same regular expression syntax as the Python | 293 |
158 programming language (it uses Python's regexp engine internally). | 294 %Mercurial accepts the same regular expression syntax as the Python |
159 This is based on the Perl language's regexp syntax, which is the most | 295 %programming language (it uses Python's regexp engine internally). |
160 popular dialect in use (it's also used in Java, for example). | 296 %This is based on the Perl language's regexp syntax, which is the most |
161 | 297 %popular dialect in use (it's also used in Java, for example). |
162 I won't discuss Mercurial's regexp dialect in any detail here, as | 298 |
163 regexps are not often used. Perl-style regexps are in any case | 299 Mercurial$B$O(BPython$B8@8l$HF1$8@55,I=8=9=J8$r<u$1IU$1$k!%!J(BMercurial$B$OFbIt$G(B |
164 already exhaustively documented on a multitude of web sites, and in | 300 Python$B$N@55,I=8=%(%s%8%s$r;H$C$F$$$k!%!K$3$l$O(BPerl$B$N(Bregexp$B9=J8$r85$K$7$F(B |
165 many books. Instead, I will focus here on a few things you should | 301 $B$$$k!%$3$N9=J8$O:G$b$h$/MQ$$$i$l$F$$$k$b$N$G$"$j!$$?$H$($P(BJava$B$G$bMxMQ$5(B |
166 know if you find yourself needing to use regexps with Mercurial. | 302 $B$l$F$$$k!%(B |
167 | 303 |
168 A regexp is matched against an entire file name, relative to the root | 304 %I won't discuss Mercurial's regexp dialect in any detail here, as |
169 of the repository. In other words, even if you're already in | 305 %regexps are not often used. Perl-style regexps are in any case |
170 subbdirectory \dirname{foo}, if you want to match files under this | 306 %already exhaustively documented on a multitude of web sites, and in |
171 directory, your pattern must start with ``\texttt{foo/}''. | 307 %many books. Instead, I will focus here on a few things you should |
172 | 308 %know if you find yourself needing to use regexps with Mercurial. |
173 One thing to note, if you're familiar with Perl-style regexps, is that | 309 |
174 Mercurial's are \emph{rooted}. That is, a regexp starts matching | 310 regexp$B$,$=$l$[$I;H$o$l$F$$$J$$$+$N$h$&$K$3$3$G(BMercurial$B$N(Bregexp$B9=J8$K$D$$(B |
175 against the beginning of a string; it doesn't look for a match | 311 $B$F5DO@$9$k$3$H$OHr$1$k!%(B Perl$B%9%?%$%k(Bregexp$B$O$9$G$KB?$/$N%&%'%V%5%$%H$d=q(B |
176 anywhere within the string. To match anywhere in a string, start | 312 $B@R$G$G>\:Y$KEO$C$F@bL@$5$l$F$$$k!%$=$NBe$o$j!$$3$3$G$O(BMercurial$B$G(Bregexp$B$r(B |
177 your pattern with ``\texttt{.*}''. | 313 $B;H$&:]$KCN$C$F$*$/$Y$-$$$/$D$+$NE@$K>GE@$rEv$F$k$3$H$K$9$k!%(B |
178 | 314 |
179 \section{Filtering files} | 315 %A regexp is matched against an entire file name, relative to the root |
180 | 316 %of the repository. In other words, even if you're already in |
181 Not only does Mercurial give you a variety of ways to specify files; | 317 %subbdirectory \dirname{foo}, if you want to match files under this |
182 it lets you further winnow those files using \emph{filters}. Commands | 318 %directory, your pattern must start with ``\texttt{foo/}''. |
183 that work with file names accept two filtering options. | 319 |
320 regexp$B$O%U%!%$%kL>A4BN$H%^%C%A$9$k$,!$%U%!%$%kL>$O%j%]%8%H%j$N%k!<%H$+$i(B | |
321 $B$NAjBP%Q%9$GI=$5$l$k!%8@$$BX$($l$P!$$9$G$K%5%V%G%#%l%/%H%j(B\dirname{foo}$B$K(B | |
322 $B$$$k$H$7$F!$$3$N%G%#%l%/%H%jFb$N%U%!%$%k$K%^%C%A$5$;$?$1$l(B | |
323 $B$P!$(B``\texttt{foo/}''$B$G;O$^$k%Q%?!<%s$rEO$9I,MW$,$"$k!%(B | |
324 | |
325 %One thing to note, if you're familiar with Perl-style regexps, is that | |
326 %Mercurial's are \emph{rooted}. That is, a regexp starts matching | |
327 %against the beginning of a string; it doesn't look for a match | |
328 %anywhere within the string. To match anywhere in a string, start | |
329 %your pattern with ``\texttt{.*}''. | |
330 | |
331 Perl$B7A<0$N(Bregexp$B$K47$l$F$$$k$N$J$i!$(BMercurial$B$N(Bregexp$B$O(B\emph{root}$B$r;}$D(B | |
332 $B$H$$$&E@$KCm0U$7$F$*$/$H$h$$!%$9$J$o$A!$(Bregexp$B$OJ8;zNs$N;O$^$j$+$i%^%C%A(B | |
333 $B$7!$J8;zNs$NESCf$+$i$O%^%C%A$7$J$$!%J8;zNs$NESCf$+$i%^%C%A$5$;$?$$>l9g(B | |
334 $B$O!$%Q%?!<%s$r(B``\texttt{.*}''$B$G;O$a$kI,MW$,$"$k!%(B | |
335 | |
336 %\section{Filtering files} | |
337 \section{$B%U%!%$%k$r%U%#%k%?$9$k(B} | |
338 | |
339 %Not only does Mercurial give you a variety of ways to specify files; | |
340 %it lets you further winnow those files using \emph{filters}. Commands | |
341 %that work with file names accept two filtering options. | |
342 | |
343 Mercurial$B$O%U%!%$%k$r;XDj$9$kMM!9$JJ}K!$rDs6!$9$k$@$1$G$J$/!$$5$i$K(B | |
344 \emph{$B%U%#%k%?(B}$B$K$h$C$F%U%!%$%k$rA*JL$9$kJ}K!$rDs6!$9$k!%%U%!%$%kL>$r<h$C(B | |
345 $B$FF0:n$9$k%3%^%s%I$O(B2$B$D$N%U%#%k%?%*%W%7%g%s$r<u$1IU$1$k!%(B | |
346 | |
184 \begin{itemize} | 347 \begin{itemize} |
185 \item \hggopt{-I}, or \hggopt{--include}, lets you specify a pattern | 348 %\item \hggopt{-I}, or \hggopt{--include}, lets you specify a pattern |
186 that file names must match in order to be processed. | 349 % that file names must match in order to be processed. |
187 \item \hggopt{-X}, or \hggopt{--exclude}, gives you a way to | 350 \item \hggopt{-I}$B$^$?$O(B\hggopt{--include}$B%*%W%7%g%s$G;XDj$7$?%Q%?!<%s$K(B |
188 \emph{avoid} processing files, if they match this pattern. | 351 $B%^%C%A$7$?%U%!%$%k$,=hM}$5$l$k!%(B |
352 %\item \hggopt{-X}, or \hggopt{--exclude}, gives you a way to | |
353 % \emph{avoid} processing files, if they match this pattern. | |
354 \item \hggopt{-X}$B$^$?$O(B\hggopt{--exclude}$B%*%W%7%g%s$G;XDj$7$?%Q%?!<%s$K(B | |
355 $B%^%C%A$7$?%U%!%$%k$O=hM}$+$i=|30$5$l$k!%(B | |
189 \end{itemize} | 356 \end{itemize} |
190 You can provide multiple \hggopt{-I} and \hggopt{-X} options on the | 357 |
191 command line, and intermix them as you please. Mercurial interprets | 358 %You can provide multiple \hggopt{-I} and \hggopt{-X} options on the |
192 the patterns you provide using glob syntax by default (but you can use | 359 %command line, and intermix them as you please. Mercurial interprets |
193 regexps if you need to). | 360 %the patterns you provide using glob syntax by default (but you can use |
194 | 361 %regexps if you need to). |
195 You can read a \hggopt{-I} filter as ``process only the files that | 362 |
196 match this filter''. | 363 $B%3%^%s%I%i%$%s$GJ#?t$N(B\hggopt{-I}$B$*$h$S(B\hggopt{-X}$B%*%W%7%g%s$r;XDj$7!$=j(B |
364 $BK>$NAH9g$;$K$9$k$3$H$,$G$-$k!%(B Mercurial$B$O%G%U%)%k%H$G$O(Bglob$B9=J8$GM?$($?(B | |
365 $B%Q%?!<%s$r2r<a$9$k$,!$@55,I=8=$r;H$&$3$H$b2DG=$G$"$k!%(B | |
366 | |
367 %You can read a \hggopt{-I} filter as ``process only the files that | |
368 %match this filter''. | |
369 | |
370 \hggopt{-I}$B%U%#%k%?$O(B``$B$3$N%U%#%k%?$K%^%C%A$9$k%U%!%$%k$@$1$r=hM}$9$k(B'' | |
371 $B$HFI$_BX$($k$3$H$,$G$-$k!%(B | |
197 \interaction{filenames.filter.include} | 372 \interaction{filenames.filter.include} |
198 The \hggopt{-X} filter is best read as ``process only the files that | 373 |
199 don't match this pattern''. | 374 %The \hggopt{-X} filter is best read as ``process only the files that |
375 %don't match this pattern''. | |
376 | |
377 \hggopt{-X}$B%U%#%k%?$O(B``$B$3$N%Q%?!<%s$K%^%C%A$7$J$$%U%!%$%k$@$1$r=hM}$9$k(B''$B$H(B | |
378 $BFI$_BX$($k$N$,:G$bAj1~$7$$!%(B | |
200 \interaction{filenames.filter.exclude} | 379 \interaction{filenames.filter.exclude} |
201 | 380 |
202 \section{Ignoring unwanted files and directories} | 381 %\section{Ignoring unwanted files and directories} |
382 \section{$BITMW$J%U%!%$%k$d%G%#%l%/%H%j$rL5;k$9$k(B} | |
203 | 383 |
204 XXX. | 384 XXX. |
205 | 385 |
206 \section{Case sensitivity} | 386 %\section{Case sensitivity} |
387 \section{$BBgJ8;z>.J8;z$N1F6A(B} | |
207 \label{sec:names:case} | 388 \label{sec:names:case} |
208 | 389 |
209 If you're working in a mixed development environment that contains | 390 %If you're working in a mixed development environment that contains |
210 both Linux (or other Unix) systems and Macs or Windows systems, you | 391 %both Linux (or other Unix) systems and Macs or Windows systems, you |
211 should keep in the back of your mind the knowledge that they treat the | 392 %should keep in the back of your mind the knowledge that they treat the |
212 case (``N'' versus ``n'') of file names in incompatible ways. This is | 393 %case (``N'' versus ``n'') of file names in incompatible ways. This is |
213 not very likely to affect you, and it's easy to deal with if it does, | 394 %not very likely to affect you, and it's easy to deal with if it does, |
214 but it could surprise you if you don't know about it. | 395 %but it could surprise you if you don't know about it. |
215 | 396 |
216 Operating systems and filesystems differ in the way they handle the | 397 Linux$B$r$O$8$a$H$9$k(BUnix$B$d(BMac$B!$(BWindows$B$,:.:_$9$k3+H/4D6-$G:n6H$r$7$F$$$k$N(B |
217 \emph{case} of characters in file and directory names. There are | 398 $B$J$i!$3F!9$N%7%9%F%`$O%U%!%$%kL>$N(B(``N''$B$H(B``n'')$B$N$h$&$JBg>.J8;z$r0[$J$C(B |
218 three common ways to handle case in names. | 399 $B$?$d$jJ}$G<h$j07$&$3$H$KN10U$9$Y$-$G$"$k!%$3$l$,LdBj$K$J$k$3$H$OLGB?$K$J(B |
400 $B$/!$LdBj$K$J$k>l9g$G$b4JC1$K2r7h$G$-$k$,!$%7%9%F%`4V$G$N<h$j07$$$N0c$$$r(B | |
401 $BCN$i$J$1$l$P6C$/$3$H$K$J$k$@$m$&!%(B | |
402 | |
403 %Operating systems and filesystems differ in the way they handle the | |
404 %\emph{case} of characters in file and directory names. There are | |
405 %three common ways to handle case in names. | |
406 $B%*%Z%l!<%F%#%s%0%7%9%F%`$H%U%!%$%k%7%9%F%`$O!$%U%!%$%kL>$H%G%#%l%/%H%jL>(B | |
407 $B$N(B\emph{$BBg>.J8;z(B}$B$N07$$$G0[$J$C$F$$$k!%Bg>.J8;z$r07$&J}K!$O(B3$BDL$j$"$k!%(B | |
408 | |
219 \begin{itemize} | 409 \begin{itemize} |
220 \item Completely case insensitive. Uppercase and lowercase versions | 410 %\item Completely case insensitive. Uppercase and lowercase versions |
221 of a letter are treated as identical, both when creating a file and | 411 % of a letter are treated as identical, both when creating a file and |
222 during subsequent accesses. This is common on older DOS-based | 412 % during subsequent accesses. This is common on older DOS-based |
223 systems. | 413 % systems. |
224 \item Case preserving, but insensitive. When a file or directory is | 414 \item $B40A4$KBg>.J8;z$r6hJL$7$J$$!%BgJ8;z$H>.J8;z$O!$%U%!%$%k$N:n@.$H$=(B |
225 created, the case of its name is stored, and can be retrieved and | 415 $B$N8e$N%"%/%;%9$GF10l$K07$o$l$k!%$3$l$O8E$$(BDOS$B%Y!<%9$N%7%9%F%`$GMQ(B |
226 displayed by the operating system. When an existing file is being | 416 $B$$$i$l$F$$$?!%(B |
227 looked up, its case is ignored. This is the standard arrangement on | 417 |
228 Windows and MacOS. The names \filename{foo} and \filename{FoO} | 418 %\item Case preserving, but insensitive. When a file or directory is |
229 identify the same file. This treatment of uppercase and lowercase | 419 % created, the case of its name is stored, and can be retrieved and |
230 letters as interchangeable is also referred to as \emph{case | 420 % displayed by the operating system. When an existing file is being |
231 folding}. | 421 % looked up, its case is ignored. This is the standard arrangement on |
232 \item Case sensitive. The case of a name is significant at all times. | 422 % Windows and MacOS. The names \filename{foo} and \filename{FoO} |
233 The names \filename{foo} and {FoO} identify different files. This | 423 % identify the same file. This treatment of uppercase and lowercase |
234 is the way Linux and Unix systems normally work. | 424 % letters as interchangeable is also referred to as \emph{case |
425 % folding}. | |
426 \item $BBg>.J8;z$N0c$$$OJ]B8$5$l$k$,6hJL$5$l$J$$!%%U%!%$%k$d%G%#%l%/%H%j$,(B | |
427 $B:n$i$l$k$H!$%*%Z%l!<%F%#%s%0%7%9%F%`$OL>A0$NBg>.J8;z$rJ]B8$7!$I=<((B | |
428 $B$J$I$K;HMQ$9$k!%4{B8$N%U%!%$%k$,;2>H$5$l$k;~$O!$Bg>.J8;z$OL5;k$5$l(B | |
429 $B$k!%$3$l$O(BWindows$B$H(BMacOS$B$GI8=`E*$J<h$j07$$$G$"$k!%(B\filename{foo}$B$H(B | |
430 \filename{FoO}$B$OF10l$N%U%!%$%k$HG'<1$5$l$k!%$3$N$h$&$JBg>.J8;z$N<h(B | |
431 $B$j07$$$O(B\emph{case folding}$B$H8F$P$l$k$3$H$b$"$k!%(B | |
432 | |
433 %\item Case sensitive. The case of a name is significant at all times. | |
434 % The names \filename{foo} and {FoO} identify different files. This | |
435 % is the way Linux and Unix systems normally work. | |
436 \item $BBg>.J8;z$r6hJL$9$k!%>o$KBg>.J8;z$GL>A0$r6hJL$9$k!%(B\filename{foo} | |
437 $B$H(B{FoO}$B$OJL$N%U%!%$%k$HG'<1$5$l$k!%$3$l$O(BLinux$B$d(BUnix$B%7%9%F%`$NDL(B | |
438 $B>o$N<h$j07$$$G$"$k!%(B | |
439 | |
235 \end{itemize} | 440 \end{itemize} |
236 | 441 |
237 On Unix-like systems, it is possible to have any or all of the above | 442 %On Unix-like systems, it is possible to have any or all of the above |
238 ways of handling case in action at once. For example, if you use a | 443 %ways of handling case in action at once. For example, if you use a |
239 USB thumb drive formatted with a FAT32 filesystem on a Linux system, | 444 %USB thumb drive formatted with a FAT32 filesystem on a Linux system, |
240 Linux will handle names on that filesystem in a case preserving, but | 445 %Linux will handle names on that filesystem in a case preserving, but |
241 insensitive, way. | 446 %insensitive, way. |
242 | 447 Unix$B7O$N%7%9%F%`$G$OF1;~$K>e5-$NJ}K!$rMxMQ$9$k$3$H$,2DG=$G$"$k!%Nc$($P(B |
243 \subsection{Safe, portable repository storage} | 448 USB$B%a%b%j$r(BLinux$B$G(BFAT32$B%U%!%$%k%7%9%F%`$H$7$F%U%)!<%^%C%H$7$?>l9g!$(B |
244 | 449 Linux$B$O$=$N%U%!%$%k%7%9%F%`>e$N%U%!%$%kL>$rBg>.J8;zJ]B8$@$,6hJL$;$:$K<h$j(B |
245 Mercurial's repository storage mechanism is \emph{case safe}. It | 450 $B07$&!%(B |
246 translates file names so that they can be safely stored on both case | 451 |
247 sensitive and case insensitive filesystems. This means that you can | 452 |
248 use normal file copying tools to transfer a Mercurial repository onto, | 453 %\subsection{Safe, portable repository storage} |
249 for example, a USB thumb drive, and safely move that drive and | 454 \subsection{$B0BA4$G2DHB$J%j%]%8%H%j%9%H%l!<%8(B} |
250 repository back and forth between a Mac, a PC running Windows, and a | 455 |
251 Linux box. | 456 %Mercurial's repository storage mechanism is \emph{case safe}. It |
252 | 457 %translates file names so that they can be safely stored on both case |
253 \subsection{Detecting case conflicts} | 458 %sensitive and case insensitive filesystems. This means that you can |
254 | 459 %use normal file copying tools to transfer a Mercurial repository onto, |
255 When operating in the working directory, Mercurial honours the naming | 460 %for example, a USB thumb drive, and safely move that drive and |
256 policy of the filesystem where the working directory is located. If | 461 %repository back and forth between a Mac, a PC running Windows, and a |
257 the filesystem is case preserving, but insensitive, Mercurial will | 462 %Linux box. |
258 treat names that differ only in case as the same. | 463 |
259 | 464 Mercurial$B$N%j%]%8%H%j3JG<%a%+%K%:%`$O(B\emph{$BBg>.J8;z%;!<%U(B}$B$G$"$k!%(B |
260 An important aspect of this approach is that it is possible to commit | 465 Mercurial$B$OBg>.J8;z$N6hJL$r$9$k%7%9%F%`$G$b$7$J$$%7%9%F%`$G$b0BA4$KJ]B8$G(B |
261 a changeset on a case sensitive (typically Linux or Unix) filesystem | 466 $B$-$k$h$&$K%U%!%$%kL>$rJQ49$9$k!%$3$N$?$a!$DL>o$N%U%!%$%k%3%T!<%D!<%k$r;H$C(B |
262 that will cause trouble for users on case insensitive (usually Windows | 467 $B$F(BMercurial$B%j%]%8%H%j$r(BUSB$B%a%b%j$KE>Aw$7!$(BMac$B!$(BWindows$B$NF0$/(BPC$B!$(BLinux$B%^%7(B |
263 and MacOS) users. If a Linux user commits changes to two files, one | 468 $B%s$N4V$G0\F0$7$F$b0BA4$G$"$k!%(B |
264 named \filename{myfile.c} and the other named \filename{MyFile.C}, | 469 |
265 they will be stored correctly in the repository. And in the working | 470 |
266 directories of other Linux users, they will be correctly represented | 471 %\subsection{Detecting case conflicts} |
267 as separate files. | 472 \subsection{$BBgJ8;z>.J8;z$N>WFM$r8!=P$9$k(B} |
268 | 473 |
269 If a Windows or Mac user pulls this change, they will not initially | 474 %When operating in the working directory, Mercurial honours the naming |
270 have a problem, because Mercurial's repository storage mechanism is | 475 %policy of the filesystem where the working directory is located. If |
271 case safe. However, once they try to \hgcmd{update} the working | 476 %the filesystem is case preserving, but insensitive, Mercurial will |
272 directory to that changeset, or \hgcmd{merge} with that changeset, | 477 %treat names that differ only in case as the same. |
273 Mercurial will spot the conflict between the two file names that the | 478 |
274 filesystem would treat as the same, and forbid the update or merge | 479 $B%o!<%-%s%0%G%#%l%/%H%j$G$NF0:n$N:]$K!$(B Mercurial$B$O%o!<%-%s%0%G%#%l%/%H%j(B |
275 from occurring. | 480 $B$N$"$k%U%!%$%k%7%9%F%`$N%M!<%_%s%0%]%j%7!<$rB:=E$9$k!%Bg>.J8;z$rJ]B8$9$k(B |
276 | 481 $B$,6hJL$7$J$$%U%!%$%k%7%9%F%`$N>l9g!$(BMercurial$B$OL>A0$NBg>.$@$1$,0[$J$C$F$$(B |
277 \subsection{Fixing a case conflict} | 482 $B$k%U%!%$%k$rF1$8%U%!%$%k$H$7$F<h$j07$&!%(B |
278 | 483 |
279 If you are using Windows or a Mac in a mixed environment where some of | 484 %An important aspect of this approach is that it is possible to commit |
280 your collaborators are using Linux or Unix, and Mercurial reports a | 485 %a changeset on a case sensitive (typically Linux or Unix) filesystem |
281 case folding conflict when you try to \hgcmd{update} or \hgcmd{merge}, | 486 %that will cause trouble for users on case insensitive (usually Windows |
282 the procedure to fix the problem is simple. | 487 %and MacOS) users. If a Linux user commits changes to two files, one |
283 | 488 %named \filename{myfile.c} and the other named \filename{MyFile.C}, |
284 Just find a nearby Linux or Unix box, clone the problem repository | 489 %they will be stored correctly in the repository. And in the working |
285 onto it, and use Mercurial's \hgcmd{rename} command to change the | 490 %directories of other Linux users, they will be correctly represented |
286 names of any offending files or directories so that they will no | 491 %as separate files. |
287 longer cause case folding conflicts. Commit this change, \hgcmd{pull} | 492 |
288 or \hgcmd{push} it across to your Windows or MacOS system, and | 493 $B$3$N%"%W%m!<%A$G=EMW$J$N$O!$Bg>.$r6hJL$9$k%U%!%$%k%7%9%F%`!JE57?E*$K$O(B |
289 \hgcmd{update} to the revision with the non-conflicting names. | 494 Linux$B$*$h$S(BUnix$B!K$GBg>.$r6hJL$7$J$$%7%9%F%`!JDL>o!$(BWindows$B$^$?$O(BMacOS$B!K$N(B |
290 | 495 $B%f!<%6$K$H$C$F%H%i%V%k$H$J$k$h$&$J%A%'%s%8%;%C%H$r%3%_%C%H$9$k$3$H$,2DG=(B |
291 The changeset with case-conflicting names will remain in your | 496 $B$G$"$k$H$$$&E@$G$"$k!%$b$7(BLinux$B%f!<%6$,(B\filename{myfile.c}$B$H$$$&%U%!%$%k(B |
292 project's history, and you still won't be able to \hgcmd{update} your | 497 $B$H(B\filename{MyFile.C}$B$H$$$&%U%!%$%k$KBP$9$k%A%'%s%8%;%C%H$r%3%_%C%H$7$?>l(B |
293 working directory to that changeset on a Windows or MacOS system, but | 498 $B9g!$$=$l$i$O%j%]%8%H%j$K@5$7$/J]B8$5$l!$B>$N(BLinux$B%f!<%6$N%o!<%-%s%0%G%#%l(B |
294 you can continue development unimpeded. | 499 $B%/%H%j$G$b@5$7$/JL!9$N%U%!%$%k$H$7$F8=$l$k!%(B |
500 | |
501 %If a Windows or Mac user pulls this change, they will not initially | |
502 %have a problem, because Mercurial's repository storage mechanism is | |
503 %case safe. However, once they try to \hgcmd{update} the working | |
504 %directory to that changeset, or \hgcmd{merge} with that changeset, | |
505 %Mercurial will spot the conflict between the two file names that the | |
506 %filesystem would treat as the same, and forbid the update or merge | |
507 %from occurring. | |
508 | |
509 $B$3$3$G(BWindows$B$^$?$O(BMac$B$N%f!<%6$,$3$N%A%'%s%8%;%C%H$r(Bpull$B$9$k$H!$(B | |
510 Mercurial$B$N%j%]%8%H%j3JG<%a%+%K%:%`$OBg>.J8;z$KBP$7$F0BA4$J$?$a!$:G=i$N$&(B | |
511 $B$A$OLdBj$H$J$i$J$$!%$7$+$7%o!<%-%s%0%G%#%l%/%H%j$r$=$N%A%'%s%8%;%C%H$K(B | |
512 \hgcmd{update}$B$7$h$&$H$7$?$j!$$=$N%A%'%s%8%;%C%H$H(B\hgcmd{merge}$B$7$h$&$H$9(B | |
513 $B$k$H!$(BMercurial$B$O!$(B 2$B$D$N%U%!%$%kL>$r%U%!%$%k%7%9%F%`$,F1$8L>A0$H$7$F07$&(B | |
514 $B$?$a$K@8$8$k%3%s%U%j%/%H$r8!=P$7!$(B update$B$d(Bmerge$B$r5v$5$J$$!%(B | |
515 | |
516 %\subsection{Fixing a case conflict} | |
517 \subsection{$BBgJ8;z>.J8;z$N>WFM$r2r7h$9$k(B} | |
518 | |
519 %If you are using Windows or a Mac in a mixed environment where some of | |
520 %your collaborators are using Linux or Unix, and Mercurial reports a | |
521 %case folding conflict when you try to \hgcmd{update} or \hgcmd{merge}, | |
522 %the procedure to fix the problem is simple. | |
523 | |
524 $B$b$7$"$J$?$,(BWindows$B$d(BMac$B$r;H$C$F$$$F!$2??M$+$N6(NO<T$,(BLinux$B$^$?$O(BUnix$B$r;H$C(B | |
525 $B$F$$$k:.9g4D6-$G3+H/$r$7$F$*$j!$(B \hgcmd{update}$B$^$?$O(B\hgcmd{merge}$B$G(B | |
526 Mercurial$B$,Bg>.J8;z$N%3%s%U%j%/%H$r8!=P$9$k$N$G$"$l$P!$2r7hJ}K!$O%7%s%W%k(B | |
527 $B$G$"$k!%(B | |
528 | |
529 %Just find a nearby Linux or Unix box, clone the problem repository | |
530 %onto it, and use Mercurial's \hgcmd{rename} command to change the | |
531 %names of any offending files or directories so that they will no | |
532 %longer cause case folding conflicts. Commit this change, \hgcmd{pull} | |
533 %or \hgcmd{push} it across to your Windows or MacOS system, and | |
534 %\hgcmd{update} to the revision with the non-conflicting names. | |
535 | |
536 $B<j6a$J(BLinux$B$^$?$O(BUnix$B%^%7%s$N>e$K!$LdBj$N$"$k%j%]%8%H%j$r%/%m!<%s$7!$(B | |
537 Mercurial$B$N(B\hgcmd{rename}$B$r<B9T$7$FLdBj$N$"$k%U%!%$%k$d%G%#%l%/%H%j$NL>A0(B | |
538 $B$rJQ99$7!$%3%s%U%j%/%H$r2r7h$9$k!%$3$NJQ99$r%3%_%C%H$7!$(B\hgcmd{pull}$B$^$?(B | |
539 $B$O(B\hgcmd{push}$B%3%^%s%I$G$"$J$?$N(BWindows$B$^$?$O(BMacOS$B%7%9%F%`$KE>Aw(B | |
540 $B$7!$(B\hgcmd{update}$B$G%3%s%U%j%/%H$N$J$$%j%S%8%g%s$X99?7$9$l$P$h$$!%(B | |
541 | |
542 %The changeset with case-conflicting names will remain in your | |
543 %project's history, and you still won't be able to \hgcmd{update} your | |
544 %working directory to that changeset on a Windows or MacOS system, but | |
545 %you can continue development unimpeded. | |
546 | |
547 $BBg>.J8;z$N%U%!%$%kL>%3%s%U%j%/%H$,$"$k%A%'%s%8%;%C%H$O%W%m%8%'%/%H$NMzNr(B | |
548 $B$K;D$C$F$*$j!$(B Windows$B$d(BMacOS$B$7$9$F$`$G$O$=$N%A%'%s%8%;%C%H$X(B | |
549 \hgcmd{update}$B$9$k$3$H$O$G$-$J$$$b$N$N!$LdBj$J$/3+H/$rB3$1$k$3$H$,$G$-$k!%(B | |
295 | 550 |
296 \begin{note} | 551 \begin{note} |
297 Prior to version~0.9.3, Mercurial did not use a case safe repository | 552 % Prior to version~0.9.3, Mercurial did not use a case safe repository |
298 storage mechanism, and did not detect case folding conflicts. If | 553 % storage mechanism, and did not detect case folding conflicts. If |
299 you are using an older version of Mercurial on Windows or MacOS, I | 554 % you are using an older version of Mercurial on Windows or MacOS, I |
300 strongly recommend that you upgrade. | 555 % strongly recommend that you upgrade. |
556 0.9.3$B$h$jA0$N(BMercurial$B$O(Bcase$B%;!<%U$N%9%H%l!<%85!9=$r;H$C$F$*$i$:!$(Bcase$B$N(B | |
557 $B>WFM$r8!=P$G$-$J$+$C$?!%(BWindows$B$d(BMacOS$B$G8E$$%P!<%8%g%s$N(BMercurial$B$r;H$C(B | |
558 $B$F$$$k$J$i$P!$%"%C%W%G!<%H$9$k$3$H$r6/$/4+$a$k!%(B | |
301 \end{note} | 559 \end{note} |
302 | 560 |
303 %%% Local Variables: | 561 %%% Local Variables: |
304 %%% mode: yatex | 562 %%% mode: yatex |
305 %%% TeX-master: "00book" | 563 %%% TeX-master: "00book" |
306 %%% End: | 564 %%% End: |