Mercurial > hgbook
comparison en/ch05-collab.xml @ 683:c838b3975bc6
Add IDs to paragraphs.
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Thu, 19 Mar 2009 21:18:52 -0700 |
parents | 28b5a5befb08 |
children | b788b405e141 |
comparison
equal
deleted
inserted
replaced
682:28b5a5befb08 | 683:c838b3975bc6 |
---|---|
2 | 2 |
3 <chapter id="cha:collab"> | 3 <chapter id="cha:collab"> |
4 <?dbhtml filename="collaborating-with-other-people.html"?> | 4 <?dbhtml filename="collaborating-with-other-people.html"?> |
5 <title>Collaborating with other people</title> | 5 <title>Collaborating with other people</title> |
6 | 6 |
7 <para>As a completely decentralised tool, Mercurial doesn't impose | 7 <para id="x_44a">As a completely decentralised tool, Mercurial doesn't impose |
8 any policy on how people ought to work with each other. However, | 8 any policy on how people ought to work with each other. However, |
9 if you're new to distributed revision control, it helps to have | 9 if you're new to distributed revision control, it helps to have |
10 some tools and examples in mind when you're thinking about | 10 some tools and examples in mind when you're thinking about |
11 possible workflow models.</para> | 11 possible workflow models.</para> |
12 | 12 |
13 <sect1> | 13 <sect1> |
14 <title>Mercurial's web interface</title> | 14 <title>Mercurial's web interface</title> |
15 | 15 |
16 <para>Mercurial has a powerful web interface that provides several | 16 <para id="x_44b">Mercurial has a powerful web interface that provides several |
17 useful capabilities.</para> | 17 useful capabilities.</para> |
18 | 18 |
19 <para>For interactive use, the web interface lets you browse a | 19 <para id="x_44c">For interactive use, the web interface lets you browse a |
20 single repository or a collection of repositories. You can view | 20 single repository or a collection of repositories. You can view |
21 the history of a repository, examine each change (comments and | 21 the history of a repository, examine each change (comments and |
22 diffs), and view the contents of each directory and file.</para> | 22 diffs), and view the contents of each directory and file.</para> |
23 | 23 |
24 <para>Also for human consumption, the web interface provides an | 24 <para id="x_44d">Also for human consumption, the web interface provides an |
25 RSS feed of the changes in a repository. This lets you | 25 RSS feed of the changes in a repository. This lets you |
26 <quote>subscribe</quote> to a repository using your favourite | 26 <quote>subscribe</quote> to a repository using your favourite |
27 feed reader, and be automatically notified of activity in that | 27 feed reader, and be automatically notified of activity in that |
28 repository as soon as it happens. I find this capability much | 28 repository as soon as it happens. I find this capability much |
29 more convenient than the model of subscribing to a mailing list | 29 more convenient than the model of subscribing to a mailing list |
30 to which notifications are sent, as it requires no additional | 30 to which notifications are sent, as it requires no additional |
31 configuration on the part of whoever is serving the | 31 configuration on the part of whoever is serving the |
32 repository.</para> | 32 repository.</para> |
33 | 33 |
34 <para>The web interface also lets remote users clone a repository, | 34 <para id="x_44e">The web interface also lets remote users clone a repository, |
35 pull changes from it, and (when the server is configured to | 35 pull changes from it, and (when the server is configured to |
36 permit it) push changes back to it. Mercurial's HTTP tunneling | 36 permit it) push changes back to it. Mercurial's HTTP tunneling |
37 protocol aggressively compresses data, so that it works | 37 protocol aggressively compresses data, so that it works |
38 efficiently even over low-bandwidth network connections.</para> | 38 efficiently even over low-bandwidth network connections.</para> |
39 | 39 |
40 <para>The easiest way to get started with the web interface is to | 40 <para id="x_44f">The easiest way to get started with the web interface is to |
41 use your web browser to visit an existing repository, such as | 41 use your web browser to visit an existing repository, such as |
42 the master Mercurial repository at <ulink | 42 the master Mercurial repository at <ulink |
43 url="http://www.selenic.com/repo/hg?style=gitweb">http://www.selenic.com/repo/hg?style=gitweb</ulink>.</para> | 43 url="http://www.selenic.com/repo/hg?style=gitweb">http://www.selenic.com/repo/hg?style=gitweb</ulink>.</para> |
44 | 44 |
45 <para>If you're interested in providing a web interface to your | 45 <para id="x_450">If you're interested in providing a web interface to your |
46 own repositories, Mercurial provides two ways to do this. The | 46 own repositories, Mercurial provides two ways to do this. The |
47 first is using the <command role="hg-cmd">hg serve</command> | 47 first is using the <command role="hg-cmd">hg serve</command> |
48 command, which is best suited to short-term | 48 command, which is best suited to short-term |
49 <quote>lightweight</quote> serving. See section <xref | 49 <quote>lightweight</quote> serving. See section <xref |
50 linkend="sec:collab:serve"/> below for details of how to use | 50 linkend="sec:collab:serve"/> below for details of how to use |
57 | 57 |
58 </sect1> | 58 </sect1> |
59 <sect1> | 59 <sect1> |
60 <title>Collaboration models</title> | 60 <title>Collaboration models</title> |
61 | 61 |
62 <para>With a suitably flexible tool, making decisions about | 62 <para id="x_451">With a suitably flexible tool, making decisions about |
63 workflow is much more of a social engineering challenge than a | 63 workflow is much more of a social engineering challenge than a |
64 technical one. Mercurial imposes few limitations on how you can | 64 technical one. Mercurial imposes few limitations on how you can |
65 structure the flow of work in a project, so it's up to you and | 65 structure the flow of work in a project, so it's up to you and |
66 your group to set up and live with a model that matches your own | 66 your group to set up and live with a model that matches your own |
67 particular needs.</para> | 67 particular needs.</para> |
68 | 68 |
69 <sect2> | 69 <sect2> |
70 <title>Factors to keep in mind</title> | 70 <title>Factors to keep in mind</title> |
71 | 71 |
72 <para>The most important aspect of any model that you must keep | 72 <para id="x_452">The most important aspect of any model that you must keep |
73 in mind is how well it matches the needs and capabilities of | 73 in mind is how well it matches the needs and capabilities of |
74 the people who will be using it. This might seem | 74 the people who will be using it. This might seem |
75 self-evident; even so, you still can't afford to forget it for | 75 self-evident; even so, you still can't afford to forget it for |
76 a moment.</para> | 76 a moment.</para> |
77 | 77 |
78 <para>I once put together a workflow model that seemed to make | 78 <para id="x_453">I once put together a workflow model that seemed to make |
79 perfect sense to me, but that caused a considerable amount of | 79 perfect sense to me, but that caused a considerable amount of |
80 consternation and strife within my development team. In spite | 80 consternation and strife within my development team. In spite |
81 of my attempts to explain why we needed a complex set of | 81 of my attempts to explain why we needed a complex set of |
82 branches, and how changes ought to flow between them, a few | 82 branches, and how changes ought to flow between them, a few |
83 team members revolted. Even though they were smart people, | 83 team members revolted. Even though they were smart people, |
84 they didn't want to pay attention to the constraints we were | 84 they didn't want to pay attention to the constraints we were |
85 operating under, or face the consequences of those constraints | 85 operating under, or face the consequences of those constraints |
86 in the details of the model that I was advocating.</para> | 86 in the details of the model that I was advocating.</para> |
87 | 87 |
88 <para>Don't sweep foreseeable social or technical problems under | 88 <para id="x_454">Don't sweep foreseeable social or technical problems under |
89 the rug. Whatever scheme you put into effect, you should plan | 89 the rug. Whatever scheme you put into effect, you should plan |
90 for mistakes and problem scenarios. Consider adding automated | 90 for mistakes and problem scenarios. Consider adding automated |
91 machinery to prevent, or quickly recover from, trouble that | 91 machinery to prevent, or quickly recover from, trouble that |
92 you can anticipate. As an example, if you intend to have a | 92 you can anticipate. As an example, if you intend to have a |
93 branch with not-for-release changes in it, you'd do well to | 93 branch with not-for-release changes in it, you'd do well to |
99 | 99 |
100 </sect2> | 100 </sect2> |
101 <sect2> | 101 <sect2> |
102 <title>Informal anarchy</title> | 102 <title>Informal anarchy</title> |
103 | 103 |
104 <para>I wouldn't suggest an <quote>anything goes</quote> | 104 <para id="x_455">I wouldn't suggest an <quote>anything goes</quote> |
105 approach as something sustainable, but it's a model that's | 105 approach as something sustainable, but it's a model that's |
106 easy to grasp, and it works perfectly well in a few unusual | 106 easy to grasp, and it works perfectly well in a few unusual |
107 situations.</para> | 107 situations.</para> |
108 | 108 |
109 <para>As one example, many projects have a loose-knit group of | 109 <para id="x_456">As one example, many projects have a loose-knit group of |
110 collaborators who rarely physically meet each other. Some | 110 collaborators who rarely physically meet each other. Some |
111 groups like to overcome the isolation of working at a distance | 111 groups like to overcome the isolation of working at a distance |
112 by organising occasional <quote>sprints</quote>. In a sprint, | 112 by organising occasional <quote>sprints</quote>. In a sprint, |
113 a number of people get together in a single location (a | 113 a number of people get together in a single location (a |
114 company's conference room, a hotel meeting room, that kind of | 114 company's conference room, a hotel meeting room, that kind of |
115 place) and spend several days more or less locked in there, | 115 place) and spend several days more or less locked in there, |
116 hacking intensely on a handful of projects.</para> | 116 hacking intensely on a handful of projects.</para> |
117 | 117 |
118 <para>A sprint is the perfect place to use the <command | 118 <para id="x_457">A sprint is the perfect place to use the <command |
119 role="hg-cmd">hg serve</command> command, since <command | 119 role="hg-cmd">hg serve</command> command, since <command |
120 role="hg-cmd">hg serve</command> does not require any fancy | 120 role="hg-cmd">hg serve</command> does not require any fancy |
121 server infrastructure. You can get started with <command | 121 server infrastructure. You can get started with <command |
122 role="hg-cmd">hg serve</command> in moments, by reading | 122 role="hg-cmd">hg serve</command> in moments, by reading |
123 section <xref linkend="sec:collab:serve"/> below. Then simply | 123 section <xref linkend="sec:collab:serve"/> below. Then simply |
127 quick-turnaround way to work together. They can type your URL | 127 quick-turnaround way to work together. They can type your URL |
128 into their web browser and quickly review your changes; or | 128 into their web browser and quickly review your changes; or |
129 they can pull a bugfix from you and verify it; or they can | 129 they can pull a bugfix from you and verify it; or they can |
130 clone a branch containing a new feature and try it out.</para> | 130 clone a branch containing a new feature and try it out.</para> |
131 | 131 |
132 <para>The charm, and the problem, with doing things in an ad hoc | 132 <para id="x_458">The charm, and the problem, with doing things in an ad hoc |
133 fashion like this is that only people who know about your | 133 fashion like this is that only people who know about your |
134 changes, and where they are, can see them. Such an informal | 134 changes, and where they are, can see them. Such an informal |
135 approach simply doesn't scale beyond a handful people, because | 135 approach simply doesn't scale beyond a handful people, because |
136 each individual needs to know about $n$ different repositories | 136 each individual needs to know about $n$ different repositories |
137 to pull from.</para> | 137 to pull from.</para> |
138 | 138 |
139 </sect2> | 139 </sect2> |
140 <sect2> | 140 <sect2> |
141 <title>A single central repository</title> | 141 <title>A single central repository</title> |
142 | 142 |
143 <para>For smaller projects migrating from a centralised revision | 143 <para id="x_459">For smaller projects migrating from a centralised revision |
144 control tool, perhaps the easiest way to get started is to | 144 control tool, perhaps the easiest way to get started is to |
145 have changes flow through a single shared central repository. | 145 have changes flow through a single shared central repository. |
146 This is also the most common <quote>building block</quote> for | 146 This is also the most common <quote>building block</quote> for |
147 more ambitious workflow schemes.</para> | 147 more ambitious workflow schemes.</para> |
148 | 148 |
149 <para>Contributors start by cloning a copy of this repository. | 149 <para id="x_45a">Contributors start by cloning a copy of this repository. |
150 They can pull changes from it whenever they need to, and some | 150 They can pull changes from it whenever they need to, and some |
151 (perhaps all) developers have permission to push a change back | 151 (perhaps all) developers have permission to push a change back |
152 when they're ready for other people to see it.</para> | 152 when they're ready for other people to see it.</para> |
153 | 153 |
154 <para>Under this model, it can still often make sense for people | 154 <para id="x_45b">Under this model, it can still often make sense for people |
155 to pull changes directly from each other, without going | 155 to pull changes directly from each other, without going |
156 through the central repository. Consider a case in which I | 156 through the central repository. Consider a case in which I |
157 have a tentative bug fix, but I am worried that if I were to | 157 have a tentative bug fix, but I am worried that if I were to |
158 publish it to the central repository, it might subsequently | 158 publish it to the central repository, it might subsequently |
159 break everyone else's trees as they pull it. To reduce the | 159 break everyone else's trees as they pull it. To reduce the |
160 potential for damage, I can ask you to clone my repository | 160 potential for damage, I can ask you to clone my repository |
161 into a temporary repository of your own and test it. This | 161 into a temporary repository of your own and test it. This |
162 lets us put off publishing the potentially unsafe change until | 162 lets us put off publishing the potentially unsafe change until |
163 it has had a little testing.</para> | 163 it has had a little testing.</para> |
164 | 164 |
165 <para>In this kind of scenario, people usually use the | 165 <para id="x_45c">In this kind of scenario, people usually use the |
166 <command>ssh</command> protocol to securely push changes to | 166 <command>ssh</command> protocol to securely push changes to |
167 the central repository, as documented in section <xref | 167 the central repository, as documented in section <xref |
168 linkend="sec:collab:ssh"/>. It's also | 168 linkend="sec:collab:ssh"/>. It's also |
169 usual to publish a read-only copy of the repository over HTTP | 169 usual to publish a read-only copy of the repository over HTTP |
170 using CGI, as in section <xref linkend="sec:collab:cgi"/>. | 170 using CGI, as in section <xref linkend="sec:collab:cgi"/>. |
175 | 175 |
176 </sect2> | 176 </sect2> |
177 <sect2> | 177 <sect2> |
178 <title>Working with multiple branches</title> | 178 <title>Working with multiple branches</title> |
179 | 179 |
180 <para>Projects of any significant size naturally tend to make | 180 <para id="x_45d">Projects of any significant size naturally tend to make |
181 progress on several fronts simultaneously. In the case of | 181 progress on several fronts simultaneously. In the case of |
182 software, it's common for a project to go through periodic | 182 software, it's common for a project to go through periodic |
183 official releases. A release might then go into | 183 official releases. A release might then go into |
184 <quote>maintenance mode</quote> for a while after its first | 184 <quote>maintenance mode</quote> for a while after its first |
185 publication; maintenance releases tend to contain only bug | 185 publication; maintenance releases tend to contain only bug |
188 development. People normally use the word | 188 development. People normally use the word |
189 <quote>branch</quote> to refer to one of these many slightly | 189 <quote>branch</quote> to refer to one of these many slightly |
190 different directions in which development is | 190 different directions in which development is |
191 proceeding.</para> | 191 proceeding.</para> |
192 | 192 |
193 <para>Mercurial is particularly well suited to managing a number | 193 <para id="x_45e">Mercurial is particularly well suited to managing a number |
194 of simultaneous, but not identical, branches. Each | 194 of simultaneous, but not identical, branches. Each |
195 <quote>development direction</quote> can live in its own | 195 <quote>development direction</quote> can live in its own |
196 central repository, and you can merge changes from one to | 196 central repository, and you can merge changes from one to |
197 another as the need arises. Because repositories are | 197 another as the need arises. Because repositories are |
198 independent of each other, unstable changes in a development | 198 independent of each other, unstable changes in a development |
199 branch will never affect a stable branch unless someone | 199 branch will never affect a stable branch unless someone |
200 explicitly merges those changes in.</para> | 200 explicitly merges those changes in.</para> |
201 | 201 |
202 <para>Here's an example of how this can work in practice. Let's | 202 <para id="x_45f">Here's an example of how this can work in practice. Let's |
203 say you have one <quote>main branch</quote> on a central | 203 say you have one <quote>main branch</quote> on a central |
204 server.</para> | 204 server.</para> |
205 | 205 |
206 &interaction.branching.init; | 206 &interaction.branching.init; |
207 | 207 |
208 <para>People clone it, make changes locally, test them, and push | 208 <para id="x_460">People clone it, make changes locally, test them, and push |
209 them back.</para> | 209 them back.</para> |
210 | 210 |
211 <para>Once the main branch reaches a release milestone, you can | 211 <para id="x_461">Once the main branch reaches a release milestone, you can |
212 use the <command role="hg-cmd">hg tag</command> command to | 212 use the <command role="hg-cmd">hg tag</command> command to |
213 give a permanent name to the milestone revision.</para> | 213 give a permanent name to the milestone revision.</para> |
214 | 214 |
215 &interaction.branching.tag; | 215 &interaction.branching.tag; |
216 | 216 |
217 <para>Let's say some ongoing | 217 <para id="x_462">Let's say some ongoing |
218 development occurs on the main branch.</para> | 218 development occurs on the main branch.</para> |
219 | 219 |
220 &interaction.branching.main; | 220 &interaction.branching.main; |
221 | 221 |
222 <para>Using the tag that was recorded at the milestone, people | 222 <para id="x_463">Using the tag that was recorded at the milestone, people |
223 who clone that repository at any time in the future can use | 223 who clone that repository at any time in the future can use |
224 <command role="hg-cmd">hg update</command> to get a copy of | 224 <command role="hg-cmd">hg update</command> to get a copy of |
225 the working directory exactly as it was when that tagged | 225 the working directory exactly as it was when that tagged |
226 revision was committed.</para> | 226 revision was committed.</para> |
227 | 227 |
228 &interaction.branching.update; | 228 &interaction.branching.update; |
229 | 229 |
230 <para>In addition, immediately after the main branch is tagged, | 230 <para id="x_464">In addition, immediately after the main branch is tagged, |
231 someone can then clone the main branch on the server to a new | 231 someone can then clone the main branch on the server to a new |
232 <quote>stable</quote> branch, also on the server.</para> | 232 <quote>stable</quote> branch, also on the server.</para> |
233 | 233 |
234 &interaction.branching.clone; | 234 &interaction.branching.clone; |
235 | 235 |
236 <para>Someone who needs to make a change to the stable branch | 236 <para id="x_465">Someone who needs to make a change to the stable branch |
237 can then clone <emphasis>that</emphasis> repository, make | 237 can then clone <emphasis>that</emphasis> repository, make |
238 their changes, commit, and push their changes back there.</para> | 238 their changes, commit, and push their changes back there.</para> |
239 | 239 |
240 &interaction.branching.stable; | 240 &interaction.branching.stable; |
241 | 241 |
242 <para>Because Mercurial repositories are independent, and | 242 <para id="x_466">Because Mercurial repositories are independent, and |
243 Mercurial doesn't move changes around automatically, the | 243 Mercurial doesn't move changes around automatically, the |
244 stable and main branches are <emphasis>isolated</emphasis> | 244 stable and main branches are <emphasis>isolated</emphasis> |
245 from each other. The changes that you made on the main branch | 245 from each other. The changes that you made on the main branch |
246 don't <quote>leak</quote> to the stable branch, and vice | 246 don't <quote>leak</quote> to the stable branch, and vice |
247 versa.</para> | 247 versa.</para> |
248 | 248 |
249 <para>You'll often want all of your bugfixes on the stable | 249 <para id="x_467">You'll often want all of your bugfixes on the stable |
250 branch to show up on the main branch, too. Rather than | 250 branch to show up on the main branch, too. Rather than |
251 rewrite a bugfix on the main branch, you can simply pull and | 251 rewrite a bugfix on the main branch, you can simply pull and |
252 merge changes from the stable to the main branch, and | 252 merge changes from the stable to the main branch, and |
253 Mercurial will bring those bugfixes in for you.</para> | 253 Mercurial will bring those bugfixes in for you.</para> |
254 | 254 |
255 &interaction.branching.merge; | 255 &interaction.branching.merge; |
256 | 256 |
257 <para>The main branch will still contain changes that are not on | 257 <para id="x_468">The main branch will still contain changes that are not on |
258 the stable branch, but it will also contain all of the | 258 the stable branch, but it will also contain all of the |
259 bugfixes from the stable branch. The stable branch remains | 259 bugfixes from the stable branch. The stable branch remains |
260 unaffected by these changes.</para> | 260 unaffected by these changes.</para> |
261 | 261 |
262 </sect2> | 262 </sect2> |
263 <sect2> | 263 <sect2> |
264 <title>Feature branches</title> | 264 <title>Feature branches</title> |
265 | 265 |
266 <para>For larger projects, an effective way to manage change is | 266 <para id="x_469">For larger projects, an effective way to manage change is |
267 to break up a team into smaller groups. Each group has a | 267 to break up a team into smaller groups. Each group has a |
268 shared branch of its own, cloned from a single | 268 shared branch of its own, cloned from a single |
269 <quote>master</quote> branch used by the entire project. | 269 <quote>master</quote> branch used by the entire project. |
270 People working on an individual branch are typically quite | 270 People working on an individual branch are typically quite |
271 isolated from developments on other branches.</para> | 271 isolated from developments on other branches.</para> |
272 | 272 |
273 <informalfigure id="fig:collab:feature-branches"> | 273 <informalfigure id="fig:collab:feature-branches"> |
274 <mediaobject><imageobject><imagedata | 274 <mediaobject><imageobject><imagedata |
275 fileref="feature-branches"/></imageobject><textobject><phrase>XXX | 275 fileref="feature-branches"/></imageobject><textobject><phrase>XXX |
276 add text</phrase></textobject><caption><para>Feature | 276 add text</phrase></textobject><caption><para id="x_46a">Feature |
277 branches</para></caption></mediaobject> | 277 branches</para></caption></mediaobject> |
278 </informalfigure> | 278 </informalfigure> |
279 | 279 |
280 <para>When a particular feature is deemed to be in suitable | 280 <para id="x_46b">When a particular feature is deemed to be in suitable |
281 shape, someone on that feature team pulls and merges from the | 281 shape, someone on that feature team pulls and merges from the |
282 master branch into the feature branch, then pushes back up to | 282 master branch into the feature branch, then pushes back up to |
283 the master branch.</para> | 283 the master branch.</para> |
284 | 284 |
285 </sect2> | 285 </sect2> |
286 <sect2> | 286 <sect2> |
287 <title>The release train</title> | 287 <title>The release train</title> |
288 | 288 |
289 <para>Some projects are organised on a <quote>train</quote> | 289 <para id="x_46c">Some projects are organised on a <quote>train</quote> |
290 basis: a release is scheduled to happen every few months, and | 290 basis: a release is scheduled to happen every few months, and |
291 whatever features are ready when the <quote>train</quote> is | 291 whatever features are ready when the <quote>train</quote> is |
292 ready to leave are allowed in.</para> | 292 ready to leave are allowed in.</para> |
293 | 293 |
294 <para>This model resembles working with feature branches. The | 294 <para id="x_46d">This model resembles working with feature branches. The |
295 difference is that when a feature branch misses a train, | 295 difference is that when a feature branch misses a train, |
296 someone on the feature team pulls and merges the changes that | 296 someone on the feature team pulls and merges the changes that |
297 went out on that train release into the feature branch, and | 297 went out on that train release into the feature branch, and |
298 the team continues its work on top of that release so that | 298 the team continues its work on top of that release so that |
299 their feature can make the next release.</para> | 299 their feature can make the next release.</para> |
300 | 300 |
301 </sect2> | 301 </sect2> |
302 <sect2> | 302 <sect2> |
303 <title>The Linux kernel model</title> | 303 <title>The Linux kernel model</title> |
304 | 304 |
305 <para>The development of the Linux kernel has a shallow | 305 <para id="x_46e">The development of the Linux kernel has a shallow |
306 hierarchical structure, surrounded by a cloud of apparent | 306 hierarchical structure, surrounded by a cloud of apparent |
307 chaos. Because most Linux developers use | 307 chaos. Because most Linux developers use |
308 <command>git</command>, a distributed revision control tool | 308 <command>git</command>, a distributed revision control tool |
309 with capabilities similar to Mercurial, it's useful to | 309 with capabilities similar to Mercurial, it's useful to |
310 describe the way work flows in that environment; if you like | 310 describe the way work flows in that environment; if you like |
311 the ideas, the approach translates well across tools.</para> | 311 the ideas, the approach translates well across tools.</para> |
312 | 312 |
313 <para>At the center of the community sits Linus Torvalds, the | 313 <para id="x_46f">At the center of the community sits Linus Torvalds, the |
314 creator of Linux. He publishes a single source repository | 314 creator of Linux. He publishes a single source repository |
315 that is considered the <quote>authoritative</quote> current | 315 that is considered the <quote>authoritative</quote> current |
316 tree by the entire developer community. Anyone can clone | 316 tree by the entire developer community. Anyone can clone |
317 Linus's tree, but he is very choosy about whose trees he pulls | 317 Linus's tree, but he is very choosy about whose trees he pulls |
318 from.</para> | 318 from.</para> |
319 | 319 |
320 <para>Linus has a number of <quote>trusted lieutenants</quote>. | 320 <para id="x_470">Linus has a number of <quote>trusted lieutenants</quote>. |
321 As a general rule, he pulls whatever changes they publish, in | 321 As a general rule, he pulls whatever changes they publish, in |
322 most cases without even reviewing those changes. Some of | 322 most cases without even reviewing those changes. Some of |
323 those lieutenants are generally agreed to be | 323 those lieutenants are generally agreed to be |
324 <quote>maintainers</quote>, responsible for specific | 324 <quote>maintainers</quote>, responsible for specific |
325 subsystems within the kernel. If a random kernel hacker wants | 325 subsystems within the kernel. If a random kernel hacker wants |
327 Linus's tree, they must find out who the subsystem's | 327 Linus's tree, they must find out who the subsystem's |
328 maintainer is, and ask that maintainer to take their change. | 328 maintainer is, and ask that maintainer to take their change. |
329 If the maintainer reviews their changes and agrees to take | 329 If the maintainer reviews their changes and agrees to take |
330 them, they'll pass them along to Linus in due course.</para> | 330 them, they'll pass them along to Linus in due course.</para> |
331 | 331 |
332 <para>Individual lieutenants have their own approaches to | 332 <para id="x_471">Individual lieutenants have their own approaches to |
333 reviewing, accepting, and publishing changes; and for deciding | 333 reviewing, accepting, and publishing changes; and for deciding |
334 when to feed them to Linus. In addition, there are several | 334 when to feed them to Linus. In addition, there are several |
335 well known branches that people use for different purposes. | 335 well known branches that people use for different purposes. |
336 For example, a few people maintain <quote>stable</quote> | 336 For example, a few people maintain <quote>stable</quote> |
337 repositories of older versions of the kernel, to which they | 337 repositories of older versions of the kernel, to which they |
338 apply critical fixes as needed. Some maintainers publish | 338 apply critical fixes as needed. Some maintainers publish |
339 multiple trees: one for experimental changes; one for changes | 339 multiple trees: one for experimental changes; one for changes |
340 that they are about to feed upstream; and so on. Others just | 340 that they are about to feed upstream; and so on. Others just |
341 publish a single tree.</para> | 341 publish a single tree.</para> |
342 | 342 |
343 <para>This model has two notable features. The first is that | 343 <para id="x_472">This model has two notable features. The first is that |
344 it's <quote>pull only</quote>. You have to ask, convince, or | 344 it's <quote>pull only</quote>. You have to ask, convince, or |
345 beg another developer to take a change from you, because there | 345 beg another developer to take a change from you, because there |
346 are almost no trees to which more than one person can push, | 346 are almost no trees to which more than one person can push, |
347 and there's no way to push changes into a tree that someone | 347 and there's no way to push changes into a tree that someone |
348 else controls.</para> | 348 else controls.</para> |
349 | 349 |
350 <para>The second is that it's based on reputation and acclaim. | 350 <para id="x_473">The second is that it's based on reputation and acclaim. |
351 If you're an unknown, Linus will probably ignore changes from | 351 If you're an unknown, Linus will probably ignore changes from |
352 you without even responding. But a subsystem maintainer will | 352 you without even responding. But a subsystem maintainer will |
353 probably review them, and will likely take them if they pass | 353 probably review them, and will likely take them if they pass |
354 their criteria for suitability. The more <quote>good</quote> | 354 their criteria for suitability. The more <quote>good</quote> |
355 changes you contribute to a maintainer, the more likely they | 355 changes you contribute to a maintainer, the more likely they |
356 are to trust your judgment and accept your changes. If you're | 356 are to trust your judgment and accept your changes. If you're |
357 well-known and maintain a long-lived branch for something | 357 well-known and maintain a long-lived branch for something |
358 Linus hasn't yet accepted, people with similar interests may | 358 Linus hasn't yet accepted, people with similar interests may |
359 pull your changes regularly to keep up with your work.</para> | 359 pull your changes regularly to keep up with your work.</para> |
360 | 360 |
361 <para>Reputation and acclaim don't necessarily cross subsystem | 361 <para id="x_474">Reputation and acclaim don't necessarily cross subsystem |
362 or <quote>people</quote> boundaries. If you're a respected | 362 or <quote>people</quote> boundaries. If you're a respected |
363 but specialised storage hacker, and you try to fix a | 363 but specialised storage hacker, and you try to fix a |
364 networking bug, that change will receive a level of scrutiny | 364 networking bug, that change will receive a level of scrutiny |
365 from a network maintainer comparable to a change from a | 365 from a network maintainer comparable to a change from a |
366 complete stranger.</para> | 366 complete stranger.</para> |
367 | 367 |
368 <para>To people who come from more orderly project backgrounds, | 368 <para id="x_475">To people who come from more orderly project backgrounds, |
369 the comparatively chaotic Linux kernel development process | 369 the comparatively chaotic Linux kernel development process |
370 often seems completely insane. It's subject to the whims of | 370 often seems completely insane. It's subject to the whims of |
371 individuals; people make sweeping changes whenever they deem | 371 individuals; people make sweeping changes whenever they deem |
372 it appropriate; and the pace of development is astounding. | 372 it appropriate; and the pace of development is astounding. |
373 And yet Linux is a highly successful, well-regarded piece of | 373 And yet Linux is a highly successful, well-regarded piece of |
375 | 375 |
376 </sect2> | 376 </sect2> |
377 <sect2> | 377 <sect2> |
378 <title>Pull-only versus shared-push collaboration</title> | 378 <title>Pull-only versus shared-push collaboration</title> |
379 | 379 |
380 <para>A perpetual source of heat in the open source community is | 380 <para id="x_476">A perpetual source of heat in the open source community is |
381 whether a development model in which people only ever pull | 381 whether a development model in which people only ever pull |
382 changes from others is <quote>better than</quote> one in which | 382 changes from others is <quote>better than</quote> one in which |
383 multiple people can push changes to a shared | 383 multiple people can push changes to a shared |
384 repository.</para> | 384 repository.</para> |
385 | 385 |
386 <para>Typically, the backers of the shared-push model use tools | 386 <para id="x_477">Typically, the backers of the shared-push model use tools |
387 that actively enforce this approach. If you're using a | 387 that actively enforce this approach. If you're using a |
388 centralised revision control tool such as Subversion, there's | 388 centralised revision control tool such as Subversion, there's |
389 no way to make a choice over which model you'll use: the tool | 389 no way to make a choice over which model you'll use: the tool |
390 gives you shared-push, and if you want to do anything else, | 390 gives you shared-push, and if you want to do anything else, |
391 you'll have to roll your own approach on top (such as applying | 391 you'll have to roll your own approach on top (such as applying |
392 a patch by hand).</para> | 392 a patch by hand).</para> |
393 | 393 |
394 <para>A good distributed revision control tool, such as | 394 <para id="x_478">A good distributed revision control tool, such as |
395 Mercurial, will support both models. You and your | 395 Mercurial, will support both models. You and your |
396 collaborators can then structure how you work together based | 396 collaborators can then structure how you work together based |
397 on your own needs and preferences, not on what contortions | 397 on your own needs and preferences, not on what contortions |
398 your tools force you into.</para> | 398 your tools force you into.</para> |
399 | 399 |
400 </sect2> | 400 </sect2> |
401 <sect2> | 401 <sect2> |
402 <title>Where collaboration meets branch management</title> | 402 <title>Where collaboration meets branch management</title> |
403 | 403 |
404 <para>Once you and your team set up some shared repositories and | 404 <para id="x_479">Once you and your team set up some shared repositories and |
405 start propagating changes back and forth between local and | 405 start propagating changes back and forth between local and |
406 shared repos, you begin to face a related, but slightly | 406 shared repos, you begin to face a related, but slightly |
407 different challenge: that of managing the multiple directions | 407 different challenge: that of managing the multiple directions |
408 in which your team may be moving at once. Even though this | 408 in which your team may be moving at once. Even though this |
409 subject is intimately related to how your team collaborates, | 409 subject is intimately related to how your team collaborates, |
413 </sect2> | 413 </sect2> |
414 </sect1> | 414 </sect1> |
415 <sect1> | 415 <sect1> |
416 <title>The technical side of sharing</title> | 416 <title>The technical side of sharing</title> |
417 | 417 |
418 <para>The remainder of this chapter is devoted to the question of | 418 <para id="x_47a">The remainder of this chapter is devoted to the question of |
419 serving data to your collaborators.</para> | 419 serving data to your collaborators.</para> |
420 | 420 |
421 </sect1> | 421 </sect1> |
422 <sect1 id="sec:collab:serve"> | 422 <sect1 id="sec:collab:serve"> |
423 <title>Informal sharing with <command role="hg-cmd">hg | 423 <title>Informal sharing with <command role="hg-cmd">hg |
424 serve</command></title> | 424 serve</command></title> |
425 | 425 |
426 <para>Mercurial's <command role="hg-cmd">hg serve</command> | 426 <para id="x_47b">Mercurial's <command role="hg-cmd">hg serve</command> |
427 command is wonderfully suited to small, tight-knit, and | 427 command is wonderfully suited to small, tight-knit, and |
428 fast-paced group environments. It also provides a great way to | 428 fast-paced group environments. It also provides a great way to |
429 get a feel for using Mercurial commands over a network.</para> | 429 get a feel for using Mercurial commands over a network.</para> |
430 | 430 |
431 <para>Run <command role="hg-cmd">hg serve</command> inside a | 431 <para id="x_47c">Run <command role="hg-cmd">hg serve</command> inside a |
432 repository, and in under a second it will bring up a specialised | 432 repository, and in under a second it will bring up a specialised |
433 HTTP server; this will accept connections from any client, and | 433 HTTP server; this will accept connections from any client, and |
434 serve up data for that repository until you terminate it. | 434 serve up data for that repository until you terminate it. |
435 Anyone who knows the URL of the server you just started, and can | 435 Anyone who knows the URL of the server you just started, and can |
436 talk to your computer over the network, can then use a web | 436 talk to your computer over the network, can then use a web |
437 browser or Mercurial to read data from that repository. A URL | 437 browser or Mercurial to read data from that repository. A URL |
438 for a <command role="hg-cmd">hg serve</command> instance running | 438 for a <command role="hg-cmd">hg serve</command> instance running |
439 on a laptop is likely to look something like | 439 on a laptop is likely to look something like |
440 <literal>http://my-laptop.local:8000/</literal>.</para> | 440 <literal>http://my-laptop.local:8000/</literal>.</para> |
441 | 441 |
442 <para>The <command role="hg-cmd">hg serve</command> command is | 442 <para id="x_47d">The <command role="hg-cmd">hg serve</command> command is |
443 <emphasis>not</emphasis> a general-purpose web server. It can do | 443 <emphasis>not</emphasis> a general-purpose web server. It can do |
444 only two things:</para> | 444 only two things:</para> |
445 <itemizedlist> | 445 <itemizedlist> |
446 <listitem><para>Allow people to browse the history of the | 446 <listitem><para id="x_47e">Allow people to browse the history of the |
447 repository it's serving, from their normal web | 447 repository it's serving, from their normal web |
448 browsers.</para> | 448 browsers.</para> |
449 </listitem> | 449 </listitem> |
450 <listitem><para>Speak Mercurial's wire protocol, so that people | 450 <listitem><para id="x_47f">Speak Mercurial's wire protocol, so that people |
451 can <command role="hg-cmd">hg clone</command> or <command | 451 can <command role="hg-cmd">hg clone</command> or <command |
452 role="hg-cmd">hg pull</command> changes from that | 452 role="hg-cmd">hg pull</command> changes from that |
453 repository.</para> | 453 repository.</para> |
454 </listitem></itemizedlist> | 454 </listitem></itemizedlist> |
455 <para>In particular, <command role="hg-cmd">hg serve</command> | 455 <para id="x_480">In particular, <command role="hg-cmd">hg serve</command> |
456 won't allow remote users to <emphasis>modify</emphasis> your | 456 won't allow remote users to <emphasis>modify</emphasis> your |
457 repository. It's intended for read-only use.</para> | 457 repository. It's intended for read-only use.</para> |
458 | 458 |
459 <para>If you're getting started with Mercurial, there's nothing to | 459 <para id="x_481">If you're getting started with Mercurial, there's nothing to |
460 prevent you from using <command role="hg-cmd">hg serve</command> | 460 prevent you from using <command role="hg-cmd">hg serve</command> |
461 to serve up a repository on your own computer, then use commands | 461 to serve up a repository on your own computer, then use commands |
462 like <command role="hg-cmd">hg clone</command>, <command | 462 like <command role="hg-cmd">hg clone</command>, <command |
463 role="hg-cmd">hg incoming</command>, and so on to talk to that | 463 role="hg-cmd">hg incoming</command>, and so on to talk to that |
464 server as if the repository was hosted remotely. This can help | 464 server as if the repository was hosted remotely. This can help |
466 network-hosted repositories.</para> | 466 network-hosted repositories.</para> |
467 | 467 |
468 <sect2> | 468 <sect2> |
469 <title>A few things to keep in mind</title> | 469 <title>A few things to keep in mind</title> |
470 | 470 |
471 <para>Because it provides unauthenticated read access to all | 471 <para id="x_482">Because it provides unauthenticated read access to all |
472 clients, you should only use <command role="hg-cmd">hg | 472 clients, you should only use <command role="hg-cmd">hg |
473 serve</command> in an environment where you either don't | 473 serve</command> in an environment where you either don't |
474 care, or have complete control over, who can access your | 474 care, or have complete control over, who can access your |
475 network and pull data from your repository.</para> | 475 network and pull data from your repository.</para> |
476 | 476 |
477 <para>The <command role="hg-cmd">hg serve</command> command | 477 <para id="x_483">The <command role="hg-cmd">hg serve</command> command |
478 knows nothing about any firewall software you might have | 478 knows nothing about any firewall software you might have |
479 installed on your system or network. It cannot detect or | 479 installed on your system or network. It cannot detect or |
480 control your firewall software. If other people are unable to | 480 control your firewall software. If other people are unable to |
481 talk to a running <command role="hg-cmd">hg serve</command> | 481 talk to a running <command role="hg-cmd">hg serve</command> |
482 instance, the second thing you should do | 482 instance, the second thing you should do |
483 (<emphasis>after</emphasis> you make sure that they're using | 483 (<emphasis>after</emphasis> you make sure that they're using |
484 the correct URL) is check your firewall configuration.</para> | 484 the correct URL) is check your firewall configuration.</para> |
485 | 485 |
486 <para>By default, <command role="hg-cmd">hg serve</command> | 486 <para id="x_484">By default, <command role="hg-cmd">hg serve</command> |
487 listens for incoming connections on port 8000. If another | 487 listens for incoming connections on port 8000. If another |
488 process is already listening on the port you want to use, you | 488 process is already listening on the port you want to use, you |
489 can specify a different port to listen on using the <option | 489 can specify a different port to listen on using the <option |
490 role="hg-opt-serve">-p</option> option.</para> | 490 role="hg-opt-serve">-p</option> option.</para> |
491 | 491 |
492 <para>Normally, when <command role="hg-cmd">hg serve</command> | 492 <para id="x_485">Normally, when <command role="hg-cmd">hg serve</command> |
493 starts, it prints no output, which can be a bit unnerving. If | 493 starts, it prints no output, which can be a bit unnerving. If |
494 you'd like to confirm that it is indeed running correctly, and | 494 you'd like to confirm that it is indeed running correctly, and |
495 find out what URL you should send to your collaborators, start | 495 find out what URL you should send to your collaborators, start |
496 it with the <option role="hg-opt-global">-v</option> | 496 it with the <option role="hg-opt-global">-v</option> |
497 option.</para> | 497 option.</para> |
499 </sect2> | 499 </sect2> |
500 </sect1> | 500 </sect1> |
501 <sect1 id="sec:collab:ssh"> | 501 <sect1 id="sec:collab:ssh"> |
502 <title>Using the Secure Shell (ssh) protocol</title> | 502 <title>Using the Secure Shell (ssh) protocol</title> |
503 | 503 |
504 <para>You can pull and push changes securely over a network | 504 <para id="x_486">You can pull and push changes securely over a network |
505 connection using the Secure Shell (<literal>ssh</literal>) | 505 connection using the Secure Shell (<literal>ssh</literal>) |
506 protocol. To use this successfully, you may have to do a little | 506 protocol. To use this successfully, you may have to do a little |
507 bit of configuration on the client or server sides.</para> | 507 bit of configuration on the client or server sides.</para> |
508 | 508 |
509 <para>If you're not familiar with ssh, it's a network protocol | 509 <para id="x_487">If you're not familiar with ssh, it's a network protocol |
510 that lets you securely communicate with another computer. To | 510 that lets you securely communicate with another computer. To |
511 use it with Mercurial, you'll be setting up one or more user | 511 use it with Mercurial, you'll be setting up one or more user |
512 accounts on a server so that remote users can log in and execute | 512 accounts on a server so that remote users can log in and execute |
513 commands.</para> | 513 commands.</para> |
514 | 514 |
515 <para>(If you <emphasis>are</emphasis> familiar with ssh, you'll | 515 <para id="x_488">(If you <emphasis>are</emphasis> familiar with ssh, you'll |
516 probably find some of the material that follows to be elementary | 516 probably find some of the material that follows to be elementary |
517 in nature.)</para> | 517 in nature.)</para> |
518 | 518 |
519 <sect2> | 519 <sect2> |
520 <title>How to read and write ssh URLs</title> | 520 <title>How to read and write ssh URLs</title> |
521 | 521 |
522 <para>An ssh URL tends to look like this:</para> | 522 <para id="x_489">An ssh URL tends to look like this:</para> |
523 <programlisting>ssh://bos@hg.serpentine.com:22/hg/hgbook</programlisting> | 523 <programlisting>ssh://bos@hg.serpentine.com:22/hg/hgbook</programlisting> |
524 <orderedlist> | 524 <orderedlist> |
525 <listitem><para>The <quote><literal>ssh://</literal></quote> | 525 <listitem><para id="x_48a">The <quote><literal>ssh://</literal></quote> |
526 part tells Mercurial to use the ssh protocol.</para> | 526 part tells Mercurial to use the ssh protocol.</para> |
527 </listitem> | 527 </listitem> |
528 <listitem><para>The <quote><literal>bos@</literal></quote> | 528 <listitem><para id="x_48b">The <quote><literal>bos@</literal></quote> |
529 component indicates what username to log into the server | 529 component indicates what username to log into the server |
530 as. You can leave this out if the remote username is the | 530 as. You can leave this out if the remote username is the |
531 same as your local username.</para> | 531 same as your local username.</para> |
532 </listitem> | 532 </listitem> |
533 <listitem><para>The | 533 <listitem><para id="x_48c">The |
534 <quote><literal>hg.serpentine.com</literal></quote> gives | 534 <quote><literal>hg.serpentine.com</literal></quote> gives |
535 the hostname of the server to log into.</para> | 535 the hostname of the server to log into.</para> |
536 </listitem> | 536 </listitem> |
537 <listitem><para>The <quote>:22</quote> identifies the port | 537 <listitem><para id="x_48d">The <quote>:22</quote> identifies the port |
538 number to connect to the server on. The default port is | 538 number to connect to the server on. The default port is |
539 22, so you only need to specify a colon and port number if | 539 22, so you only need to specify a colon and port number if |
540 you're <emphasis>not</emphasis> using port 22.</para> | 540 you're <emphasis>not</emphasis> using port 22.</para> |
541 </listitem> | 541 </listitem> |
542 <listitem><para>The remainder of the URL is the local path to | 542 <listitem><para id="x_48e">The remainder of the URL is the local path to |
543 the repository on the server.</para> | 543 the repository on the server.</para> |
544 </listitem></orderedlist> | 544 </listitem></orderedlist> |
545 | 545 |
546 <para>There's plenty of scope for confusion with the path | 546 <para id="x_48f">There's plenty of scope for confusion with the path |
547 component of ssh URLs, as there is no standard way for tools | 547 component of ssh URLs, as there is no standard way for tools |
548 to interpret it. Some programs behave differently than others | 548 to interpret it. Some programs behave differently than others |
549 when dealing with these paths. This isn't an ideal situation, | 549 when dealing with these paths. This isn't an ideal situation, |
550 but it's unlikely to change. Please read the following | 550 but it's unlikely to change. Please read the following |
551 paragraphs carefully.</para> | 551 paragraphs carefully.</para> |
552 | 552 |
553 <para>Mercurial treats the path to a repository on the server as | 553 <para id="x_490">Mercurial treats the path to a repository on the server as |
554 relative to the remote user's home directory. For example, if | 554 relative to the remote user's home directory. For example, if |
555 user <literal>foo</literal> on the server has a home directory | 555 user <literal>foo</literal> on the server has a home directory |
556 of <filename class="directory">/home/foo</filename>, then an | 556 of <filename class="directory">/home/foo</filename>, then an |
557 ssh URL that contains a path component of <filename | 557 ssh URL that contains a path component of <filename |
558 class="directory">bar</filename> <emphasis>really</emphasis> | 558 class="directory">bar</filename> <emphasis>really</emphasis> |
559 refers to the directory <filename | 559 refers to the directory <filename |
560 class="directory">/home/foo/bar</filename>.</para> | 560 class="directory">/home/foo/bar</filename>.</para> |
561 | 561 |
562 <para>If you want to specify a path relative to another user's | 562 <para id="x_491">If you want to specify a path relative to another user's |
563 home directory, you can use a path that starts with a tilde | 563 home directory, you can use a path that starts with a tilde |
564 character followed by the user's name (let's call them | 564 character followed by the user's name (let's call them |
565 <literal>otheruser</literal>), like this.</para> | 565 <literal>otheruser</literal>), like this.</para> |
566 <programlisting>ssh://server/~otheruser/hg/repo</programlisting> | 566 <programlisting>ssh://server/~otheruser/hg/repo</programlisting> |
567 | 567 |
568 <para>And if you really want to specify an | 568 <para id="x_492">And if you really want to specify an |
569 <emphasis>absolute</emphasis> path on the server, begin the | 569 <emphasis>absolute</emphasis> path on the server, begin the |
570 path component with two slashes, as in this example.</para> | 570 path component with two slashes, as in this example.</para> |
571 <programlisting>ssh://server//absolute/path</programlisting> | 571 <programlisting>ssh://server//absolute/path</programlisting> |
572 | 572 |
573 </sect2> | 573 </sect2> |
574 <sect2> | 574 <sect2> |
575 <title>Finding an ssh client for your system</title> | 575 <title>Finding an ssh client for your system</title> |
576 | 576 |
577 <para>Almost every Unix-like system comes with OpenSSH | 577 <para id="x_493">Almost every Unix-like system comes with OpenSSH |
578 preinstalled. If you're using such a system, run | 578 preinstalled. If you're using such a system, run |
579 <literal>which ssh</literal> to find out if the | 579 <literal>which ssh</literal> to find out if the |
580 <command>ssh</command> command is installed (it's usually in | 580 <command>ssh</command> command is installed (it's usually in |
581 <filename class="directory">/usr/bin</filename>). In the | 581 <filename class="directory">/usr/bin</filename>). In the |
582 unlikely event that it isn't present, take a look at your | 582 unlikely event that it isn't present, take a look at your |
583 system documentation to figure out how to install it.</para> | 583 system documentation to figure out how to install it.</para> |
584 | 584 |
585 <para>On Windows, you'll first need to download a suitable ssh | 585 <para id="x_494">On Windows, you'll first need to download a suitable ssh |
586 client. There are two alternatives.</para> | 586 client. There are two alternatives.</para> |
587 <itemizedlist> | 587 <itemizedlist> |
588 <listitem><para>Simon Tatham's excellent PuTTY package | 588 <listitem><para id="x_495">Simon Tatham's excellent PuTTY package |
589 <citation>web:putty</citation> provides a complete suite | 589 <citation>web:putty</citation> provides a complete suite |
590 of ssh client commands.</para> | 590 of ssh client commands.</para> |
591 </listitem> | 591 </listitem> |
592 <listitem><para>If you have a high tolerance for pain, you can | 592 <listitem><para id="x_496">If you have a high tolerance for pain, you can |
593 use the Cygwin port of OpenSSH.</para> | 593 use the Cygwin port of OpenSSH.</para> |
594 </listitem></itemizedlist> | 594 </listitem></itemizedlist> |
595 <para>In either case, you'll need to edit your <filename | 595 <para id="x_497">In either case, you'll need to edit your <filename |
596 role="special">hg.ini</filename> file to | 596 role="special">hg.ini</filename> file to |
597 tell Mercurial where to find the actual client command. For | 597 tell Mercurial where to find the actual client command. For |
598 example, if you're using PuTTY, you'll need to use the | 598 example, if you're using PuTTY, you'll need to use the |
599 <command>plink</command> command as a command-line ssh | 599 <command>plink</command> command as a command-line ssh |
600 client.</para> | 600 client.</para> |
601 <programlisting>[ui] | 601 <programlisting>[ui] |
602 ssh = C:/path/to/plink.exe -ssh -i "C:/path/to/my/private/key"</programlisting> | 602 ssh = C:/path/to/plink.exe -ssh -i "C:/path/to/my/private/key"</programlisting> |
603 | 603 |
604 <note> | 604 <note> |
605 <para> The path to <command>plink</command> shouldn't contain | 605 <para id="x_498"> The path to <command>plink</command> shouldn't contain |
606 any whitespace characters, or Mercurial may not be able to | 606 any whitespace characters, or Mercurial may not be able to |
607 run it correctly (so putting it in <filename | 607 run it correctly (so putting it in <filename |
608 class="directory">C:\Program Files</filename> is probably | 608 class="directory">C:\Program Files</filename> is probably |
609 not a good idea).</para> | 609 not a good idea).</para> |
610 </note> | 610 </note> |
611 | 611 |
612 </sect2> | 612 </sect2> |
613 <sect2> | 613 <sect2> |
614 <title>Generating a key pair</title> | 614 <title>Generating a key pair</title> |
615 | 615 |
616 <para>To avoid the need to repetitively type a password every | 616 <para id="x_499">To avoid the need to repetitively type a password every |
617 time you need to use your ssh client, I recommend generating a | 617 time you need to use your ssh client, I recommend generating a |
618 key pair. On a Unix-like system, the | 618 key pair. On a Unix-like system, the |
619 <command>ssh-keygen</command> command will do the trick. On | 619 <command>ssh-keygen</command> command will do the trick. On |
620 Windows, if you're using PuTTY, the | 620 Windows, if you're using PuTTY, the |
621 <command>puttygen</command> command is what you'll | 621 <command>puttygen</command> command is what you'll |
622 need.</para> | 622 need.</para> |
623 | 623 |
624 <para>When you generate a key pair, it's usually | 624 <para id="x_49a">When you generate a key pair, it's usually |
625 <emphasis>highly</emphasis> advisable to protect it with a | 625 <emphasis>highly</emphasis> advisable to protect it with a |
626 passphrase. (The only time that you might not want to do this | 626 passphrase. (The only time that you might not want to do this |
627 is when you're using the ssh protocol for automated tasks on a | 627 is when you're using the ssh protocol for automated tasks on a |
628 secure network.)</para> | 628 secure network.)</para> |
629 | 629 |
630 <para>Simply generating a key pair isn't enough, however. | 630 <para id="x_49b">Simply generating a key pair isn't enough, however. |
631 You'll need to add the public key to the set of authorised | 631 You'll need to add the public key to the set of authorised |
632 keys for whatever user you're logging in remotely as. For | 632 keys for whatever user you're logging in remotely as. For |
633 servers using OpenSSH (the vast majority), this will mean | 633 servers using OpenSSH (the vast majority), this will mean |
634 adding the public key to a list in a file called <filename | 634 adding the public key to a list in a file called <filename |
635 role="special">authorized_keys</filename> in their <filename | 635 role="special">authorized_keys</filename> in their <filename |
636 role="special" class="directory">.ssh</filename> | 636 role="special" class="directory">.ssh</filename> |
637 directory.</para> | 637 directory.</para> |
638 | 638 |
639 <para>On a Unix-like system, your public key will have a | 639 <para id="x_49c">On a Unix-like system, your public key will have a |
640 <filename>.pub</filename> extension. If you're using | 640 <filename>.pub</filename> extension. If you're using |
641 <command>puttygen</command> on Windows, you can save the | 641 <command>puttygen</command> on Windows, you can save the |
642 public key to a file of your choosing, or paste it from the | 642 public key to a file of your choosing, or paste it from the |
643 window it's displayed in straight into the <filename | 643 window it's displayed in straight into the <filename |
644 role="special">authorized_keys</filename> file.</para> | 644 role="special">authorized_keys</filename> file.</para> |
645 | 645 |
646 </sect2> | 646 </sect2> |
647 <sect2> | 647 <sect2> |
648 <title>Using an authentication agent</title> | 648 <title>Using an authentication agent</title> |
649 | 649 |
650 <para>An authentication agent is a daemon that stores | 650 <para id="x_49d">An authentication agent is a daemon that stores |
651 passphrases in memory (so it will forget passphrases if you | 651 passphrases in memory (so it will forget passphrases if you |
652 log out and log back in again). An ssh client will notice if | 652 log out and log back in again). An ssh client will notice if |
653 it's running, and query it for a passphrase. If there's no | 653 it's running, and query it for a passphrase. If there's no |
654 authentication agent running, or the agent doesn't store the | 654 authentication agent running, or the agent doesn't store the |
655 necessary passphrase, you'll have to type your passphrase | 655 necessary passphrase, you'll have to type your passphrase |
656 every time Mercurial tries to communicate with a server on | 656 every time Mercurial tries to communicate with a server on |
657 your behalf (e.g. whenever you pull or push changes).</para> | 657 your behalf (e.g. whenever you pull or push changes).</para> |
658 | 658 |
659 <para>The downside of storing passphrases in an agent is that | 659 <para id="x_49e">The downside of storing passphrases in an agent is that |
660 it's possible for a well-prepared attacker to recover the | 660 it's possible for a well-prepared attacker to recover the |
661 plain text of your passphrases, in some cases even if your | 661 plain text of your passphrases, in some cases even if your |
662 system has been power-cycled. You should make your own | 662 system has been power-cycled. You should make your own |
663 judgment as to whether this is an acceptable risk. It | 663 judgment as to whether this is an acceptable risk. It |
664 certainly saves a lot of repeated typing.</para> | 664 certainly saves a lot of repeated typing.</para> |
665 | 665 |
666 <para>On Unix-like systems, the agent is called | 666 <para id="x_49f">On Unix-like systems, the agent is called |
667 <command>ssh-agent</command>, and it's often run automatically | 667 <command>ssh-agent</command>, and it's often run automatically |
668 for you when you log in. You'll need to use the | 668 for you when you log in. You'll need to use the |
669 <command>ssh-add</command> command to add passphrases to the | 669 <command>ssh-add</command> command to add passphrases to the |
670 agent's store. On Windows, if you're using PuTTY, the | 670 agent's store. On Windows, if you're using PuTTY, the |
671 <command>pageant</command> command acts as the agent. It adds | 671 <command>pageant</command> command acts as the agent. It adds |
674 | 674 |
675 </sect2> | 675 </sect2> |
676 <sect2> | 676 <sect2> |
677 <title>Configuring the server side properly</title> | 677 <title>Configuring the server side properly</title> |
678 | 678 |
679 <para>Because ssh can be fiddly to set up if you're new to it, | 679 <para id="x_4a0">Because ssh can be fiddly to set up if you're new to it, |
680 there's a variety of things that can go wrong. Add Mercurial | 680 there's a variety of things that can go wrong. Add Mercurial |
681 on top, and there's plenty more scope for head-scratching. | 681 on top, and there's plenty more scope for head-scratching. |
682 Most of these potential problems occur on the server side, not | 682 Most of these potential problems occur on the server side, not |
683 the client side. The good news is that once you've gotten a | 683 the client side. The good news is that once you've gotten a |
684 configuration working, it will usually continue to work | 684 configuration working, it will usually continue to work |
685 indefinitely.</para> | 685 indefinitely.</para> |
686 | 686 |
687 <para>Before you try using Mercurial to talk to an ssh server, | 687 <para id="x_4a1">Before you try using Mercurial to talk to an ssh server, |
688 it's best to make sure that you can use the normal | 688 it's best to make sure that you can use the normal |
689 <command>ssh</command> or <command>putty</command> command to | 689 <command>ssh</command> or <command>putty</command> command to |
690 talk to the server first. If you run into problems with using | 690 talk to the server first. If you run into problems with using |
691 these commands directly, Mercurial surely won't work. Worse, | 691 these commands directly, Mercurial surely won't work. Worse, |
692 it will obscure the underlying problem. Any time you want to | 692 it will obscure the underlying problem. Any time you want to |
693 debug ssh-related Mercurial problems, you should drop back to | 693 debug ssh-related Mercurial problems, you should drop back to |
694 making sure that plain ssh client commands work first, | 694 making sure that plain ssh client commands work first, |
695 <emphasis>before</emphasis> you worry about whether there's a | 695 <emphasis>before</emphasis> you worry about whether there's a |
696 problem with Mercurial.</para> | 696 problem with Mercurial.</para> |
697 | 697 |
698 <para>The first thing to be sure of on the server side is that | 698 <para id="x_4a2">The first thing to be sure of on the server side is that |
699 you can actually log in from another machine at all. If you | 699 you can actually log in from another machine at all. If you |
700 can't use <command>ssh</command> or <command>putty</command> | 700 can't use <command>ssh</command> or <command>putty</command> |
701 to log in, the error message you get may give you a few hints | 701 to log in, the error message you get may give you a few hints |
702 as to what's wrong. The most common problems are as | 702 as to what's wrong. The most common problems are as |
703 follows.</para> | 703 follows.</para> |
704 <itemizedlist> | 704 <itemizedlist> |
705 <listitem><para>If you get a <quote>connection refused</quote> | 705 <listitem><para id="x_4a3">If you get a <quote>connection refused</quote> |
706 error, either there isn't an SSH daemon running on the | 706 error, either there isn't an SSH daemon running on the |
707 server at all, or it's inaccessible due to firewall | 707 server at all, or it's inaccessible due to firewall |
708 configuration.</para> | 708 configuration.</para> |
709 </listitem> | 709 </listitem> |
710 <listitem><para>If you get a <quote>no route to host</quote> | 710 <listitem><para id="x_4a4">If you get a <quote>no route to host</quote> |
711 error, you either have an incorrect address for the server | 711 error, you either have an incorrect address for the server |
712 or a seriously locked down firewall that won't admit its | 712 or a seriously locked down firewall that won't admit its |
713 existence at all.</para> | 713 existence at all.</para> |
714 </listitem> | 714 </listitem> |
715 <listitem><para>If you get a <quote>permission denied</quote> | 715 <listitem><para id="x_4a5">If you get a <quote>permission denied</quote> |
716 error, you may have mistyped the username on the server, | 716 error, you may have mistyped the username on the server, |
717 or you could have mistyped your key's passphrase or the | 717 or you could have mistyped your key's passphrase or the |
718 remote user's password.</para> | 718 remote user's password.</para> |
719 </listitem></itemizedlist> | 719 </listitem></itemizedlist> |
720 <para>In summary, if you're having trouble talking to the | 720 <para id="x_4a6">In summary, if you're having trouble talking to the |
721 server's ssh daemon, first make sure that one is running at | 721 server's ssh daemon, first make sure that one is running at |
722 all. On many systems it will be installed, but disabled, by | 722 all. On many systems it will be installed, but disabled, by |
723 default. Once you're done with this step, you should then | 723 default. Once you're done with this step, you should then |
724 check that the server's firewall is configured to allow | 724 check that the server's firewall is configured to allow |
725 incoming connections on the port the ssh daemon is listening | 725 incoming connections on the port the ssh daemon is listening |
726 on (usually 22). Don't worry about more exotic possibilities | 726 on (usually 22). Don't worry about more exotic possibilities |
727 for misconfiguration until you've checked these two | 727 for misconfiguration until you've checked these two |
728 first.</para> | 728 first.</para> |
729 | 729 |
730 <para>If you're using an authentication agent on the client side | 730 <para id="x_4a7">If you're using an authentication agent on the client side |
731 to store passphrases for your keys, you ought to be able to | 731 to store passphrases for your keys, you ought to be able to |
732 log into the server without being prompted for a passphrase or | 732 log into the server without being prompted for a passphrase or |
733 a password. If you're prompted for a passphrase, there are a | 733 a password. If you're prompted for a passphrase, there are a |
734 few possible culprits.</para> | 734 few possible culprits.</para> |
735 <itemizedlist> | 735 <itemizedlist> |
736 <listitem><para>You might have forgotten to use | 736 <listitem><para id="x_4a8">You might have forgotten to use |
737 <command>ssh-add</command> or <command>pageant</command> | 737 <command>ssh-add</command> or <command>pageant</command> |
738 to store the passphrase.</para> | 738 to store the passphrase.</para> |
739 </listitem> | 739 </listitem> |
740 <listitem><para>You might have stored the passphrase for the | 740 <listitem><para id="x_4a9">You might have stored the passphrase for the |
741 wrong key.</para> | 741 wrong key.</para> |
742 </listitem></itemizedlist> | 742 </listitem></itemizedlist> |
743 <para>If you're being prompted for the remote user's password, | 743 <para id="x_4aa">If you're being prompted for the remote user's password, |
744 there are another few possible problems to check.</para> | 744 there are another few possible problems to check.</para> |
745 <itemizedlist> | 745 <itemizedlist> |
746 <listitem><para>Either the user's home directory or their | 746 <listitem><para id="x_4ab">Either the user's home directory or their |
747 <filename role="special" class="directory">.ssh</filename> | 747 <filename role="special" class="directory">.ssh</filename> |
748 directory might have excessively liberal permissions. As | 748 directory might have excessively liberal permissions. As |
749 a result, the ssh daemon will not trust or read their | 749 a result, the ssh daemon will not trust or read their |
750 <filename role="special">authorized_keys</filename> file. | 750 <filename role="special">authorized_keys</filename> file. |
751 For example, a group-writable home or <filename | 751 For example, a group-writable home or <filename |
752 role="special" class="directory">.ssh</filename> | 752 role="special" class="directory">.ssh</filename> |
753 directory will often cause this symptom.</para> | 753 directory will often cause this symptom.</para> |
754 </listitem> | 754 </listitem> |
755 <listitem><para>The user's <filename | 755 <listitem><para id="x_4ac">The user's <filename |
756 role="special">authorized_keys</filename> file may have | 756 role="special">authorized_keys</filename> file may have |
757 a problem. If anyone other than the user owns or can write | 757 a problem. If anyone other than the user owns or can write |
758 to that file, the ssh daemon will not trust or read | 758 to that file, the ssh daemon will not trust or read |
759 it.</para> | 759 it.</para> |
760 </listitem></itemizedlist> | 760 </listitem></itemizedlist> |
761 | 761 |
762 <para>In the ideal world, you should be able to run the | 762 <para id="x_4ad">In the ideal world, you should be able to run the |
763 following command successfully, and it should print exactly | 763 following command successfully, and it should print exactly |
764 one line of output, the current date and time.</para> | 764 one line of output, the current date and time.</para> |
765 <programlisting>ssh myserver date</programlisting> | 765 <programlisting>ssh myserver date</programlisting> |
766 | 766 |
767 <para>If, on your server, you have login scripts that print | 767 <para id="x_4ae">If, on your server, you have login scripts that print |
768 banners or other junk even when running non-interactive | 768 banners or other junk even when running non-interactive |
769 commands like this, you should fix them before you continue, | 769 commands like this, you should fix them before you continue, |
770 so that they only print output if they're run interactively. | 770 so that they only print output if they're run interactively. |
771 Otherwise these banners will at least clutter up Mercurial's | 771 Otherwise these banners will at least clutter up Mercurial's |
772 output. Worse, they could potentially cause problems with | 772 output. Worse, they could potentially cause problems with |
776 you're editing your login scripts on your server, the usual | 776 you're editing your login scripts on your server, the usual |
777 way to see if a login script is running in an interactive | 777 way to see if a login script is running in an interactive |
778 shell is to check the return code from the command | 778 shell is to check the return code from the command |
779 <literal>tty -s</literal>.)</para> | 779 <literal>tty -s</literal>.)</para> |
780 | 780 |
781 <para>Once you've verified that plain old ssh is working with | 781 <para id="x_4af">Once you've verified that plain old ssh is working with |
782 your server, the next step is to ensure that Mercurial runs on | 782 your server, the next step is to ensure that Mercurial runs on |
783 the server. The following command should run | 783 the server. The following command should run |
784 successfully:</para> | 784 successfully:</para> |
785 | 785 |
786 <programlisting>ssh myserver hg version</programlisting> | 786 <programlisting>ssh myserver hg version</programlisting> |
787 | 787 |
788 <para>If you see an error message instead of normal <command | 788 <para id="x_4b0">If you see an error message instead of normal <command |
789 role="hg-cmd">hg version</command> output, this is usually | 789 role="hg-cmd">hg version</command> output, this is usually |
790 because you haven't installed Mercurial to <filename | 790 because you haven't installed Mercurial to <filename |
791 class="directory">/usr/bin</filename>. Don't worry if this | 791 class="directory">/usr/bin</filename>. Don't worry if this |
792 is the case; you don't need to do that. But you should check | 792 is the case; you don't need to do that. But you should check |
793 for a few possible problems.</para> | 793 for a few possible problems.</para> |
794 <itemizedlist> | 794 <itemizedlist> |
795 <listitem><para>Is Mercurial really installed on the server at | 795 <listitem><para id="x_4b1">Is Mercurial really installed on the server at |
796 all? I know this sounds trivial, but it's worth | 796 all? I know this sounds trivial, but it's worth |
797 checking!</para> | 797 checking!</para> |
798 </listitem> | 798 </listitem> |
799 <listitem><para>Maybe your shell's search path (usually set | 799 <listitem><para id="x_4b2">Maybe your shell's search path (usually set |
800 via the <envar>PATH</envar> environment variable) is | 800 via the <envar>PATH</envar> environment variable) is |
801 simply misconfigured.</para> | 801 simply misconfigured.</para> |
802 </listitem> | 802 </listitem> |
803 <listitem><para>Perhaps your <envar>PATH</envar> environment | 803 <listitem><para id="x_4b3">Perhaps your <envar>PATH</envar> environment |
804 variable is only being set to point to the location of the | 804 variable is only being set to point to the location of the |
805 <command>hg</command> executable if the login session is | 805 <command>hg</command> executable if the login session is |
806 interactive. This can happen if you're setting the path | 806 interactive. This can happen if you're setting the path |
807 in the wrong shell login script. See your shell's | 807 in the wrong shell login script. See your shell's |
808 documentation for details.</para> | 808 documentation for details.</para> |
809 </listitem> | 809 </listitem> |
810 <listitem><para>The <envar>PYTHONPATH</envar> environment | 810 <listitem><para id="x_4b4">The <envar>PYTHONPATH</envar> environment |
811 variable may need to contain the path to the Mercurial | 811 variable may need to contain the path to the Mercurial |
812 Python modules. It might not be set at all; it could be | 812 Python modules. It might not be set at all; it could be |
813 incorrect; or it may be set only if the login is | 813 incorrect; or it may be set only if the login is |
814 interactive.</para> | 814 interactive.</para> |
815 </listitem></itemizedlist> | 815 </listitem></itemizedlist> |
816 | 816 |
817 <para>If you can run <command role="hg-cmd">hg version</command> | 817 <para id="x_4b5">If you can run <command role="hg-cmd">hg version</command> |
818 over an ssh connection, well done! You've got the server and | 818 over an ssh connection, well done! You've got the server and |
819 client sorted out. You should now be able to use Mercurial to | 819 client sorted out. You should now be able to use Mercurial to |
820 access repositories hosted by that username on that server. | 820 access repositories hosted by that username on that server. |
821 If you run into problems with Mercurial and ssh at this point, | 821 If you run into problems with Mercurial and ssh at this point, |
822 try using the <option role="hg-opt-global">--debug</option> | 822 try using the <option role="hg-opt-global">--debug</option> |
824 | 824 |
825 </sect2> | 825 </sect2> |
826 <sect2> | 826 <sect2> |
827 <title>Using compression with ssh</title> | 827 <title>Using compression with ssh</title> |
828 | 828 |
829 <para>Mercurial does not compress data when it uses the ssh | 829 <para id="x_4b6">Mercurial does not compress data when it uses the ssh |
830 protocol, because the ssh protocol can transparently compress | 830 protocol, because the ssh protocol can transparently compress |
831 data. However, the default behaviour of ssh clients is | 831 data. However, the default behaviour of ssh clients is |
832 <emphasis>not</emphasis> to request compression.</para> | 832 <emphasis>not</emphasis> to request compression.</para> |
833 | 833 |
834 <para>Over any network other than a fast LAN (even a wireless | 834 <para id="x_4b7">Over any network other than a fast LAN (even a wireless |
835 network), using compression is likely to significantly speed | 835 network), using compression is likely to significantly speed |
836 up Mercurial's network operations. For example, over a WAN, | 836 up Mercurial's network operations. For example, over a WAN, |
837 someone measured compression as reducing the amount of time | 837 someone measured compression as reducing the amount of time |
838 required to clone a particularly large repository from 51 | 838 required to clone a particularly large repository from 51 |
839 minutes to 17 minutes.</para> | 839 minutes to 17 minutes.</para> |
840 | 840 |
841 <para>Both <command>ssh</command> and <command>plink</command> | 841 <para id="x_4b8">Both <command>ssh</command> and <command>plink</command> |
842 accept a <option role="cmd-opt-ssh">-C</option> option which | 842 accept a <option role="cmd-opt-ssh">-C</option> option which |
843 turns on compression. You can easily edit your <filename | 843 turns on compression. You can easily edit your <filename |
844 role="special">~/.hgrc</filename> to enable compression for | 844 role="special">~/.hgrc</filename> to enable compression for |
845 all of Mercurial's uses of the ssh protocol.</para> | 845 all of Mercurial's uses of the ssh protocol.</para> |
846 <programlisting>[ui] | 846 <programlisting>[ui] |
847 ssh = ssh -C</programlisting> | 847 ssh = ssh -C</programlisting> |
848 | 848 |
849 <para>If you use <command>ssh</command>, you can configure it to | 849 <para id="x_4b9">If you use <command>ssh</command>, you can configure it to |
850 always use compression when talking to your server. To do | 850 always use compression when talking to your server. To do |
851 this, edit your <filename | 851 this, edit your <filename |
852 role="special">.ssh/config</filename> file (which may not | 852 role="special">.ssh/config</filename> file (which may not |
853 yet exist), as follows.</para> | 853 yet exist), as follows.</para> |
854 <programlisting>Host hg | 854 <programlisting>Host hg |
855 Compression yes | 855 Compression yes |
856 HostName hg.example.com</programlisting> | 856 HostName hg.example.com</programlisting> |
857 <para>This defines an alias, <literal>hg</literal>. When you | 857 <para id="x_4ba">This defines an alias, <literal>hg</literal>. When you |
858 use it on the <command>ssh</command> command line or in a | 858 use it on the <command>ssh</command> command line or in a |
859 Mercurial <literal>ssh</literal>-protocol URL, it will cause | 859 Mercurial <literal>ssh</literal>-protocol URL, it will cause |
860 <command>ssh</command> to connect to | 860 <command>ssh</command> to connect to |
861 <literal>hg.example.com</literal> and use compression. This | 861 <literal>hg.example.com</literal> and use compression. This |
862 gives you both a shorter name to type and compression, each of | 862 gives you both a shorter name to type and compression, each of |
865 </sect2> | 865 </sect2> |
866 </sect1> | 866 </sect1> |
867 <sect1 id="sec:collab:cgi"> | 867 <sect1 id="sec:collab:cgi"> |
868 <title>Serving over HTTP using CGI</title> | 868 <title>Serving over HTTP using CGI</title> |
869 | 869 |
870 <para>Depending on how ambitious you are, configuring Mercurial's | 870 <para id="x_4bb">Depending on how ambitious you are, configuring Mercurial's |
871 CGI interface can take anything from a few moments to several | 871 CGI interface can take anything from a few moments to several |
872 hours.</para> | 872 hours.</para> |
873 | 873 |
874 <para>We'll begin with the simplest of examples, and work our way | 874 <para id="x_4bc">We'll begin with the simplest of examples, and work our way |
875 towards a more complex configuration. Even for the most basic | 875 towards a more complex configuration. Even for the most basic |
876 case, you're almost certainly going to need to read and modify | 876 case, you're almost certainly going to need to read and modify |
877 your web server's configuration.</para> | 877 your web server's configuration.</para> |
878 | 878 |
879 <note> | 879 <note> |
880 <para> Configuring a web server is a complex, fiddly, and | 880 <para id="x_4bd"> Configuring a web server is a complex, fiddly, and |
881 highly system-dependent activity. I can't possibly give you | 881 highly system-dependent activity. I can't possibly give you |
882 instructions that will cover anything like all of the cases | 882 instructions that will cover anything like all of the cases |
883 you will encounter. Please use your discretion and judgment in | 883 you will encounter. Please use your discretion and judgment in |
884 following the sections below. Be prepared to make plenty of | 884 following the sections below. Be prepared to make plenty of |
885 mistakes, and to spend a lot of time reading your server's | 885 mistakes, and to spend a lot of time reading your server's |
887 </note> | 887 </note> |
888 | 888 |
889 <sect2> | 889 <sect2> |
890 <title>Web server configuration checklist</title> | 890 <title>Web server configuration checklist</title> |
891 | 891 |
892 <para>Before you continue, do take a few moments to check a few | 892 <para id="x_4be">Before you continue, do take a few moments to check a few |
893 aspects of your system's setup.</para> | 893 aspects of your system's setup.</para> |
894 | 894 |
895 <orderedlist> | 895 <orderedlist> |
896 <listitem><para>Do you have a web server installed at all? | 896 <listitem><para id="x_4bf">Do you have a web server installed at all? |
897 Mac OS X ships with Apache, but many other systems may not | 897 Mac OS X ships with Apache, but many other systems may not |
898 have a web server installed.</para> | 898 have a web server installed.</para> |
899 </listitem> | 899 </listitem> |
900 <listitem><para>If you have a web server installed, is it | 900 <listitem><para id="x_4c0">If you have a web server installed, is it |
901 actually running? On most systems, even if one is | 901 actually running? On most systems, even if one is |
902 present, it will be disabled by default.</para> | 902 present, it will be disabled by default.</para> |
903 </listitem> | 903 </listitem> |
904 <listitem><para>Is your server configured to allow you to run | 904 <listitem><para id="x_4c1">Is your server configured to allow you to run |
905 CGI programs in the directory where you plan to do so? | 905 CGI programs in the directory where you plan to do so? |
906 Most servers default to explicitly disabling the ability | 906 Most servers default to explicitly disabling the ability |
907 to run CGI programs.</para> | 907 to run CGI programs.</para> |
908 </listitem></orderedlist> | 908 </listitem></orderedlist> |
909 | 909 |
910 <para>If you don't have a web server installed, and don't have | 910 <para id="x_4c2">If you don't have a web server installed, and don't have |
911 substantial experience configuring Apache, you should consider | 911 substantial experience configuring Apache, you should consider |
912 using the <literal>lighttpd</literal> web server instead of | 912 using the <literal>lighttpd</literal> web server instead of |
913 Apache. Apache has a well-deserved reputation for baroque and | 913 Apache. Apache has a well-deserved reputation for baroque and |
914 confusing configuration. While <literal>lighttpd</literal> is | 914 confusing configuration. While <literal>lighttpd</literal> is |
915 less capable in some ways than Apache, most of these | 915 less capable in some ways than Apache, most of these |
920 | 920 |
921 </sect2> | 921 </sect2> |
922 <sect2> | 922 <sect2> |
923 <title>Basic CGI configuration</title> | 923 <title>Basic CGI configuration</title> |
924 | 924 |
925 <para>On Unix-like systems, it's common for users to have a | 925 <para id="x_4c3">On Unix-like systems, it's common for users to have a |
926 subdirectory named something like <filename | 926 subdirectory named something like <filename |
927 class="directory">public_html</filename> in their home | 927 class="directory">public_html</filename> in their home |
928 directory, from which they can serve up web pages. A file | 928 directory, from which they can serve up web pages. A file |
929 named <filename>foo</filename> in this directory will be | 929 named <filename>foo</filename> in this directory will be |
930 accessible at a URL of the form | 930 accessible at a URL of the form |
931 <literal>http://www.example.com/username/foo</literal>.</para> | 931 <literal>http://www.example.com/username/foo</literal>.</para> |
932 | 932 |
933 <para>To get started, find the <filename | 933 <para id="x_4c4">To get started, find the <filename |
934 role="special">hgweb.cgi</filename> script that should be | 934 role="special">hgweb.cgi</filename> script that should be |
935 present in your Mercurial installation. If you can't quickly | 935 present in your Mercurial installation. If you can't quickly |
936 find a local copy on your system, simply download one from the | 936 find a local copy on your system, simply download one from the |
937 master Mercurial repository at <ulink | 937 master Mercurial repository at <ulink |
938 url="http://www.selenic.com/repo/hg/raw-file/tip/hgweb.cgi">http://www.selenic.com/repo/hg/raw-file/tip/hgweb.cgi</ulink>.</para> | 938 url="http://www.selenic.com/repo/hg/raw-file/tip/hgweb.cgi">http://www.selenic.com/repo/hg/raw-file/tip/hgweb.cgi</ulink>.</para> |
939 | 939 |
940 <para>You'll need to copy this script into your <filename | 940 <para id="x_4c5">You'll need to copy this script into your <filename |
941 class="directory">public_html</filename> directory, and | 941 class="directory">public_html</filename> directory, and |
942 ensure that it's executable.</para> | 942 ensure that it's executable.</para> |
943 <programlisting>cp .../hgweb.cgi ~/public_html | 943 <programlisting>cp .../hgweb.cgi ~/public_html |
944 chmod 755 ~/public_html/hgweb.cgi</programlisting> | 944 chmod 755 ~/public_html/hgweb.cgi</programlisting> |
945 <para>The <literal>755</literal> argument to | 945 <para id="x_4c6">The <literal>755</literal> argument to |
946 <command>chmod</command> is a little more general than just | 946 <command>chmod</command> is a little more general than just |
947 making the script executable: it ensures that the script is | 947 making the script executable: it ensures that the script is |
948 executable by anyone, and that <quote>group</quote> and | 948 executable by anyone, and that <quote>group</quote> and |
949 <quote>other</quote> write permissions are | 949 <quote>other</quote> write permissions are |
950 <emphasis>not</emphasis> set. If you were to leave those | 950 <emphasis>not</emphasis> set. If you were to leave those |
957 | 957 |
958 <sect3 id="sec:collab:wtf"> | 958 <sect3 id="sec:collab:wtf"> |
959 <title>What could <emphasis>possibly</emphasis> go | 959 <title>What could <emphasis>possibly</emphasis> go |
960 wrong?</title> | 960 wrong?</title> |
961 | 961 |
962 <para>Once you've copied the CGI script into place, go into a | 962 <para id="x_4c7">Once you've copied the CGI script into place, go into a |
963 web browser, and try to open the URL <ulink | 963 web browser, and try to open the URL <ulink |
964 url="http://myhostname/ | 964 url="http://myhostname/ |
965 myuser/hgweb.cgi">http://myhostname/ | 965 myuser/hgweb.cgi">http://myhostname/ |
966 myuser/hgweb.cgi</ulink>, <emphasis>but</emphasis> brace | 966 myuser/hgweb.cgi</ulink>, <emphasis>but</emphasis> brace |
967 yourself for instant failure. There's a high probability | 967 yourself for instant failure. There's a high probability |
971 so please read carefully. The following are all of the | 971 so please read carefully. The following are all of the |
972 problems I ran into on a system running Fedora 7, with a | 972 problems I ran into on a system running Fedora 7, with a |
973 fresh installation of Apache, and a user account that I | 973 fresh installation of Apache, and a user account that I |
974 created specially to perform this exercise.</para> | 974 created specially to perform this exercise.</para> |
975 | 975 |
976 <para>Your web server may have per-user directories disabled. | 976 <para id="x_4c8">Your web server may have per-user directories disabled. |
977 If you're using Apache, search your config file for a | 977 If you're using Apache, search your config file for a |
978 <literal>UserDir</literal> directive. If there's none | 978 <literal>UserDir</literal> directive. If there's none |
979 present, per-user directories will be disabled. If one | 979 present, per-user directories will be disabled. If one |
980 exists, but its value is <literal>disabled</literal>, then | 980 exists, but its value is <literal>disabled</literal>, then |
981 per-user directories will be disabled. Otherwise, the | 981 per-user directories will be disabled. Otherwise, the |
982 string after <literal>UserDir</literal> gives the name of | 982 string after <literal>UserDir</literal> gives the name of |
983 the subdirectory that Apache will look in under your home | 983 the subdirectory that Apache will look in under your home |
984 directory, for example <filename | 984 directory, for example <filename |
985 class="directory">public_html</filename>.</para> | 985 class="directory">public_html</filename>.</para> |
986 | 986 |
987 <para>Your file access permissions may be too restrictive. | 987 <para id="x_4c9">Your file access permissions may be too restrictive. |
988 The web server must be able to traverse your home directory | 988 The web server must be able to traverse your home directory |
989 and directories under your <filename | 989 and directories under your <filename |
990 class="directory">public_html</filename> directory, and | 990 class="directory">public_html</filename> directory, and |
991 read files under the latter too. Here's a quick recipe to | 991 read files under the latter too. Here's a quick recipe to |
992 help you to make your permissions more appropriate.</para> | 992 help you to make your permissions more appropriate.</para> |
993 <programlisting>chmod 755 ~ | 993 <programlisting>chmod 755 ~ |
994 find ~/public_html -type d -print0 | xargs -0r chmod 755 | 994 find ~/public_html -type d -print0 | xargs -0r chmod 755 |
995 find ~/public_html -type f -print0 | xargs -0r chmod 644</programlisting> | 995 find ~/public_html -type f -print0 | xargs -0r chmod 644</programlisting> |
996 | 996 |
997 <para>The other possibility with permissions is that you might | 997 <para id="x_4ca">The other possibility with permissions is that you might |
998 get a completely empty window when you try to load the | 998 get a completely empty window when you try to load the |
999 script. In this case, it's likely that your access | 999 script. In this case, it's likely that your access |
1000 permissions are <emphasis>too permissive</emphasis>. Apache's | 1000 permissions are <emphasis>too permissive</emphasis>. Apache's |
1001 <literal>suexec</literal> subsystem won't execute a script | 1001 <literal>suexec</literal> subsystem won't execute a script |
1002 that's group- or world-writable, for example.</para> | 1002 that's group- or world-writable, for example.</para> |
1003 | 1003 |
1004 <para>Your web server may be configured to disallow execution | 1004 <para id="x_4cb">Your web server may be configured to disallow execution |
1005 of CGI programs in your per-user web directory. Here's | 1005 of CGI programs in your per-user web directory. Here's |
1006 Apache's default per-user configuration from my Fedora | 1006 Apache's default per-user configuration from my Fedora |
1007 system.</para> | 1007 system.</para> |
1008 | 1008 |
1009 &ch06-apache-config.lst; | 1009 &ch06-apache-config.lst; |
1010 | 1010 |
1011 <para>If you find a similar-looking | 1011 <para id="x_4cc">If you find a similar-looking |
1012 <literal>Directory</literal> group in your Apache | 1012 <literal>Directory</literal> group in your Apache |
1013 configuration, the directive to look at inside it is | 1013 configuration, the directive to look at inside it is |
1014 <literal>Options</literal>. Add <literal>ExecCGI</literal> | 1014 <literal>Options</literal>. Add <literal>ExecCGI</literal> |
1015 to the end of this list if it's missing, and restart the web | 1015 to the end of this list if it's missing, and restart the web |
1016 server.</para> | 1016 server.</para> |
1017 | 1017 |
1018 <para>If you find that Apache serves you the text of the CGI | 1018 <para id="x_4cd">If you find that Apache serves you the text of the CGI |
1019 script instead of executing it, you may need to either | 1019 script instead of executing it, you may need to either |
1020 uncomment (if already present) or add a directive like | 1020 uncomment (if already present) or add a directive like |
1021 this.</para> | 1021 this.</para> |
1022 <programlisting>AddHandler cgi-script .cgi</programlisting> | 1022 <programlisting>AddHandler cgi-script .cgi</programlisting> |
1023 | 1023 |
1024 <para>The next possibility is that you might be served with a | 1024 <para id="x_4ce">The next possibility is that you might be served with a |
1025 colourful Python backtrace claiming that it can't import a | 1025 colourful Python backtrace claiming that it can't import a |
1026 <literal>mercurial</literal>-related module. This is | 1026 <literal>mercurial</literal>-related module. This is |
1027 actually progress! The server is now capable of executing | 1027 actually progress! The server is now capable of executing |
1028 your CGI script. This error is only likely to occur if | 1028 your CGI script. This error is only likely to occur if |
1029 you're running a private installation of Mercurial, instead | 1029 you're running a private installation of Mercurial, instead |
1033 this error happens to you, edit your copy of <filename | 1033 this error happens to you, edit your copy of <filename |
1034 role="special">hgweb.cgi</filename> and follow the | 1034 role="special">hgweb.cgi</filename> and follow the |
1035 directions inside it to correctly set your | 1035 directions inside it to correctly set your |
1036 <envar>PYTHONPATH</envar> environment variable.</para> | 1036 <envar>PYTHONPATH</envar> environment variable.</para> |
1037 | 1037 |
1038 <para>Finally, you are <emphasis>certain</emphasis> to by | 1038 <para id="x_4cf">Finally, you are <emphasis>certain</emphasis> to by |
1039 served with another colourful Python backtrace: this one | 1039 served with another colourful Python backtrace: this one |
1040 will complain that it can't find <filename | 1040 will complain that it can't find <filename |
1041 class="directory">/path/to/repository</filename>. Edit | 1041 class="directory">/path/to/repository</filename>. Edit |
1042 your <filename role="special">hgweb.cgi</filename> script | 1042 your <filename role="special">hgweb.cgi</filename> script |
1043 and replace the <filename | 1043 and replace the <filename |
1044 class="directory">/path/to/repository</filename> string | 1044 class="directory">/path/to/repository</filename> string |
1045 with the complete path to the repository you want to serve | 1045 with the complete path to the repository you want to serve |
1046 up.</para> | 1046 up.</para> |
1047 | 1047 |
1048 <para>At this point, when you try to reload the page, you | 1048 <para id="x_4d0">At this point, when you try to reload the page, you |
1049 should be presented with a nice HTML view of your | 1049 should be presented with a nice HTML view of your |
1050 repository's history. Whew!</para> | 1050 repository's history. Whew!</para> |
1051 | 1051 |
1052 </sect3> | 1052 </sect3> |
1053 <sect3> | 1053 <sect3> |
1054 <title>Configuring lighttpd</title> | 1054 <title>Configuring lighttpd</title> |
1055 | 1055 |
1056 <para>To be exhaustive in my experiments, I tried configuring | 1056 <para id="x_4d1">To be exhaustive in my experiments, I tried configuring |
1057 the increasingly popular <literal>lighttpd</literal> web | 1057 the increasingly popular <literal>lighttpd</literal> web |
1058 server to serve the same repository as I described with | 1058 server to serve the same repository as I described with |
1059 Apache above. I had already overcome all of the problems I | 1059 Apache above. I had already overcome all of the problems I |
1060 outlined with Apache, many of which are not server-specific. | 1060 outlined with Apache, many of which are not server-specific. |
1061 As a result, I was fairly sure that my file and directory | 1061 As a result, I was fairly sure that my file and directory |
1062 permissions were good, and that my <filename | 1062 permissions were good, and that my <filename |
1063 role="special">hgweb.cgi</filename> script was properly | 1063 role="special">hgweb.cgi</filename> script was properly |
1064 edited.</para> | 1064 edited.</para> |
1065 | 1065 |
1066 <para>Once I had Apache running, getting | 1066 <para id="x_4d2">Once I had Apache running, getting |
1067 <literal>lighttpd</literal> to serve the repository was a | 1067 <literal>lighttpd</literal> to serve the repository was a |
1068 snap (in other words, even if you're trying to use | 1068 snap (in other words, even if you're trying to use |
1069 <literal>lighttpd</literal>, you should read the Apache | 1069 <literal>lighttpd</literal>, you should read the Apache |
1070 section). I first had to edit the | 1070 section). I first had to edit the |
1071 <literal>mod_access</literal> section of its config file to | 1071 <literal>mod_access</literal> section of its config file to |
1073 <literal>mod_userdir</literal>, both of which were disabled | 1073 <literal>mod_userdir</literal>, both of which were disabled |
1074 by default on my system. I then added a few lines to the | 1074 by default on my system. I then added a few lines to the |
1075 end of the config file, to configure these modules.</para> | 1075 end of the config file, to configure these modules.</para> |
1076 <programlisting>userdir.path = "public_html" | 1076 <programlisting>userdir.path = "public_html" |
1077 cgi.assign = (".cgi" => "" )</programlisting> | 1077 cgi.assign = (".cgi" => "" )</programlisting> |
1078 <para>With this done, <literal>lighttpd</literal> ran | 1078 <para id="x_4d3">With this done, <literal>lighttpd</literal> ran |
1079 immediately for me. If I had configured | 1079 immediately for me. If I had configured |
1080 <literal>lighttpd</literal> before Apache, I'd almost | 1080 <literal>lighttpd</literal> before Apache, I'd almost |
1081 certainly have run into many of the same system-level | 1081 certainly have run into many of the same system-level |
1082 configuration problems as I did with Apache. However, I | 1082 configuration problems as I did with Apache. However, I |
1083 found <literal>lighttpd</literal> to be noticeably easier to | 1083 found <literal>lighttpd</literal> to be noticeably easier to |
1088 </sect3> | 1088 </sect3> |
1089 </sect2> | 1089 </sect2> |
1090 <sect2> | 1090 <sect2> |
1091 <title>Sharing multiple repositories with one CGI script</title> | 1091 <title>Sharing multiple repositories with one CGI script</title> |
1092 | 1092 |
1093 <para>The <filename role="special">hgweb.cgi</filename> script | 1093 <para id="x_4d4">The <filename role="special">hgweb.cgi</filename> script |
1094 only lets you publish a single repository, which is an | 1094 only lets you publish a single repository, which is an |
1095 annoying restriction. If you want to publish more than one | 1095 annoying restriction. If you want to publish more than one |
1096 without wracking yourself with multiple copies of the same | 1096 without wracking yourself with multiple copies of the same |
1097 script, each with different names, a better choice is to use | 1097 script, each with different names, a better choice is to use |
1098 the <filename role="special">hgwebdir.cgi</filename> | 1098 the <filename role="special">hgwebdir.cgi</filename> |
1099 script.</para> | 1099 script.</para> |
1100 | 1100 |
1101 <para>The procedure to configure <filename | 1101 <para id="x_4d5">The procedure to configure <filename |
1102 role="special">hgwebdir.cgi</filename> is only a little more | 1102 role="special">hgwebdir.cgi</filename> is only a little more |
1103 involved than for <filename | 1103 involved than for <filename |
1104 role="special">hgweb.cgi</filename>. First, you must obtain | 1104 role="special">hgweb.cgi</filename>. First, you must obtain |
1105 a copy of the script. If you don't have one handy, you can | 1105 a copy of the script. If you don't have one handy, you can |
1106 download a copy from the master Mercurial repository at <ulink | 1106 download a copy from the master Mercurial repository at <ulink |
1107 url="http://www.selenic.com/repo/hg/raw-file/tip/hgwebdir.cgi">http://www.selenic.com/repo/hg/raw-file/tip/hgwebdir.cgi</ulink>.</para> | 1107 url="http://www.selenic.com/repo/hg/raw-file/tip/hgwebdir.cgi">http://www.selenic.com/repo/hg/raw-file/tip/hgwebdir.cgi</ulink>.</para> |
1108 | 1108 |
1109 <para>You'll need to copy this script into your <filename | 1109 <para id="x_4d6">You'll need to copy this script into your <filename |
1110 class="directory">public_html</filename> directory, and | 1110 class="directory">public_html</filename> directory, and |
1111 ensure that it's executable.</para> | 1111 ensure that it's executable.</para> |
1112 <programlisting>cp .../hgwebdir.cgi ~/public_html | 1112 <programlisting>cp .../hgwebdir.cgi ~/public_html |
1113 chmod 755 ~/public_html ~/public_html/hgwebdir.cgi</programlisting> | 1113 chmod 755 ~/public_html ~/public_html/hgwebdir.cgi</programlisting> |
1114 <para>With basic configuration out of the way, try to visit | 1114 <para id="x_4d7">With basic configuration out of the way, try to visit |
1115 <ulink url="http://myhostname/ | 1115 <ulink url="http://myhostname/ |
1116 myuser/hgwebdir.cgi">http://myhostname/ | 1116 myuser/hgwebdir.cgi">http://myhostname/ |
1117 myuser/hgwebdir.cgi</ulink> in your browser. It should | 1117 myuser/hgwebdir.cgi</ulink> in your browser. It should |
1118 display an empty list of repositories. If you get a blank | 1118 display an empty list of repositories. If you get a blank |
1119 window or error message, try walking through the list of | 1119 window or error message, try walking through the list of |
1120 potential problems in section <xref | 1120 potential problems in section <xref |
1121 linkend="sec:collab:wtf"/>.</para> | 1121 linkend="sec:collab:wtf"/>.</para> |
1122 | 1122 |
1123 <para>The <filename role="special">hgwebdir.cgi</filename> | 1123 <para id="x_4d8">The <filename role="special">hgwebdir.cgi</filename> |
1124 script relies on an external configuration file. By default, | 1124 script relies on an external configuration file. By default, |
1125 it searches for a file named <filename | 1125 it searches for a file named <filename |
1126 role="special">hgweb.config</filename> in the same directory | 1126 role="special">hgweb.config</filename> in the same directory |
1127 as itself. You'll need to create this file, and make it | 1127 as itself. You'll need to create this file, and make it |
1128 world-readable. The format of the file is similar to a | 1128 world-readable. The format of the file is similar to a |
1129 Windows <quote>ini</quote> file, as understood by Python's | 1129 Windows <quote>ini</quote> file, as understood by Python's |
1130 <literal>ConfigParser</literal> | 1130 <literal>ConfigParser</literal> |
1131 <citation>web:configparser</citation> module.</para> | 1131 <citation>web:configparser</citation> module.</para> |
1132 | 1132 |
1133 <para>The easiest way to configure <filename | 1133 <para id="x_4d9">The easiest way to configure <filename |
1134 role="special">hgwebdir.cgi</filename> is with a section | 1134 role="special">hgwebdir.cgi</filename> is with a section |
1135 named <literal>collections</literal>. This will automatically | 1135 named <literal>collections</literal>. This will automatically |
1136 publish <emphasis>every</emphasis> repository under the | 1136 publish <emphasis>every</emphasis> repository under the |
1137 directories you name. The section should look like | 1137 directories you name. The section should look like |
1138 this:</para> | 1138 this:</para> |
1139 <programlisting>[collections] | 1139 <programlisting>[collections] |
1140 /my/root = /my/root</programlisting> | 1140 /my/root = /my/root</programlisting> |
1141 <para>Mercurial interprets this by looking at the directory name | 1141 <para id="x_4da">Mercurial interprets this by looking at the directory name |
1142 on the <emphasis>right</emphasis> hand side of the | 1142 on the <emphasis>right</emphasis> hand side of the |
1143 <quote><literal>=</literal></quote> sign; finding repositories | 1143 <quote><literal>=</literal></quote> sign; finding repositories |
1144 in that directory hierarchy; and using the text on the | 1144 in that directory hierarchy; and using the text on the |
1145 <emphasis>left</emphasis> to strip off matching text from the | 1145 <emphasis>left</emphasis> to strip off matching text from the |
1146 names it will actually list in the web interface. The | 1146 names it will actually list in the web interface. The |
1147 remaining component of a path after this stripping has | 1147 remaining component of a path after this stripping has |
1148 occurred is called a <quote>virtual path</quote>.</para> | 1148 occurred is called a <quote>virtual path</quote>.</para> |
1149 | 1149 |
1150 <para>Given the example above, if we have a repository whose | 1150 <para id="x_4db">Given the example above, if we have a repository whose |
1151 local path is <filename | 1151 local path is <filename |
1152 class="directory">/my/root/this/repo</filename>, the CGI | 1152 class="directory">/my/root/this/repo</filename>, the CGI |
1153 script will strip the leading <filename | 1153 script will strip the leading <filename |
1154 class="directory">/my/root</filename> from the name, and | 1154 class="directory">/my/root</filename> from the name, and |
1155 publish the repository with a virtual path of <filename | 1155 publish the repository with a virtual path of <filename |
1159 myuser/hgwebdir.cgi</ulink>, the complete URL for that | 1159 myuser/hgwebdir.cgi</ulink>, the complete URL for that |
1160 repository will be <ulink url="http://myhostname/ | 1160 repository will be <ulink url="http://myhostname/ |
1161 myuser/hgwebdir.cgi/this/repo">http://myhostname/ | 1161 myuser/hgwebdir.cgi/this/repo">http://myhostname/ |
1162 myuser/hgwebdir.cgi/this/repo</ulink>.</para> | 1162 myuser/hgwebdir.cgi/this/repo</ulink>.</para> |
1163 | 1163 |
1164 <para>If we replace <filename | 1164 <para id="x_4dc">If we replace <filename |
1165 class="directory">/my/root</filename> on the left hand side | 1165 class="directory">/my/root</filename> on the left hand side |
1166 of this example with <filename | 1166 of this example with <filename |
1167 class="directory">/my</filename>, then <filename | 1167 class="directory">/my</filename>, then <filename |
1168 role="special">hgwebdir.cgi</filename> will only strip off | 1168 role="special">hgwebdir.cgi</filename> will only strip off |
1169 <filename class="directory">/my</filename> from the repository | 1169 <filename class="directory">/my</filename> from the repository |
1170 name, and will give us a virtual path of <filename | 1170 name, and will give us a virtual path of <filename |
1171 class="directory">root/this/repo</filename> instead of | 1171 class="directory">root/this/repo</filename> instead of |
1172 <filename class="directory">this/repo</filename>.</para> | 1172 <filename class="directory">this/repo</filename>.</para> |
1173 | 1173 |
1174 <para>The <filename role="special">hgwebdir.cgi</filename> | 1174 <para id="x_4dd">The <filename role="special">hgwebdir.cgi</filename> |
1175 script will recursively search each directory listed in the | 1175 script will recursively search each directory listed in the |
1176 <literal>collections</literal> section of its configuration | 1176 <literal>collections</literal> section of its configuration |
1177 file, but it will <literal>not</literal> recurse into the | 1177 file, but it will <literal>not</literal> recurse into the |
1178 repositories it finds.</para> | 1178 repositories it finds.</para> |
1179 | 1179 |
1180 <para>The <literal>collections</literal> mechanism makes it easy | 1180 <para id="x_4de">The <literal>collections</literal> mechanism makes it easy |
1181 to publish many repositories in a <quote>fire and | 1181 to publish many repositories in a <quote>fire and |
1182 forget</quote> manner. You only need to set up the CGI | 1182 forget</quote> manner. You only need to set up the CGI |
1183 script and configuration file one time. Afterwards, you can | 1183 script and configuration file one time. Afterwards, you can |
1184 publish or unpublish a repository at any time by simply moving | 1184 publish or unpublish a repository at any time by simply moving |
1185 it into, or out of, the directory hierarchy in which you've | 1185 it into, or out of, the directory hierarchy in which you've |
1188 | 1188 |
1189 <sect3> | 1189 <sect3> |
1190 <title>Explicitly specifying which repositories to | 1190 <title>Explicitly specifying which repositories to |
1191 publish</title> | 1191 publish</title> |
1192 | 1192 |
1193 <para>In addition to the <literal>collections</literal> | 1193 <para id="x_4df">In addition to the <literal>collections</literal> |
1194 mechanism, the <filename | 1194 mechanism, the <filename |
1195 role="special">hgwebdir.cgi</filename> script allows you | 1195 role="special">hgwebdir.cgi</filename> script allows you |
1196 to publish a specific list of repositories. To do so, | 1196 to publish a specific list of repositories. To do so, |
1197 create a <literal>paths</literal> section, with contents of | 1197 create a <literal>paths</literal> section, with contents of |
1198 the following form.</para> | 1198 the following form.</para> |
1199 <programlisting>[paths] | 1199 <programlisting>[paths] |
1200 repo1 = /my/path/to/some/repo | 1200 repo1 = /my/path/to/some/repo |
1201 repo2 = /some/path/to/another</programlisting> | 1201 repo2 = /some/path/to/another</programlisting> |
1202 <para>In this case, the virtual path (the component that will | 1202 <para id="x_4e0">In this case, the virtual path (the component that will |
1203 appear in a URL) is on the left hand side of each | 1203 appear in a URL) is on the left hand side of each |
1204 definition, while the path to the repository is on the | 1204 definition, while the path to the repository is on the |
1205 right. Notice that there does not need to be any | 1205 right. Notice that there does not need to be any |
1206 relationship between the virtual path you choose and the | 1206 relationship between the virtual path you choose and the |
1207 location of a repository in your filesystem.</para> | 1207 location of a repository in your filesystem.</para> |
1208 | 1208 |
1209 <para>If you wish, you can use both the | 1209 <para id="x_4e1">If you wish, you can use both the |
1210 <literal>collections</literal> and <literal>paths</literal> | 1210 <literal>collections</literal> and <literal>paths</literal> |
1211 mechanisms simultaneously in a single configuration | 1211 mechanisms simultaneously in a single configuration |
1212 file.</para> | 1212 file.</para> |
1213 | 1213 |
1214 <note> | 1214 <note> |
1215 <para> If multiple repositories have the same virtual path, | 1215 <para id="x_4e2"> If multiple repositories have the same virtual path, |
1216 <filename role="special">hgwebdir.cgi</filename> will not | 1216 <filename role="special">hgwebdir.cgi</filename> will not |
1217 report an error. Instead, it will behave | 1217 report an error. Instead, it will behave |
1218 unpredictably.</para> | 1218 unpredictably.</para> |
1219 </note> | 1219 </note> |
1220 | 1220 |
1221 </sect3> | 1221 </sect3> |
1222 </sect2> | 1222 </sect2> |
1223 <sect2> | 1223 <sect2> |
1224 <title>Downloading source archives</title> | 1224 <title>Downloading source archives</title> |
1225 | 1225 |
1226 <para>Mercurial's web interface lets users download an archive | 1226 <para id="x_4e3">Mercurial's web interface lets users download an archive |
1227 of any revision. This archive will contain a snapshot of the | 1227 of any revision. This archive will contain a snapshot of the |
1228 working directory as of that revision, but it will not contain | 1228 working directory as of that revision, but it will not contain |
1229 a copy of the repository data.</para> | 1229 a copy of the repository data.</para> |
1230 | 1230 |
1231 <para>By default, this feature is not enabled. To enable it, | 1231 <para id="x_4e4">By default, this feature is not enabled. To enable it, |
1232 you'll need to add an <envar | 1232 you'll need to add an <envar |
1233 role="rc-item-web">allow_archive</envar> item to the | 1233 role="rc-item-web">allow_archive</envar> item to the |
1234 <literal role="rc-web">web</literal> section of your <filename | 1234 <literal role="rc-web">web</literal> section of your <filename |
1235 role="special">~/.hgrc</filename>.</para> | 1235 role="special">~/.hgrc</filename>.</para> |
1236 | 1236 |
1237 </sect2> | 1237 </sect2> |
1238 <sect2> | 1238 <sect2> |
1239 <title>Web configuration options</title> | 1239 <title>Web configuration options</title> |
1240 | 1240 |
1241 <para>Mercurial's web interfaces (the <command role="hg-cmd">hg | 1241 <para id="x_4e5">Mercurial's web interfaces (the <command role="hg-cmd">hg |
1242 serve</command> command, and the <filename | 1242 serve</command> command, and the <filename |
1243 role="special">hgweb.cgi</filename> and <filename | 1243 role="special">hgweb.cgi</filename> and <filename |
1244 role="special">hgwebdir.cgi</filename> scripts) have a | 1244 role="special">hgwebdir.cgi</filename> scripts) have a |
1245 number of configuration options that you can set. These | 1245 number of configuration options that you can set. These |
1246 belong in a section named <literal | 1246 belong in a section named <literal |
1247 role="rc-web">web</literal>.</para> | 1247 role="rc-web">web</literal>.</para> |
1248 <itemizedlist> | 1248 <itemizedlist> |
1249 <listitem><para><envar | 1249 <listitem><para id="x_4e6"><envar |
1250 role="rc-item-web">allow_archive</envar>: Determines | 1250 role="rc-item-web">allow_archive</envar>: Determines |
1251 which (if any) archive download mechanisms Mercurial | 1251 which (if any) archive download mechanisms Mercurial |
1252 supports. If you enable this feature, users of the web | 1252 supports. If you enable this feature, users of the web |
1253 interface will be able to download an archive of whatever | 1253 interface will be able to download an archive of whatever |
1254 revision of a repository they are viewing. To enable the | 1254 revision of a repository they are viewing. To enable the |
1255 archive feature, this item must take the form of a | 1255 archive feature, this item must take the form of a |
1256 sequence of words drawn from the list below.</para> | 1256 sequence of words drawn from the list below.</para> |
1257 <itemizedlist> | 1257 <itemizedlist> |
1258 <listitem><para><literal>bz2</literal>: A | 1258 <listitem><para id="x_4e7"><literal>bz2</literal>: A |
1259 <command>tar</command> archive, compressed using | 1259 <command>tar</command> archive, compressed using |
1260 <literal>bzip2</literal> compression. This has the | 1260 <literal>bzip2</literal> compression. This has the |
1261 best compression ratio, but uses the most CPU time on | 1261 best compression ratio, but uses the most CPU time on |
1262 the server.</para> | 1262 the server.</para> |
1263 </listitem> | 1263 </listitem> |
1264 <listitem><para><literal>gz</literal>: A | 1264 <listitem><para id="x_4e8"><literal>gz</literal>: A |
1265 <command>tar</command> archive, compressed using | 1265 <command>tar</command> archive, compressed using |
1266 <literal>gzip</literal> compression.</para> | 1266 <literal>gzip</literal> compression.</para> |
1267 </listitem> | 1267 </listitem> |
1268 <listitem><para><literal>zip</literal>: A | 1268 <listitem><para id="x_4e9"><literal>zip</literal>: A |
1269 <command>zip</command> archive, compressed using LZW | 1269 <command>zip</command> archive, compressed using LZW |
1270 compression. This format has the worst compression | 1270 compression. This format has the worst compression |
1271 ratio, but is widely used in the Windows world.</para> | 1271 ratio, but is widely used in the Windows world.</para> |
1272 </listitem> | 1272 </listitem> |
1273 </itemizedlist> | 1273 </itemizedlist> |
1274 <para> If you provide an empty list, or don't have an | 1274 <para id="x_4ea"> If you provide an empty list, or don't have an |
1275 <envar role="rc-item-web">allow_archive</envar> entry at | 1275 <envar role="rc-item-web">allow_archive</envar> entry at |
1276 all, this feature will be disabled. Here is an example of | 1276 all, this feature will be disabled. Here is an example of |
1277 how to enable all three supported formats.</para> | 1277 how to enable all three supported formats.</para> |
1278 <programlisting>[web] | 1278 <programlisting>[web] |
1279 allow_archive = bz2 gz zip</programlisting> | 1279 allow_archive = bz2 gz zip</programlisting> |
1280 </listitem> | 1280 </listitem> |
1281 <listitem><para><envar role="rc-item-web">allowpull</envar>: | 1281 <listitem><para id="x_4eb"><envar role="rc-item-web">allowpull</envar>: |
1282 Boolean. Determines whether the web interface allows | 1282 Boolean. Determines whether the web interface allows |
1283 remote users to <command role="hg-cmd">hg pull</command> | 1283 remote users to <command role="hg-cmd">hg pull</command> |
1284 and <command role="hg-cmd">hg clone</command> this | 1284 and <command role="hg-cmd">hg clone</command> this |
1285 repository over HTTP. If set to <literal>no</literal> or | 1285 repository over HTTP. If set to <literal>no</literal> or |
1286 <literal>false</literal>, only the | 1286 <literal>false</literal>, only the |
1287 <quote>human-oriented</quote> portion of the web interface | 1287 <quote>human-oriented</quote> portion of the web interface |
1288 is available.</para> | 1288 is available.</para> |
1289 </listitem> | 1289 </listitem> |
1290 <listitem><para><envar role="rc-item-web">contact</envar>: | 1290 <listitem><para id="x_4ec"><envar role="rc-item-web">contact</envar>: |
1291 String. A free-form (but preferably brief) string | 1291 String. A free-form (but preferably brief) string |
1292 identifying the person or group in charge of the | 1292 identifying the person or group in charge of the |
1293 repository. This often contains the name and email | 1293 repository. This often contains the name and email |
1294 address of a person or mailing list. It often makes sense | 1294 address of a person or mailing list. It often makes sense |
1295 to place this entry in a repository's own <filename | 1295 to place this entry in a repository's own <filename |
1296 role="special">.hg/hgrc</filename> file, but it can make | 1296 role="special">.hg/hgrc</filename> file, but it can make |
1297 sense to use in a global <filename | 1297 sense to use in a global <filename |
1298 role="special">~/.hgrc</filename> if every repository | 1298 role="special">~/.hgrc</filename> if every repository |
1299 has a single maintainer.</para> | 1299 has a single maintainer.</para> |
1300 </listitem> | 1300 </listitem> |
1301 <listitem><para><envar role="rc-item-web">maxchanges</envar>: | 1301 <listitem><para id="x_4ed"><envar role="rc-item-web">maxchanges</envar>: |
1302 Integer. The default maximum number of changesets to | 1302 Integer. The default maximum number of changesets to |
1303 display in a single page of output.</para> | 1303 display in a single page of output.</para> |
1304 </listitem> | 1304 </listitem> |
1305 <listitem><para><envar role="rc-item-web">maxfiles</envar>: | 1305 <listitem><para id="x_4ee"><envar role="rc-item-web">maxfiles</envar>: |
1306 Integer. The default maximum number of modified files to | 1306 Integer. The default maximum number of modified files to |
1307 display in a single page of output.</para> | 1307 display in a single page of output.</para> |
1308 </listitem> | 1308 </listitem> |
1309 <listitem><para><envar role="rc-item-web">stripes</envar>: | 1309 <listitem><para id="x_4ef"><envar role="rc-item-web">stripes</envar>: |
1310 Integer. If the web interface displays alternating | 1310 Integer. If the web interface displays alternating |
1311 <quote>stripes</quote> to make it easier to visually align | 1311 <quote>stripes</quote> to make it easier to visually align |
1312 rows when you are looking at a table, this number controls | 1312 rows when you are looking at a table, this number controls |
1313 the number of rows in each stripe.</para> | 1313 the number of rows in each stripe.</para> |
1314 </listitem> | 1314 </listitem> |
1315 <listitem><para><envar role="rc-item-web">style</envar>: | 1315 <listitem><para id="x_4f0"><envar role="rc-item-web">style</envar>: |
1316 Controls the template Mercurial uses to display the web | 1316 Controls the template Mercurial uses to display the web |
1317 interface. Mercurial ships with two web templates, named | 1317 interface. Mercurial ships with two web templates, named |
1318 <literal>default</literal> and <literal>gitweb</literal> | 1318 <literal>default</literal> and <literal>gitweb</literal> |
1319 (the latter is much more visually attractive). You can | 1319 (the latter is much more visually attractive). You can |
1320 also specify a custom template of your own; see chapter | 1320 also specify a custom template of your own; see chapter |
1322 Here, you can see how to enable the | 1322 Here, you can see how to enable the |
1323 <literal>gitweb</literal> style.</para> | 1323 <literal>gitweb</literal> style.</para> |
1324 <programlisting>[web] | 1324 <programlisting>[web] |
1325 style = gitweb</programlisting> | 1325 style = gitweb</programlisting> |
1326 </listitem> | 1326 </listitem> |
1327 <listitem><para><envar role="rc-item-web">templates</envar>: | 1327 <listitem><para id="x_4f1"><envar role="rc-item-web">templates</envar>: |
1328 Path. The directory in which to search for template | 1328 Path. The directory in which to search for template |
1329 files. By default, Mercurial searches in the directory in | 1329 files. By default, Mercurial searches in the directory in |
1330 which it was installed.</para> | 1330 which it was installed.</para> |
1331 </listitem></itemizedlist> | 1331 </listitem></itemizedlist> |
1332 <para>If you are using <filename | 1332 <para id="x_4f2">If you are using <filename |
1333 role="special">hgwebdir.cgi</filename>, you can place a few | 1333 role="special">hgwebdir.cgi</filename>, you can place a few |
1334 configuration items in a <literal role="rc-web">web</literal> | 1334 configuration items in a <literal role="rc-web">web</literal> |
1335 section of the <filename | 1335 section of the <filename |
1336 role="special">hgweb.config</filename> file instead of a | 1336 role="special">hgweb.config</filename> file instead of a |
1337 <filename role="special">~/.hgrc</filename> file, for | 1337 <filename role="special">~/.hgrc</filename> file, for |
1340 role="rc-item-web">style</envar>.</para> | 1340 role="rc-item-web">style</envar>.</para> |
1341 | 1341 |
1342 <sect3> | 1342 <sect3> |
1343 <title>Options specific to an individual repository</title> | 1343 <title>Options specific to an individual repository</title> |
1344 | 1344 |
1345 <para>A few <literal role="rc-web">web</literal> configuration | 1345 <para id="x_4f3">A few <literal role="rc-web">web</literal> configuration |
1346 items ought to be placed in a repository's local <filename | 1346 items ought to be placed in a repository's local <filename |
1347 role="special">.hg/hgrc</filename>, rather than a user's | 1347 role="special">.hg/hgrc</filename>, rather than a user's |
1348 or global <filename role="special">~/.hgrc</filename>.</para> | 1348 or global <filename role="special">~/.hgrc</filename>.</para> |
1349 <itemizedlist> | 1349 <itemizedlist> |
1350 <listitem><para><envar | 1350 <listitem><para id="x_4f4"><envar |
1351 role="rc-item-web">description</envar>: String. A | 1351 role="rc-item-web">description</envar>: String. A |
1352 free-form (but preferably brief) string that describes | 1352 free-form (but preferably brief) string that describes |
1353 the contents or purpose of the repository.</para> | 1353 the contents or purpose of the repository.</para> |
1354 </listitem> | 1354 </listitem> |
1355 <listitem><para><envar role="rc-item-web">name</envar>: | 1355 <listitem><para id="x_4f5"><envar role="rc-item-web">name</envar>: |
1356 String. The name to use for the repository in the web | 1356 String. The name to use for the repository in the web |
1357 interface. This overrides the default name, which is | 1357 interface. This overrides the default name, which is |
1358 the last component of the repository's path.</para> | 1358 the last component of the repository's path.</para> |
1359 </listitem></itemizedlist> | 1359 </listitem></itemizedlist> |
1360 | 1360 |
1361 </sect3> | 1361 </sect3> |
1362 <sect3> | 1362 <sect3> |
1363 <title>Options specific to the <command role="hg-cmd">hg | 1363 <title>Options specific to the <command role="hg-cmd">hg |
1364 serve</command> command</title> | 1364 serve</command> command</title> |
1365 | 1365 |
1366 <para>Some of the items in the <literal | 1366 <para id="x_4f6">Some of the items in the <literal |
1367 role="rc-web">web</literal> section of a <filename | 1367 role="rc-web">web</literal> section of a <filename |
1368 role="special">~/.hgrc</filename> file are only for use | 1368 role="special">~/.hgrc</filename> file are only for use |
1369 with the <command role="hg-cmd">hg serve</command> | 1369 with the <command role="hg-cmd">hg serve</command> |
1370 command.</para> | 1370 command.</para> |
1371 <itemizedlist> | 1371 <itemizedlist> |
1372 <listitem><para><envar role="rc-item-web">accesslog</envar>: | 1372 <listitem><para id="x_4f7"><envar role="rc-item-web">accesslog</envar>: |
1373 Path. The name of a file into which to write an access | 1373 Path. The name of a file into which to write an access |
1374 log. By default, the <command role="hg-cmd">hg | 1374 log. By default, the <command role="hg-cmd">hg |
1375 serve</command> command writes this information to | 1375 serve</command> command writes this information to |
1376 standard output, not to a file. Log entries are written | 1376 standard output, not to a file. Log entries are written |
1377 in the standard <quote>combined</quote> file format used | 1377 in the standard <quote>combined</quote> file format used |
1378 by almost all web servers.</para> | 1378 by almost all web servers.</para> |
1379 </listitem> | 1379 </listitem> |
1380 <listitem><para><envar role="rc-item-web">address</envar>: | 1380 <listitem><para id="x_4f8"><envar role="rc-item-web">address</envar>: |
1381 String. The local address on which the server should | 1381 String. The local address on which the server should |
1382 listen for incoming connections. By default, the server | 1382 listen for incoming connections. By default, the server |
1383 listens on all addresses.</para> | 1383 listens on all addresses.</para> |
1384 </listitem> | 1384 </listitem> |
1385 <listitem><para><envar role="rc-item-web">errorlog</envar>: | 1385 <listitem><para id="x_4f9"><envar role="rc-item-web">errorlog</envar>: |
1386 Path. The name of a file into which to write an error | 1386 Path. The name of a file into which to write an error |
1387 log. By default, the <command role="hg-cmd">hg | 1387 log. By default, the <command role="hg-cmd">hg |
1388 serve</command> command writes this information to | 1388 serve</command> command writes this information to |
1389 standard error, not to a file.</para> | 1389 standard error, not to a file.</para> |
1390 </listitem> | 1390 </listitem> |
1391 <listitem><para><envar role="rc-item-web">ipv6</envar>: | 1391 <listitem><para id="x_4fa"><envar role="rc-item-web">ipv6</envar>: |
1392 Boolean. Whether to use the IPv6 protocol. By default, | 1392 Boolean. Whether to use the IPv6 protocol. By default, |
1393 IPv6 is not used.</para> | 1393 IPv6 is not used.</para> |
1394 </listitem> | 1394 </listitem> |
1395 <listitem><para><envar role="rc-item-web">port</envar>: | 1395 <listitem><para id="x_4fb"><envar role="rc-item-web">port</envar>: |
1396 Integer. The TCP port number on which the server should | 1396 Integer. The TCP port number on which the server should |
1397 listen. The default port number used is 8000.</para> | 1397 listen. The default port number used is 8000.</para> |
1398 </listitem></itemizedlist> | 1398 </listitem></itemizedlist> |
1399 | 1399 |
1400 </sect3> | 1400 </sect3> |
1401 <sect3> | 1401 <sect3> |
1402 <title>Choosing the right <filename | 1402 <title>Choosing the right <filename |
1403 role="special">~/.hgrc</filename> file to add <literal | 1403 role="special">~/.hgrc</filename> file to add <literal |
1404 role="rc-web">web</literal> items to</title> | 1404 role="rc-web">web</literal> items to</title> |
1405 | 1405 |
1406 <para>It is important to remember that a web server like | 1406 <para id="x_4fc">It is important to remember that a web server like |
1407 Apache or <literal>lighttpd</literal> will run under a user | 1407 Apache or <literal>lighttpd</literal> will run under a user |
1408 ID that is different to yours. CGI scripts run by your | 1408 ID that is different to yours. CGI scripts run by your |
1409 server, such as <filename | 1409 server, such as <filename |
1410 role="special">hgweb.cgi</filename>, will usually also run | 1410 role="special">hgweb.cgi</filename>, will usually also run |
1411 under that user ID.</para> | 1411 under that user ID.</para> |
1412 | 1412 |
1413 <para>If you add <literal role="rc-web">web</literal> items to | 1413 <para id="x_4fd">If you add <literal role="rc-web">web</literal> items to |
1414 your own personal <filename role="special">~/.hgrc</filename> file, CGI scripts won't read that | 1414 your own personal <filename role="special">~/.hgrc</filename> file, CGI scripts won't read that |
1415 <filename role="special">~/.hgrc</filename> file. Those | 1415 <filename role="special">~/.hgrc</filename> file. Those |
1416 settings will thus only affect the behaviour of the <command | 1416 settings will thus only affect the behaviour of the <command |
1417 role="hg-cmd">hg serve</command> command when you run it. | 1417 role="hg-cmd">hg serve</command> command when you run it. |
1418 To cause CGI scripts to see your settings, either create a | 1418 To cause CGI scripts to see your settings, either create a |