Show More
@@ -1,778 +1,793 b'' | |||
|
1 | 1 | HG(1) |
|
2 | 2 | ===== |
|
3 | 3 | Matt Mackall <mpm@selenic.com> |
|
4 | 4 | |
|
5 | 5 | NAME |
|
6 | 6 | ---- |
|
7 | 7 | hg - Mercurial source code management system |
|
8 | 8 | |
|
9 | 9 | SYNOPSIS |
|
10 | 10 | -------- |
|
11 | 11 | 'hg' [-v -d -q -y] <command> [command options] [files] |
|
12 | 12 | |
|
13 | 13 | DESCRIPTION |
|
14 | 14 | ----------- |
|
15 | 15 | The hg(1) command provides a command line interface to the Mercurial system. |
|
16 | 16 | |
|
17 | 17 | OPTIONS |
|
18 | 18 | ------- |
|
19 | 19 | |
|
20 | 20 | -R, --repository:: |
|
21 | 21 | repository root directory |
|
22 | 22 | |
|
23 | 23 | --cwd:: |
|
24 | 24 | change working directory |
|
25 | 25 | |
|
26 | 26 | -y, --noninteractive:: |
|
27 | 27 | do not prompt, assume 'yes' for any required answers |
|
28 | 28 | |
|
29 | 29 | -q, --quiet:: |
|
30 | 30 | suppress output |
|
31 | 31 | |
|
32 | 32 | -v, --verbose:: |
|
33 | 33 | enable additional output |
|
34 | 34 | |
|
35 | 35 | --debug:: |
|
36 | 36 | enable debugging output |
|
37 | 37 | |
|
38 | 38 | --traceback:: |
|
39 | 39 | print traceback on exception |
|
40 | 40 | |
|
41 | 41 | --time:: |
|
42 | 42 | time how long the command takes |
|
43 | 43 | |
|
44 | 44 | --profile:: |
|
45 | 45 | print command execution profile |
|
46 | 46 | |
|
47 | 47 | --version:: |
|
48 | 48 | output version information and exit |
|
49 | 49 | |
|
50 | 50 | -h, --help:: |
|
51 | 51 | display help and exit |
|
52 | 52 | |
|
53 | 53 | COMMAND ELEMENTS |
|
54 | 54 | ---------------- |
|
55 | 55 | |
|
56 | 56 | files ...:: |
|
57 | 57 | indicates one or more filename or relative path filenames; see |
|
58 | 58 | "FILE NAME PATTERNS" for information on pattern matching |
|
59 | 59 | |
|
60 | 60 | path:: |
|
61 | 61 | indicates a path on the local machine |
|
62 | 62 | |
|
63 | 63 | revision:: |
|
64 | 64 | indicates a changeset which can be specified as a changeset revision |
|
65 | 65 | number, a tag, or a unique substring of the changeset hash value |
|
66 | 66 | |
|
67 | 67 | repository path:: |
|
68 | 68 | either the pathname of a local repository or the URI of a remote |
|
69 | 69 | repository. There are two available URI protocols, http:// which is |
|
70 | 70 | fast and the old-http:// protocol which is much slower but does not |
|
71 | 71 | require a special server on the web host. |
|
72 | 72 | |
|
73 | 73 | COMMANDS |
|
74 | 74 | -------- |
|
75 | 75 | |
|
76 | 76 | add [options] [files ...]:: |
|
77 | 77 | Schedule files to be version controlled and added to the repository. |
|
78 | 78 | |
|
79 | 79 | The files will be added to the repository at the next commit. |
|
80 | 80 | |
|
81 | 81 | If no names are given, add all files in the current directory and |
|
82 | 82 | its subdirectories. |
|
83 | 83 | |
|
84 | 84 | addremove [options] [files ...]:: |
|
85 | 85 | Add all new files and remove all missing files from the repository. |
|
86 | 86 | |
|
87 | 87 | New files are ignored if they match any of the patterns in .hgignore. As |
|
88 | 88 | with add, these changes take effect at the next commit. |
|
89 | 89 | |
|
90 | 90 | annotate [-r <rev> -u -n -c] [files ...]:: |
|
91 | 91 | List changes in files, showing the revision id responsible for each line |
|
92 | 92 | |
|
93 | 93 | This command is useful to discover who did a change or when a change took |
|
94 | 94 | place. |
|
95 | 95 | |
|
96 | 96 | Without the -a option, annotate will avoid processing files it |
|
97 | 97 | detects as binary. With -a, annotate will generate an annotation |
|
98 | 98 | anyway, probably with undesirable results. |
|
99 | 99 | |
|
100 | 100 | options: |
|
101 | 101 | -a, --text treat all files as text |
|
102 | 102 | -I, --include <pat> include names matching the given patterns |
|
103 | 103 | -X, --exclude <pat> exclude names matching the given patterns |
|
104 | 104 | -r, --revision <rev> annotate the specified revision |
|
105 | 105 | -u, --user list the author |
|
106 | 106 | -c, --changeset list the changeset |
|
107 | 107 | -n, --number list the revision number (default) |
|
108 | 108 | |
|
109 | 109 | bundle <file> <other>:: |
|
110 | 110 | (EXPERIMENTAL) |
|
111 | 111 | |
|
112 | 112 | Generate a compressed changegroup file collecting all changesets |
|
113 | 113 | not found in the other repository. |
|
114 | 114 | |
|
115 | 115 | This file can then be transferred using conventional means and |
|
116 | 116 | applied to another repository with the unbundle command. This is |
|
117 | 117 | useful when native push and pull are not available or when |
|
118 | 118 | exporting an entire repository is undesirable. The standard file |
|
119 | 119 | extension is ".hg". |
|
120 | 120 | |
|
121 | 121 | Unlike import/export, this exactly preserves all changeset |
|
122 | 122 | contents including permissions, rename data, and revision history. |
|
123 | 123 | |
|
124 | cat <file> [revision]:: | |
|
125 | Output to stdout the given revision for the specified file. | |
|
124 | cat [options] <file ...>:: | |
|
125 | Print the specified files as they were at the given revision. | |
|
126 | If no revision is given then the tip is used. | |
|
127 | ||
|
128 | Output may be to a file, in which case the name of the file is | |
|
129 | given using a format string. The formatting rules are the same as | |
|
130 | for the export command, with the following additions: | |
|
126 | 131 | |
|
127 | If no revision is given then the tip is used. | |
|
132 | %s basename of file being printed | |
|
133 | %d dirname of file being printed, or '.' if in repo root | |
|
134 | %p root-relative path name of file being printed | |
|
135 | ||
|
136 | options: | |
|
137 | -I, --include <pat> include names matching the given patterns | |
|
138 | -X, --exclude <pat> exclude names matching the given patterns | |
|
139 | -o, --output <filespec> print output to file with formatted name | |
|
140 | -r, --rev <rev> print the given revision | |
|
128 | 141 | |
|
129 | 142 | clone [-U] <source> [dest]:: |
|
130 | 143 | Create a copy of an existing repository in a new directory. |
|
131 | 144 | |
|
132 | 145 | If no destination directory name is specified, it defaults to the |
|
133 | 146 | basename of the source. |
|
134 | 147 | |
|
135 | 148 | The source is added to the new repository's .hg/hgrc file to be used in |
|
136 | 149 | future pulls. |
|
137 | 150 | |
|
138 | 151 | For efficiency, hardlinks are used for cloning whenever the |
|
139 | 152 | source and destination are on the same filesystem. |
|
140 | 153 | |
|
141 | 154 | options: |
|
142 | 155 | -U, --noupdate do not update the new working directory |
|
143 | 156 | -e, --ssh specify ssh command to use |
|
144 | 157 | --remotecmd specify hg command to run on the remote side |
|
145 | 158 | |
|
146 | 159 | commit [options] [files...]:: |
|
147 | 160 | Commit changes to the given files into the repository. |
|
148 | 161 | |
|
149 | 162 | If a list of files is omitted, all changes reported by "hg status" |
|
150 | 163 | from the root of the repository will be commited. |
|
151 | 164 | |
|
152 | 165 | The HGEDITOR or EDITOR environment variables are used to start an |
|
153 | 166 | editor to add a commit comment. |
|
154 | 167 | |
|
155 | 168 | Options: |
|
156 | 169 | |
|
157 | 170 | -A, --addremove run addremove during commit |
|
158 | 171 | -I, --include <pat> include names matching the given patterns |
|
159 | 172 | -X, --exclude <pat> exclude names matching the given patterns |
|
160 | 173 | -m, --message <text> use <text> as commit message |
|
161 | 174 | -l, --logfile <file> read the commit message from <file> |
|
162 | 175 | -d, --date <datecode> record datecode as commit date |
|
163 | 176 | -u, --user <user> record user as commiter |
|
164 | 177 | |
|
165 | 178 | aliases: ci |
|
166 | 179 | |
|
167 | 180 | copy <source ...> <dest>:: |
|
168 | 181 | Mark dest as having copies of source files. If dest is a |
|
169 | 182 | directory, copies are put in that directory. If dest is a file, |
|
170 | 183 | there can only be one source. |
|
171 | 184 | |
|
172 | 185 | By default, this command copies the contents of files as they |
|
173 | 186 | stand in the working directory. If invoked with --after, the |
|
174 | 187 | operation is recorded, but no copying is performed. |
|
175 | 188 | |
|
176 | 189 | This command takes effect in the next commit. |
|
177 | 190 | |
|
178 | 191 | Options: |
|
179 | -A, --after record a copy that has already occurred | |
|
180 | -f, --force forcibly copy over an existing managed file | |
|
181 | -p, --parents append source path to dest | |
|
192 | -A, --after record a copy that has already occurred | |
|
193 | -I, --include <pat> include names matching the given patterns | |
|
194 | -X, --exclude <pat> exclude names matching the given patterns | |
|
195 | -f, --force forcibly copy over an existing managed file | |
|
196 | -p, --parents append source path to dest | |
|
182 | 197 | |
|
183 | 198 | aliases: cp |
|
184 | 199 | |
|
185 | 200 | diff [-a] [-r revision] [-r revision] [files ...]:: |
|
186 | 201 | Show differences between revisions for the specified files. |
|
187 | 202 | |
|
188 | 203 | Differences between files are shown using the unified diff format. |
|
189 | 204 | |
|
190 | 205 | When two revision arguments are given, then changes are shown |
|
191 | 206 | between those revisions. If only one revision is specified then |
|
192 | 207 | that revision is compared to the working directory, and, when no |
|
193 | 208 | revisions are specified, the working directory files are compared |
|
194 | 209 | to its parent. |
|
195 | 210 | |
|
196 | 211 | Without the -a option, diff will avoid generating diffs of files |
|
197 | 212 | it detects as binary. With -a, diff will generate a diff anyway, |
|
198 | 213 | probably with undesirable results. |
|
199 | 214 | |
|
200 | 215 | options: |
|
201 | 216 | -a, --text treat all files as text |
|
202 | 217 | -I, --include <pat> include names matching the given patterns |
|
203 | 218 | -X, --exclude <pat> exclude names matching the given patterns |
|
204 | 219 | |
|
205 | 220 | export [-o filespec] [revision] ...:: |
|
206 | 221 | Print the changeset header and diffs for one or more revisions. |
|
207 | 222 | |
|
208 | 223 | The information shown in the changeset header is: author, |
|
209 | 224 | changeset hash, parent and commit comment. |
|
210 | 225 | |
|
211 | 226 | Output may be to a file, in which case the name of the file is |
|
212 | 227 | given using a format string. The formatting rules are as follows: |
|
213 | 228 | |
|
214 | 229 | %% literal "%" character |
|
215 | 230 | %H changeset hash (40 bytes of hexadecimal) |
|
216 | 231 | %N number of patches being generated |
|
217 | 232 | %R changeset revision number |
|
218 | 233 | %b basename of the exporting repository |
|
219 | 234 | %h short-form changeset hash (12 bytes of hexadecimal) |
|
220 | 235 | %n zero-padded sequence number, starting at 1 |
|
221 | 236 | %r zero-padded changeset revision number |
|
222 | 237 | |
|
223 | 238 | Without the -a option, export will avoid generating diffs of files |
|
224 | 239 | it detects as binary. With -a, export will generate a diff anyway, |
|
225 | 240 | probably with undesirable results. |
|
226 | 241 | |
|
227 | 242 | options: |
|
228 | 243 | -a, --text treat all files as text |
|
229 |
-o, --output <filespec> print output to file with formatted name |
|
|
244 | -o, --output <filespec> print output to file with formatted name | |
|
230 | 245 | |
|
231 | 246 | forget [options] [files]:: |
|
232 | 247 | Undo an 'hg add' scheduled for the next commit. |
|
233 | 248 | |
|
234 | 249 | options: |
|
235 | 250 | -I, --include <pat> include names matching the given patterns |
|
236 | 251 | -X, --exclude <pat> exclude names matching the given patterns |
|
237 | 252 | |
|
238 | 253 | grep [options] pattern [files]:: |
|
239 | 254 | Search revisions of files for a regular expression. |
|
240 | 255 | |
|
241 | 256 | This command behaves differently than Unix grep. It only accepts |
|
242 | 257 | Python/Perl regexps. It searches repository history, not the |
|
243 | 258 | working directory. It always prints the revision number in which |
|
244 | 259 | a match appears. |
|
245 | 260 | |
|
246 | 261 | By default, grep only prints output for the first revision of a |
|
247 | 262 | file in which it finds a match. To get it to print every revision |
|
248 | 263 | that contains a change in match status ("-" for a match that |
|
249 | 264 | becomes a non-match, or "+" for a non-match that becomes a match), |
|
250 | 265 | use the --all flag. |
|
251 | 266 | |
|
252 | 267 | options: |
|
253 | 268 | -0, --print0 end fields with NUL |
|
254 | 269 | -I, --include <pat> include names matching the given patterns |
|
255 | 270 | -X, --exclude <pat> exclude names matching the given patterns |
|
256 | 271 | --all print all revisions that match |
|
257 | 272 | -i, --ignore-case ignore case when matching |
|
258 | 273 | -l, --files-with-matches print only file names and revs that match |
|
259 | 274 | -n, --line-number print matching line numbers |
|
260 | 275 | -r <rev>, --rev <rev> search in given revision range |
|
261 | 276 | -u, --user print user who committed change |
|
262 | 277 | |
|
263 | 278 | heads:: |
|
264 | 279 | Show all repository head changesets. |
|
265 | 280 | |
|
266 | 281 | Repository "heads" are changesets that don't have children |
|
267 | 282 | changesets. They are where development generally takes place and |
|
268 | 283 | are the usual targets for update and merge operations. |
|
269 | 284 | |
|
270 | 285 | identify:: |
|
271 | 286 | Print a short summary of the current state of the repo. |
|
272 | 287 | |
|
273 | 288 | This summary identifies the repository state using one or two parent |
|
274 | 289 | hash identifiers, followed by a "+" if there are uncommitted changes |
|
275 | 290 | in the working directory, followed by a list of tags for this revision. |
|
276 | 291 | |
|
277 | 292 | aliases: id |
|
278 | 293 | |
|
279 | 294 | import [-p <n> -b <base> -f] <patches>:: |
|
280 | 295 | Import a list of patches and commit them individually. |
|
281 | 296 | |
|
282 | 297 | If there are outstanding changes in the working directory, import |
|
283 | 298 | will abort unless given the -f flag. |
|
284 | 299 | |
|
285 | 300 | If a patch looks like a mail message (its first line starts with |
|
286 | 301 | "From " or looks like an RFC822 header), it will not be applied |
|
287 | 302 | unless the -f option is used. The importer neither parses nor |
|
288 | 303 | discards mail headers, so use -f only to override the "mailness" |
|
289 | 304 | safety check, not to import a real mail message. |
|
290 | 305 | |
|
291 | 306 | options: |
|
292 | 307 | -p, --strip <n> directory strip option for patch. This has the same |
|
293 | 308 | meaning as the corresponding patch option |
|
294 | 309 | -b <path> base directory to read patches from |
|
295 | 310 | -f, --force skip check for outstanding uncommitted changes |
|
296 | 311 | |
|
297 | 312 | aliases: patch |
|
298 | 313 | |
|
299 | 314 | incoming [-p] [source]:: |
|
300 | 315 | Show new changesets found in the specified repo or the default |
|
301 | 316 | pull repo. These are the changesets that would be pulled if a pull |
|
302 | 317 | was requested. |
|
303 | 318 | |
|
304 | 319 | Currently only local repositories are supported. |
|
305 | 320 | |
|
306 | 321 | options: |
|
307 | 322 | -p, --patch show patch |
|
308 | 323 | |
|
309 | 324 | aliases: in |
|
310 | 325 | |
|
311 | 326 | init [dest]:: |
|
312 | 327 | Initialize a new repository in the given directory. If the given |
|
313 | 328 | directory does not exist, it is created. |
|
314 | 329 | |
|
315 | 330 | If no directory is given, the current directory is used. |
|
316 | 331 | |
|
317 | 332 | locate [options] [files]:: |
|
318 | 333 | Print all files under Mercurial control whose names match the |
|
319 | 334 | given patterns. |
|
320 | 335 | |
|
321 | 336 | This command searches the current directory and its |
|
322 | 337 | subdirectories. To search an entire repository, move to the root |
|
323 | 338 | of the repository. |
|
324 | 339 | |
|
325 | 340 | If no patterns are given to match, this command prints all file |
|
326 | 341 | names. |
|
327 | 342 | |
|
328 | 343 | If you want to feed the output of this command into the "xargs" |
|
329 | 344 | command, use the "-0" option to both this command and "xargs". |
|
330 | 345 | This will avoid the problem of "xargs" treating single filenames |
|
331 | 346 | that contain white space as multiple file names. |
|
332 | 347 | |
|
333 | 348 | options: |
|
334 | 349 | |
|
335 | 350 | -0, --print0 end filenames with NUL, for use with xargs |
|
336 | 351 | -f, --fullpath print complete paths from the filesystem root |
|
337 | 352 | -I, --include <pat> include names matching the given patterns |
|
338 | 353 | -r, --rev <rev> search the repository as it stood at rev |
|
339 | 354 | -X, --exclude <pat> exclude names matching the given patterns |
|
340 | 355 | |
|
341 | 356 | log [-r revision ...] [-p] [files]:: |
|
342 | 357 | Print the revision history of the specified files or the entire project. |
|
343 | 358 | |
|
344 | 359 | By default this command outputs: changeset id and hash, tags, |
|
345 | 360 | parents, user, date and time, and a summary for each commit. The |
|
346 | 361 | -v switch adds some more detail, such as changed files, manifest |
|
347 | 362 | hashes or message signatures. |
|
348 | 363 | |
|
349 | 364 | options: |
|
350 | 365 | -I, --include <pat> include names matching the given patterns |
|
351 | 366 | -X, --exclude <pat> exclude names matching the given patterns |
|
352 | 367 | -r, --rev <A> show the specified revision or range |
|
353 | 368 | -p, --patch show patch |
|
354 | 369 | |
|
355 | 370 | aliases: history |
|
356 | 371 | |
|
357 | 372 | manifest [revision]:: |
|
358 | 373 | Print a list of version controlled files for the given revision. |
|
359 | 374 | |
|
360 | 375 | The manifest is the list of files being version controlled. If no revision |
|
361 | 376 | is given then the tip is used. |
|
362 | 377 | |
|
363 | 378 | outgoing [-p] [dest]:: |
|
364 | 379 | Show changesets not found in the specified destination repo or the |
|
365 | 380 | default push repo. These are the changesets that would be pushed |
|
366 | 381 | if a push was requested. |
|
367 | 382 | |
|
368 | 383 | options: |
|
369 | 384 | -p, --patch show patch |
|
370 | 385 | |
|
371 | 386 | aliases: out |
|
372 | 387 | |
|
373 | 388 | parents:: |
|
374 | 389 | Print the working directory's parent revisions. |
|
375 | 390 | |
|
376 | 391 | paths [NAME]:: |
|
377 | 392 | Show definition of symbolic path name NAME. If no name is given, show |
|
378 | 393 | definition of available names. |
|
379 | 394 | |
|
380 | 395 | Path names are defined in the [paths] section of /etc/mercurial/hgrc |
|
381 | 396 | and $HOME/.hgrc. If run inside a repository, .hg/hgrc is used, too. |
|
382 | 397 | |
|
383 | 398 | pull <repository path>:: |
|
384 | 399 | Pull changes from a remote repository to a local one. |
|
385 | 400 | |
|
386 | 401 | This finds all changes from the repository at the specified path |
|
387 | 402 | or URL and adds them to the local repository. By default, this |
|
388 | 403 | does not update the copy of the project in the working directory. |
|
389 | 404 | |
|
390 | 405 | Valid URLs are of the form: |
|
391 | 406 | |
|
392 | 407 | local/filesystem/path |
|
393 | 408 | http://[user@]host[:port][/path] |
|
394 | 409 | https://[user@]host[:port][/path] |
|
395 | 410 | ssh://[user@]host[:port][/path] |
|
396 | 411 | |
|
397 | 412 | SSH requires an accessible shell account on the destination |
|
398 | 413 | machine and a copy of hg in the remote path. |
|
399 | 414 | |
|
400 | 415 | options: |
|
401 | 416 | -u, --update update the working directory to tip after pull |
|
402 | 417 | -e, --ssh specify ssh command to use |
|
403 | 418 | --remotecmd specify hg command to run on the remote side |
|
404 | 419 | |
|
405 | 420 | push <destination>:: |
|
406 | 421 | Push changes from the local repository to the given destination. |
|
407 | 422 | |
|
408 | 423 | This is the symmetrical operation for pull. It helps to move |
|
409 | 424 | changes from the current repository to a different one. If the |
|
410 | 425 | destination is local this is identical to a pull in that directory |
|
411 | 426 | from the current one. |
|
412 | 427 | |
|
413 | 428 | By default, push will refuse to run if it detects the result would |
|
414 | 429 | increase the number of remote heads. This generally indicates the |
|
415 | 430 | the client has forgotten to sync and merge before pushing. |
|
416 | 431 | |
|
417 | 432 | Valid URLs are of the form: |
|
418 | 433 | |
|
419 | 434 | local/filesystem/path |
|
420 | 435 | ssh://[user@]host[:port][/path] |
|
421 | 436 | |
|
422 | 437 | SSH requires an accessible shell account on the destination |
|
423 | 438 | machine and a copy of hg in the remote path. |
|
424 | 439 | |
|
425 | 440 | options: |
|
426 | 441 | |
|
427 | 442 | -f, --force force update |
|
428 | 443 | -e, --ssh specify ssh command to use |
|
429 | 444 | --remotecmd specify hg command to run on the remote side |
|
430 | 445 | |
|
431 | 446 | rawcommit [-p -d -u -F -m -l]:: |
|
432 | 447 | Lowlevel commit, for use in helper scripts. |
|
433 | 448 | |
|
434 | 449 | This command is not intended to be used by normal users, as it is |
|
435 | 450 | primarily useful for importing from other SCMs. |
|
436 | 451 | |
|
437 | 452 | recover:: |
|
438 | 453 | Recover from an interrupted commit or pull. |
|
439 | 454 | |
|
440 | 455 | This command tries to fix the repository status after an interrupted |
|
441 | 456 | operation. It should only be necessary when Mercurial suggests it. |
|
442 | 457 | |
|
443 | 458 | remove [options] [files ...]:: |
|
444 | 459 | Schedule the indicated files for removal from the repository. |
|
445 | 460 | |
|
446 | 461 | This command schedules the files to be removed at the next commit. |
|
447 | 462 | This only removes files from the current branch, not from the |
|
448 | 463 | entire project history. If the files still exist in the working |
|
449 | 464 | directory, they will be deleted from it. |
|
450 | 465 | |
|
451 | 466 | aliases: rm |
|
452 | 467 | |
|
453 | 468 | rename <source ...> <dest>:: |
|
454 | 469 | Mark dest as copies of sources; mark sources for deletion. If |
|
455 | 470 | dest is a directory, copies are put in that directory. If dest is |
|
456 | 471 | a file, there can only be one source. |
|
457 | 472 | |
|
458 | 473 | By default, this command copies the contents of files as they |
|
459 | 474 | stand in the working directory. If invoked with --after, the |
|
460 | 475 | operation is recorded, but no copying is performed. |
|
461 | 476 | |
|
462 | 477 | This command takes effect in the next commit. |
|
463 | 478 | |
|
464 | 479 | Options: |
|
465 | 480 | -A, --after record a rename that has already occurred |
|
466 | 481 | -f, --force forcibly copy over an existing managed file |
|
467 | 482 | -p, --parents append source path to dest |
|
468 | 483 | |
|
469 | 484 | aliases: mv |
|
470 | 485 | |
|
471 | 486 | revert [names ...]:: |
|
472 | 487 | Revert any uncommitted modifications made to the named files or |
|
473 | 488 | directories. This restores the contents of the affected files to |
|
474 | 489 | an unmodified state. |
|
475 | 490 | |
|
476 | 491 | If a file has been deleted, it is recreated. If the executable |
|
477 | 492 | mode of a file was changed, it is reset. |
|
478 | 493 | |
|
479 | 494 | If a directory is given, all files in that directory and its |
|
480 | 495 | subdirectories are reverted. |
|
481 | 496 | |
|
482 | 497 | If no arguments are given, all files in the current directory and |
|
483 | 498 | its subdirectories are reverted. |
|
484 | 499 | |
|
485 | 500 | options: |
|
486 | 501 | -r, --rev <rev> revision to revert to |
|
487 | 502 | -n, --nonrecursive do not recurse into subdirectories |
|
488 | 503 | |
|
489 | 504 | root:: |
|
490 | 505 | Print the root directory of the current repository. |
|
491 | 506 | |
|
492 | 507 | serve [options]:: |
|
493 | 508 | Start a local HTTP repository browser and pull server. |
|
494 | 509 | |
|
495 | 510 | By default, the server logs accesses to stdout and errors to |
|
496 | 511 | stderr. Use the "-A" and "-E" options to log to files. |
|
497 | 512 | |
|
498 | 513 | options: |
|
499 | 514 | -A, --accesslog <file> name of access log file to write to |
|
500 | 515 | -E, --errorlog <file> name of error log file to write to |
|
501 | 516 | -a, --address <addr> address to use |
|
502 | 517 | -p, --port <n> port to use (default: 8000) |
|
503 | 518 | -n, --name <name> name to show in web pages (default: working dir) |
|
504 | 519 | -t, --templatedir <path> web templates to use |
|
505 | 520 | -6, --ipv6 use IPv6 in addition to IPv4 |
|
506 | 521 | |
|
507 | 522 | status [options] [files]:: |
|
508 | 523 | Show changed files in the working directory. If no names are |
|
509 | 524 | given, all files are shown. Otherwise, only files matching the |
|
510 | 525 | given names are shown. |
|
511 | 526 | |
|
512 | 527 | The codes used to show the status of files are: |
|
513 | 528 | |
|
514 | 529 | M = changed |
|
515 | 530 | A = added |
|
516 | 531 | R = removed |
|
517 | 532 | ? = not tracked |
|
518 | 533 | |
|
519 | 534 | options: |
|
520 | 535 | |
|
521 | 536 | -m, --modified show only modified files |
|
522 | 537 | -a, --added show only added files |
|
523 | 538 | -r, --removed show only removed files |
|
524 | 539 | -u, --unknown show only unknown (not tracked) files |
|
525 | 540 | -n, --no-status hide status prefix |
|
526 | 541 | -0, --print0 end filenames with NUL, for use with xargs |
|
527 | 542 | -I, --include <pat> include names matching the given patterns |
|
528 | 543 | -X, --exclude <pat> exclude names matching the given patterns |
|
529 | 544 | |
|
530 | 545 | tag [-l -m <text> -d <datecode> -u <user>] <name> [revision]:: |
|
531 | 546 | Name a particular revision using <name>. |
|
532 | 547 | |
|
533 | 548 | Tags are used to name particular revisions of the repository and are |
|
534 | 549 | very useful to compare different revision, to go back to significant |
|
535 | 550 | earlier versions or to mark branch points as releases, etc. |
|
536 | 551 | |
|
537 | 552 | If no revision is given, the tip is used. |
|
538 | 553 | |
|
539 | 554 | To facilitate version control, distribution, and merging of tags, |
|
540 | 555 | they are stored as a file named ".hgtags" which is managed |
|
541 | 556 | similarly to other project files and can be hand-edited if |
|
542 | 557 | necessary. |
|
543 | 558 | |
|
544 | 559 | options: |
|
545 | 560 | -l, --local make the tag local |
|
546 | 561 | -m, --message <text> message for tag commit log entry |
|
547 | 562 | -d, --date <datecode> datecode for commit |
|
548 | 563 | -u, --user <user> user for commit |
|
549 | 564 | |
|
550 | 565 | Note: Local tags are not version-controlled or distributed and are |
|
551 | 566 | stored in the .hg/localtags file. If there exists a local tag and |
|
552 | 567 | a public tag with the same name, local tag is used. |
|
553 | 568 | |
|
554 | 569 | tags:: |
|
555 | 570 | List the repository tags. |
|
556 | 571 | |
|
557 | 572 | This lists both regular and local tags. |
|
558 | 573 | |
|
559 | 574 | tip:: |
|
560 | 575 | Show the tip revision. |
|
561 | 576 | |
|
562 | 577 | unbundle <file>:: |
|
563 | 578 | (EXPERIMENTAL) |
|
564 | 579 | |
|
565 | 580 | Apply a compressed changegroup file generated by the bundle |
|
566 | 581 | command. |
|
567 | 582 | |
|
568 | 583 | undo:: |
|
569 | 584 | Undo the last commit or pull transaction. |
|
570 | 585 | |
|
571 | 586 | Roll back the last pull or commit transaction on the |
|
572 | 587 | repository, restoring the project to its earlier state. |
|
573 | 588 | |
|
574 | 589 | This command should be used with care. There is only one level of |
|
575 | 590 | undo and there is no redo. |
|
576 | 591 | |
|
577 | 592 | This command is not intended for use on public repositories. Once |
|
578 | 593 | a change is visible for pull by other users, undoing it locally is |
|
579 | 594 | ineffective. |
|
580 | 595 | |
|
581 | 596 | update [-m -C] [revision]:: |
|
582 | 597 | Update the working directory to the specified revision. |
|
583 | 598 | |
|
584 | 599 | By default, update will refuse to run if doing so would require |
|
585 | 600 | merging or discarding local changes. |
|
586 | 601 | |
|
587 | 602 | With the -m option, a merge will be performed. |
|
588 | 603 | |
|
589 | 604 | With the -C option, local changes will be lost. |
|
590 | 605 | |
|
591 | 606 | options: |
|
592 | 607 | -m, --merge allow merging of branches |
|
593 | 608 | -C, --clean overwrite locally modified files |
|
594 | 609 | |
|
595 | 610 | aliases: up checkout co |
|
596 | 611 | |
|
597 | 612 | verify:: |
|
598 | 613 | Verify the integrity of the current repository. |
|
599 | 614 | |
|
600 | 615 | This will perform an extensive check of the repository's |
|
601 | 616 | integrity, validating the hashes and checksums of each entry in |
|
602 | 617 | the changelog, manifest, and tracked files, as well as the |
|
603 | 618 | integrity of their crosslinks and indices. |
|
604 | 619 | |
|
605 | 620 | FILE NAME PATTERNS |
|
606 | 621 | ------------------ |
|
607 | 622 | |
|
608 | 623 | Mercurial accepts several notations for identifying one or more |
|
609 | 624 | file at a time. |
|
610 | 625 | |
|
611 | 626 | By default, Mercurial treats file names as shell-style extended |
|
612 | 627 | glob patterns. |
|
613 | 628 | |
|
614 | 629 | Alternate pattern notations must be specified explicitly. |
|
615 | 630 | |
|
616 | 631 | To use a plain path name without any pattern matching, start a |
|
617 | 632 | name with "path:". These path names must match completely, from |
|
618 | 633 | the root of the current repository. |
|
619 | 634 | |
|
620 | 635 | To use an extended glob, start a name with "glob:". Globs are |
|
621 | 636 | rooted at the current directory; a glob such as "*.c" will match |
|
622 | 637 | files ending in ".c" in the current directory only. |
|
623 | 638 | |
|
624 | 639 | The supported glob syntax extensions are "**" to match any string |
|
625 | 640 | across path separators, and "{a,b}" to mean "a or b". |
|
626 | 641 | |
|
627 | 642 | To use a Perl/Python regular expression, start a name with "re:". |
|
628 | 643 | Regexp pattern matching is anchored at the root of the repository. |
|
629 | 644 | |
|
630 | 645 | Plain examples: |
|
631 | 646 | |
|
632 | 647 | path:foo/bar a name bar in a directory named foo in the root of |
|
633 | 648 | the repository |
|
634 | 649 | path:path:name a file or directory named "path:name" |
|
635 | 650 | |
|
636 | 651 | Glob examples: |
|
637 | 652 | |
|
638 | 653 | glob:*.c any name ending in ".c" in the current directory |
|
639 | 654 | *.c any name ending in ".c" in the current directory |
|
640 | 655 | **.c any name ending in ".c" in the current directory, or |
|
641 | 656 | any subdirectory |
|
642 | 657 | foo/*.c any name ending in ".c" in the directory foo |
|
643 | 658 | foo/**.c any name ending in ".c" in the directory foo, or any |
|
644 | 659 | subdirectory |
|
645 | 660 | |
|
646 | 661 | Regexp examples: |
|
647 | 662 | |
|
648 | 663 | re:.*\.c$ any name ending in ".c", anywhere in the repository |
|
649 | 664 | |
|
650 | 665 | |
|
651 | 666 | SPECIFYING SINGLE REVISIONS |
|
652 | 667 | --------------------------- |
|
653 | 668 | |
|
654 | 669 | Mercurial accepts several notations for identifying individual |
|
655 | 670 | revisions. |
|
656 | 671 | |
|
657 | 672 | A plain integer is treated as a revision number. Negative |
|
658 | 673 | integers are treated as offsets from the tip, with -1 denoting the |
|
659 | 674 | tip. |
|
660 | 675 | |
|
661 | 676 | A 40-digit hexadecimal string is treated as a unique revision |
|
662 | 677 | identifier. |
|
663 | 678 | |
|
664 | 679 | A hexadecimal string less than 40 characters long is treated as a |
|
665 | 680 | unique revision identifier, and referred to as a short-form |
|
666 | 681 | identifier. A short-form identifier is only valid if it is the |
|
667 | 682 | prefix of one full-length identifier. |
|
668 | 683 | |
|
669 | 684 | Any other string is treated as a tag name, which is a symbolic |
|
670 | 685 | name associated with a revision identifier. Tag names may not |
|
671 | 686 | contain the ":" character. |
|
672 | 687 | |
|
673 | 688 | The reserved name "tip" is a special tag that always identifies |
|
674 | 689 | the most recent revision. |
|
675 | 690 | |
|
676 | 691 | SPECIFYING MULTIPLE REVISIONS |
|
677 | 692 | ----------------------------- |
|
678 | 693 | |
|
679 | 694 | When Mercurial accepts more than one revision, they may be |
|
680 | 695 | specified individually, or provided as a continuous range, |
|
681 | 696 | separated by the ":" character. |
|
682 | 697 | |
|
683 | 698 | The syntax of range notation is [BEGIN]:[END], where BEGIN and END |
|
684 | 699 | are revision identifiers. Both BEGIN and END are optional. If |
|
685 | 700 | BEGIN is not specified, it defaults to revision number 0. If END |
|
686 | 701 | is not specified, it defaults to the tip. The range ":" thus |
|
687 | 702 | means "all revisions". |
|
688 | 703 | |
|
689 | 704 | If BEGIN is greater than END, revisions are treated in reverse |
|
690 | 705 | order. |
|
691 | 706 | |
|
692 | 707 | A range acts as a closed interval. This means that a range of 3:5 |
|
693 | 708 | gives 3, 4 and 5. Similarly, a range of 4:2 gives 4, 3, and 2. |
|
694 | 709 | |
|
695 | 710 | ENVIRONMENT VARIABLES |
|
696 | 711 | --------------------- |
|
697 | 712 | |
|
698 | 713 | HGEDITOR:: |
|
699 | 714 | This is the name of the editor to use when committing. Defaults to the |
|
700 | 715 | value of EDITOR. |
|
701 | 716 | |
|
702 | 717 | (deprecated, use .hgrc) |
|
703 | 718 | |
|
704 | 719 | HGMERGE:: |
|
705 | 720 | An executable to use for resolving merge conflicts. The program |
|
706 | 721 | will be executed with three arguments: local file, remote file, |
|
707 | 722 | ancestor file. |
|
708 | 723 | |
|
709 | 724 | The default program is "hgmerge", which is a shell script provided |
|
710 | 725 | by Mercurial with some sensible defaults. |
|
711 | 726 | |
|
712 | 727 | (deprecated, use .hgrc) |
|
713 | 728 | |
|
714 | 729 | HGUSER:: |
|
715 | 730 | This is the string used for the author of a commit. |
|
716 | 731 | |
|
717 | 732 | (deprecated, use .hgrc) |
|
718 | 733 | |
|
719 | 734 | EMAIL:: |
|
720 | 735 | If HGUSER is not set, this will be used as the author for a commit. |
|
721 | 736 | |
|
722 | 737 | LOGNAME:: |
|
723 | 738 | If neither HGUSER nor EMAIL is set, LOGNAME will be used (with |
|
724 | 739 | '@hostname' appended) as the author value for a commit. |
|
725 | 740 | |
|
726 | 741 | EDITOR:: |
|
727 | 742 | This is the name of the editor used in the hgmerge script. It will be |
|
728 | 743 | used for commit messages if HGEDITOR isn't set. Defaults to 'vi'. |
|
729 | 744 | |
|
730 | 745 | PYTHONPATH:: |
|
731 | 746 | This is used by Python to find imported modules and may need to be set |
|
732 | 747 | appropriately if Mercurial is not installed system-wide. |
|
733 | 748 | |
|
734 | 749 | FILES |
|
735 | 750 | ----- |
|
736 | 751 | .hgignore:: |
|
737 | 752 | This file contains regular expressions (one per line) that describe file |
|
738 | 753 | names that should be ignored by hg. |
|
739 | 754 | |
|
740 | 755 | .hgtags:: |
|
741 | 756 | This file contains changeset hash values and text tag names (one of each |
|
742 | 757 | separated by spaces) that correspond to tagged versions of the repository |
|
743 | 758 | contents. |
|
744 | 759 | |
|
745 | 760 | /etc/mercurial/hgrc, $HOME/.hgrc, .hg/hgrc:: |
|
746 | 761 | This file contains defaults and configuration. Values in .hg/hgrc |
|
747 | 762 | override those in $HOME/.hgrc, and these override settings made in the |
|
748 | 763 | global /etc/mercurial/hgrc configuration. See hgrc(5) for details of |
|
749 | 764 | the contents and format of these files. |
|
750 | 765 | |
|
751 | 766 | BUGS |
|
752 | 767 | ---- |
|
753 | 768 | Probably lots, please post them to the mailing list (See Resources below) |
|
754 | 769 | when you find them. |
|
755 | 770 | |
|
756 | 771 | SEE ALSO |
|
757 | 772 | -------- |
|
758 | 773 | hgrc(5) |
|
759 | 774 | |
|
760 | 775 | AUTHOR |
|
761 | 776 | ------ |
|
762 | 777 | Written by Matt Mackall <mpm@selenic.com> |
|
763 | 778 | |
|
764 | 779 | RESOURCES |
|
765 | 780 | --------- |
|
766 | 781 | http://selenic.com/mercurial[Main Web Site] |
|
767 | 782 | |
|
768 | 783 | http://www.serpentine.com/mercurial[Wiki site] |
|
769 | 784 | |
|
770 | 785 | http://selenic.com/hg[Source code repository] |
|
771 | 786 | |
|
772 | 787 | http://selenic.com/mailman/listinfo/mercurial[Mailing list] |
|
773 | 788 | |
|
774 | 789 | COPYING |
|
775 | 790 | ------- |
|
776 | 791 | Copyright (C) 2005 Matt Mackall. |
|
777 | 792 | Free use of this software is granted under the terms of the GNU General |
|
778 | 793 | Public License (GPL). |
@@ -1,2193 +1,2202 b'' | |||
|
1 | 1 | # commands.py - command processing for mercurial |
|
2 | 2 | # |
|
3 | 3 | # Copyright 2005 Matt Mackall <mpm@selenic.com> |
|
4 | 4 | # |
|
5 | 5 | # This software may be used and distributed according to the terms |
|
6 | 6 | # of the GNU General Public License, incorporated herein by reference. |
|
7 | 7 | |
|
8 | 8 | from demandload import demandload |
|
9 | 9 | from node import * |
|
10 | 10 | demandload(globals(), "os re sys signal shutil imp urllib pdb") |
|
11 | 11 | demandload(globals(), "fancyopts ui hg util lock revlog") |
|
12 | 12 | demandload(globals(), "fnmatch hgweb mdiff random signal time traceback") |
|
13 | 13 | demandload(globals(), "errno socket version struct atexit sets bz2") |
|
14 | 14 | |
|
15 | 15 | class UnknownCommand(Exception): |
|
16 | 16 | """Exception raised if command is not in the command table.""" |
|
17 | 17 | |
|
18 | 18 | def filterfiles(filters, files): |
|
19 | 19 | l = [x for x in files if x in filters] |
|
20 | 20 | |
|
21 | 21 | for t in filters: |
|
22 | 22 | if t and t[-1] != "/": |
|
23 | 23 | t += "/" |
|
24 | 24 | l += [x for x in files if x.startswith(t)] |
|
25 | 25 | return l |
|
26 | 26 | |
|
27 | 27 | def relpath(repo, args): |
|
28 | 28 | cwd = repo.getcwd() |
|
29 | 29 | if cwd: |
|
30 | 30 | return [util.normpath(os.path.join(cwd, x)) for x in args] |
|
31 | 31 | return args |
|
32 | 32 | |
|
33 | 33 | def matchpats(repo, cwd, pats=[], opts={}, head=''): |
|
34 | 34 | return util.matcher(repo.root, cwd, pats or ['.'], opts.get('include'), |
|
35 | 35 | opts.get('exclude'), head) |
|
36 | 36 | |
|
37 | 37 | def makewalk(repo, pats, opts, head=''): |
|
38 | 38 | cwd = repo.getcwd() |
|
39 | 39 | files, matchfn, anypats = matchpats(repo, cwd, pats, opts, head) |
|
40 | 40 | exact = dict(zip(files, files)) |
|
41 | 41 | def walk(): |
|
42 | 42 | for src, fn in repo.walk(files=files, match=matchfn): |
|
43 | 43 | yield src, fn, util.pathto(cwd, fn), fn in exact |
|
44 | 44 | return files, matchfn, walk() |
|
45 | 45 | |
|
46 | 46 | def walk(repo, pats, opts, head=''): |
|
47 | 47 | files, matchfn, results = makewalk(repo, pats, opts, head) |
|
48 | 48 | for r in results: |
|
49 | 49 | yield r |
|
50 | 50 | |
|
51 | 51 | def walkchangerevs(ui, repo, cwd, pats, opts): |
|
52 | 52 | '''Iterate over files and the revs they changed in. |
|
53 | 53 | |
|
54 | 54 | Callers most commonly need to iterate backwards over the history |
|
55 | 55 | it is interested in. Doing so has awful (quadratic-looking) |
|
56 | 56 | performance, so we use iterators in a "windowed" way. |
|
57 | 57 | |
|
58 | 58 | We walk a window of revisions in the desired order. Within the |
|
59 | 59 | window, we first walk forwards to gather data, then in the desired |
|
60 | 60 | order (usually backwards) to display it. |
|
61 | 61 | |
|
62 | 62 | This function returns an (iterator, getchange) pair. The |
|
63 | 63 | getchange function returns the changelog entry for a numeric |
|
64 | 64 | revision. The iterator yields 3-tuples. They will be of one of |
|
65 | 65 | the following forms: |
|
66 | 66 | |
|
67 | 67 | "window", incrementing, lastrev: stepping through a window, |
|
68 | 68 | positive if walking forwards through revs, last rev in the |
|
69 | 69 | sequence iterated over - use to reset state for the current window |
|
70 | 70 | |
|
71 | 71 | "add", rev, fns: out-of-order traversal of the given file names |
|
72 | 72 | fns, which changed during revision rev - use to gather data for |
|
73 | 73 | possible display |
|
74 | 74 | |
|
75 | 75 | "iter", rev, None: in-order traversal of the revs earlier iterated |
|
76 | 76 | over with "add" - use to display data''' |
|
77 | 77 | cwd = repo.getcwd() |
|
78 | 78 | if not pats and cwd: |
|
79 | 79 | opts['include'] = [os.path.join(cwd, i) for i in opts['include']] |
|
80 | 80 | opts['exclude'] = [os.path.join(cwd, x) for x in opts['exclude']] |
|
81 | 81 | files, matchfn, anypats = matchpats(repo, (pats and cwd) or '', |
|
82 | 82 | pats, opts) |
|
83 | 83 | revs = map(int, revrange(ui, repo, opts['rev'] or ['tip:0'])) |
|
84 | 84 | wanted = {} |
|
85 | 85 | slowpath = anypats |
|
86 | 86 | window = 300 |
|
87 | 87 | fncache = {} |
|
88 | 88 | |
|
89 | 89 | chcache = {} |
|
90 | 90 | def getchange(rev): |
|
91 | 91 | ch = chcache.get(rev) |
|
92 | 92 | if ch is None: |
|
93 | 93 | chcache[rev] = ch = repo.changelog.read(repo.lookup(str(rev))) |
|
94 | 94 | return ch |
|
95 | 95 | |
|
96 | 96 | if not slowpath and not files: |
|
97 | 97 | # No files, no patterns. Display all revs. |
|
98 | 98 | wanted = dict(zip(revs, revs)) |
|
99 | 99 | if not slowpath: |
|
100 | 100 | # Only files, no patterns. Check the history of each file. |
|
101 | 101 | def filerevgen(filelog): |
|
102 | 102 | for i in xrange(filelog.count() - 1, -1, -window): |
|
103 | 103 | revs = [] |
|
104 | 104 | for j in xrange(max(0, i - window), i + 1): |
|
105 | 105 | revs.append(filelog.linkrev(filelog.node(j))) |
|
106 | 106 | revs.reverse() |
|
107 | 107 | for rev in revs: |
|
108 | 108 | yield rev |
|
109 | 109 | |
|
110 | 110 | minrev, maxrev = min(revs), max(revs) |
|
111 | 111 | for file in files: |
|
112 | 112 | filelog = repo.file(file) |
|
113 | 113 | # A zero count may be a directory or deleted file, so |
|
114 | 114 | # try to find matching entries on the slow path. |
|
115 | 115 | if filelog.count() == 0: |
|
116 | 116 | slowpath = True |
|
117 | 117 | break |
|
118 | 118 | for rev in filerevgen(filelog): |
|
119 | 119 | if rev <= maxrev: |
|
120 | 120 | if rev < minrev: |
|
121 | 121 | break |
|
122 | 122 | fncache.setdefault(rev, []) |
|
123 | 123 | fncache[rev].append(file) |
|
124 | 124 | wanted[rev] = 1 |
|
125 | 125 | if slowpath: |
|
126 | 126 | # The slow path checks files modified in every changeset. |
|
127 | 127 | def changerevgen(): |
|
128 | 128 | for i in xrange(repo.changelog.count() - 1, -1, -window): |
|
129 | 129 | for j in xrange(max(0, i - window), i + 1): |
|
130 | 130 | yield j, getchange(j)[3] |
|
131 | 131 | |
|
132 | 132 | for rev, changefiles in changerevgen(): |
|
133 | 133 | matches = filter(matchfn, changefiles) |
|
134 | 134 | if matches: |
|
135 | 135 | fncache[rev] = matches |
|
136 | 136 | wanted[rev] = 1 |
|
137 | 137 | |
|
138 | 138 | def iterate(): |
|
139 | 139 | for i in xrange(0, len(revs), window): |
|
140 | 140 | yield 'window', revs[0] < revs[-1], revs[-1] |
|
141 | 141 | nrevs = [rev for rev in revs[i:min(i+window, len(revs))] |
|
142 | 142 | if rev in wanted] |
|
143 | 143 | srevs = list(nrevs) |
|
144 | 144 | srevs.sort() |
|
145 | 145 | for rev in srevs: |
|
146 | 146 | fns = fncache.get(rev) or filter(matchfn, getchange(rev)[3]) |
|
147 | 147 | yield 'add', rev, fns |
|
148 | 148 | for rev in nrevs: |
|
149 | 149 | yield 'iter', rev, None |
|
150 | 150 | return iterate(), getchange |
|
151 | 151 | |
|
152 | 152 | revrangesep = ':' |
|
153 | 153 | |
|
154 | 154 | def revrange(ui, repo, revs, revlog=None): |
|
155 | 155 | """Yield revision as strings from a list of revision specifications.""" |
|
156 | 156 | if revlog is None: |
|
157 | 157 | revlog = repo.changelog |
|
158 | 158 | revcount = revlog.count() |
|
159 | 159 | def fix(val, defval): |
|
160 | 160 | if not val: |
|
161 | 161 | return defval |
|
162 | 162 | try: |
|
163 | 163 | num = int(val) |
|
164 | 164 | if str(num) != val: |
|
165 | 165 | raise ValueError |
|
166 | 166 | if num < 0: |
|
167 | 167 | num += revcount |
|
168 | 168 | if not (0 <= num < revcount): |
|
169 | 169 | raise ValueError |
|
170 | 170 | except ValueError: |
|
171 | 171 | try: |
|
172 | 172 | num = repo.changelog.rev(repo.lookup(val)) |
|
173 | 173 | except KeyError: |
|
174 | 174 | try: |
|
175 | 175 | num = revlog.rev(revlog.lookup(val)) |
|
176 | 176 | except KeyError: |
|
177 | 177 | raise util.Abort('invalid revision identifier %s', val) |
|
178 | 178 | return num |
|
179 | 179 | seen = {} |
|
180 | 180 | for spec in revs: |
|
181 | 181 | if spec.find(revrangesep) >= 0: |
|
182 | 182 | start, end = spec.split(revrangesep, 1) |
|
183 | 183 | start = fix(start, 0) |
|
184 | 184 | end = fix(end, revcount - 1) |
|
185 | 185 | step = start > end and -1 or 1 |
|
186 | 186 | for rev in xrange(start, end+step, step): |
|
187 | 187 | if rev in seen: continue |
|
188 | 188 | seen[rev] = 1 |
|
189 | 189 | yield str(rev) |
|
190 | 190 | else: |
|
191 | 191 | rev = fix(spec, None) |
|
192 | 192 | if rev in seen: continue |
|
193 | 193 | seen[rev] = 1 |
|
194 | 194 | yield str(rev) |
|
195 | 195 | |
|
196 | 196 | def make_filename(repo, r, pat, node=None, |
|
197 | total=None, seqno=None, revwidth=None): | |
|
197 | total=None, seqno=None, revwidth=None, pathname=None): | |
|
198 | 198 | node_expander = { |
|
199 | 199 | 'H': lambda: hex(node), |
|
200 | 200 | 'R': lambda: str(r.rev(node)), |
|
201 | 201 | 'h': lambda: short(node), |
|
202 | 202 | } |
|
203 | 203 | expander = { |
|
204 | 204 | '%': lambda: '%', |
|
205 | 205 | 'b': lambda: os.path.basename(repo.root), |
|
206 | 206 | } |
|
207 | 207 | |
|
208 | 208 | try: |
|
209 | 209 | if node: |
|
210 | 210 | expander.update(node_expander) |
|
211 | 211 | if node and revwidth is not None: |
|
212 | 212 | expander['r'] = lambda: str(r.rev(node)).zfill(revwidth) |
|
213 | 213 | if total is not None: |
|
214 | 214 | expander['N'] = lambda: str(total) |
|
215 | 215 | if seqno is not None: |
|
216 | 216 | expander['n'] = lambda: str(seqno) |
|
217 | 217 | if total is not None and seqno is not None: |
|
218 | 218 | expander['n'] = lambda:str(seqno).zfill(len(str(total))) |
|
219 | if pathname is not None: | |
|
220 | expander['s'] = lambda: os.path.basename(pathname) | |
|
221 | expander['d'] = lambda: os.path.dirname(pathname) or '.' | |
|
222 | expander['p'] = lambda: pathname | |
|
219 | 223 | |
|
220 | 224 | newname = [] |
|
221 | 225 | patlen = len(pat) |
|
222 | 226 | i = 0 |
|
223 | 227 | while i < patlen: |
|
224 | 228 | c = pat[i] |
|
225 | 229 | if c == '%': |
|
226 | 230 | i += 1 |
|
227 | 231 | c = pat[i] |
|
228 | 232 | c = expander[c]() |
|
229 | 233 | newname.append(c) |
|
230 | 234 | i += 1 |
|
231 | 235 | return ''.join(newname) |
|
232 | 236 | except KeyError, inst: |
|
233 | 237 | raise util.Abort("invalid format spec '%%%s' in output file name", |
|
234 | 238 | inst.args[0]) |
|
235 | 239 | |
|
236 | 240 | def make_file(repo, r, pat, node=None, |
|
237 | total=None, seqno=None, revwidth=None, mode='wb'): | |
|
241 | total=None, seqno=None, revwidth=None, mode='wb', pathname=None): | |
|
238 | 242 | if not pat or pat == '-': |
|
239 | 243 | return 'w' in mode and sys.stdout or sys.stdin |
|
240 | 244 | if hasattr(pat, 'write') and 'w' in mode: |
|
241 | 245 | return pat |
|
242 | 246 | if hasattr(pat, 'read') and 'r' in mode: |
|
243 | 247 | return pat |
|
244 |
return open(make_filename(repo, r, pat, node, total, seqno, revwidth |
|
|
248 | return open(make_filename(repo, r, pat, node, total, seqno, revwidth, | |
|
249 | pathname), | |
|
245 | 250 | mode) |
|
246 | 251 | |
|
247 | 252 | def dodiff(fp, ui, repo, node1, node2, files=None, match=util.always, |
|
248 | 253 | changes=None, text=False): |
|
249 | 254 | def date(c): |
|
250 | 255 | return time.asctime(time.gmtime(float(c[2].split(' ')[0]))) |
|
251 | 256 | |
|
252 | 257 | if not changes: |
|
253 | 258 | (c, a, d, u) = repo.changes(node1, node2, files, match=match) |
|
254 | 259 | else: |
|
255 | 260 | (c, a, d, u) = changes |
|
256 | 261 | if files: |
|
257 | 262 | c, a, d = map(lambda x: filterfiles(files, x), (c, a, d)) |
|
258 | 263 | |
|
259 | 264 | if not c and not a and not d: |
|
260 | 265 | return |
|
261 | 266 | |
|
262 | 267 | if node2: |
|
263 | 268 | change = repo.changelog.read(node2) |
|
264 | 269 | mmap2 = repo.manifest.read(change[0]) |
|
265 | 270 | date2 = date(change) |
|
266 | 271 | def read(f): |
|
267 | 272 | return repo.file(f).read(mmap2[f]) |
|
268 | 273 | else: |
|
269 | 274 | date2 = time.asctime() |
|
270 | 275 | if not node1: |
|
271 | 276 | node1 = repo.dirstate.parents()[0] |
|
272 | 277 | def read(f): |
|
273 | 278 | return repo.wfile(f).read() |
|
274 | 279 | |
|
275 | 280 | if ui.quiet: |
|
276 | 281 | r = None |
|
277 | 282 | else: |
|
278 | 283 | hexfunc = ui.verbose and hex or short |
|
279 | 284 | r = [hexfunc(node) for node in [node1, node2] if node] |
|
280 | 285 | |
|
281 | 286 | change = repo.changelog.read(node1) |
|
282 | 287 | mmap = repo.manifest.read(change[0]) |
|
283 | 288 | date1 = date(change) |
|
284 | 289 | |
|
285 | 290 | for f in c: |
|
286 | 291 | to = None |
|
287 | 292 | if f in mmap: |
|
288 | 293 | to = repo.file(f).read(mmap[f]) |
|
289 | 294 | tn = read(f) |
|
290 | 295 | fp.write(mdiff.unidiff(to, date1, tn, date2, f, r, text=text)) |
|
291 | 296 | for f in a: |
|
292 | 297 | to = None |
|
293 | 298 | tn = read(f) |
|
294 | 299 | fp.write(mdiff.unidiff(to, date1, tn, date2, f, r, text=text)) |
|
295 | 300 | for f in d: |
|
296 | 301 | to = repo.file(f).read(mmap[f]) |
|
297 | 302 | tn = None |
|
298 | 303 | fp.write(mdiff.unidiff(to, date1, tn, date2, f, r, text=text)) |
|
299 | 304 | |
|
300 | 305 | def trimuser(ui, name, rev, revcache): |
|
301 | 306 | """trim the name of the user who committed a change""" |
|
302 | 307 | user = revcache.get(rev) |
|
303 | 308 | if user is None: |
|
304 | 309 | user = revcache[rev] = ui.shortuser(name) |
|
305 | 310 | return user |
|
306 | 311 | |
|
307 | 312 | def show_changeset(ui, repo, rev=0, changenode=None, brinfo=None): |
|
308 | 313 | """show a single changeset or file revision""" |
|
309 | 314 | log = repo.changelog |
|
310 | 315 | if changenode is None: |
|
311 | 316 | changenode = log.node(rev) |
|
312 | 317 | elif not rev: |
|
313 | 318 | rev = log.rev(changenode) |
|
314 | 319 | |
|
315 | 320 | if ui.quiet: |
|
316 | 321 | ui.write("%d:%s\n" % (rev, short(changenode))) |
|
317 | 322 | return |
|
318 | 323 | |
|
319 | 324 | changes = log.read(changenode) |
|
320 | 325 | |
|
321 | 326 | t, tz = changes[2].split(' ') |
|
322 | 327 | # a conversion tool was sticking non-integer offsets into repos |
|
323 | 328 | try: |
|
324 | 329 | tz = int(tz) |
|
325 | 330 | except ValueError: |
|
326 | 331 | tz = 0 |
|
327 | 332 | date = time.asctime(time.localtime(float(t))) + " %+05d" % (int(tz)/-36) |
|
328 | 333 | |
|
329 | 334 | parents = [(log.rev(p), ui.verbose and hex(p) or short(p)) |
|
330 | 335 | for p in log.parents(changenode) |
|
331 | 336 | if ui.debugflag or p != nullid] |
|
332 | 337 | if not ui.debugflag and len(parents) == 1 and parents[0][0] == rev-1: |
|
333 | 338 | parents = [] |
|
334 | 339 | |
|
335 | 340 | if ui.verbose: |
|
336 | 341 | ui.write("changeset: %d:%s\n" % (rev, hex(changenode))) |
|
337 | 342 | else: |
|
338 | 343 | ui.write("changeset: %d:%s\n" % (rev, short(changenode))) |
|
339 | 344 | |
|
340 | 345 | for tag in repo.nodetags(changenode): |
|
341 | 346 | ui.status("tag: %s\n" % tag) |
|
342 | 347 | for parent in parents: |
|
343 | 348 | ui.write("parent: %d:%s\n" % parent) |
|
344 | 349 | |
|
345 | 350 | if brinfo and changenode in brinfo: |
|
346 | 351 | br = brinfo[changenode] |
|
347 | 352 | ui.write("branch: %s\n" % " ".join(br)) |
|
348 | 353 | |
|
349 | 354 | ui.debug("manifest: %d:%s\n" % (repo.manifest.rev(changes[0]), |
|
350 | 355 | hex(changes[0]))) |
|
351 | 356 | ui.status("user: %s\n" % changes[1]) |
|
352 | 357 | ui.status("date: %s\n" % date) |
|
353 | 358 | |
|
354 | 359 | if ui.debugflag: |
|
355 | 360 | files = repo.changes(log.parents(changenode)[0], changenode) |
|
356 | 361 | for key, value in zip(["files:", "files+:", "files-:"], files): |
|
357 | 362 | if value: |
|
358 | 363 | ui.note("%-12s %s\n" % (key, " ".join(value))) |
|
359 | 364 | else: |
|
360 | 365 | ui.note("files: %s\n" % " ".join(changes[3])) |
|
361 | 366 | |
|
362 | 367 | description = changes[4].strip() |
|
363 | 368 | if description: |
|
364 | 369 | if ui.verbose: |
|
365 | 370 | ui.status("description:\n") |
|
366 | 371 | ui.status(description) |
|
367 | 372 | ui.status("\n\n") |
|
368 | 373 | else: |
|
369 | 374 | ui.status("summary: %s\n" % description.splitlines()[0]) |
|
370 | 375 | ui.status("\n") |
|
371 | 376 | |
|
372 | 377 | def show_version(ui): |
|
373 | 378 | """output version and copyright information""" |
|
374 | 379 | ui.write("Mercurial Distributed SCM (version %s)\n" |
|
375 | 380 | % version.get_version()) |
|
376 | 381 | ui.status( |
|
377 | 382 | "\nCopyright (C) 2005 Matt Mackall <mpm@selenic.com>\n" |
|
378 | 383 | "This is free software; see the source for copying conditions. " |
|
379 | 384 | "There is NO\nwarranty; " |
|
380 | 385 | "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n" |
|
381 | 386 | ) |
|
382 | 387 | |
|
383 | 388 | def help_(ui, cmd=None, with_version=False): |
|
384 | 389 | """show help for a given command or all commands""" |
|
385 | 390 | option_lists = [] |
|
386 | 391 | if cmd and cmd != 'shortlist': |
|
387 | 392 | if with_version: |
|
388 | 393 | show_version(ui) |
|
389 | 394 | ui.write('\n') |
|
390 | 395 | key, i = find(cmd) |
|
391 | 396 | # synopsis |
|
392 | 397 | ui.write("%s\n\n" % i[2]) |
|
393 | 398 | |
|
394 | 399 | # description |
|
395 | 400 | doc = i[0].__doc__ |
|
396 | 401 | if ui.quiet: |
|
397 | 402 | doc = doc.splitlines(0)[0] |
|
398 | 403 | ui.write("%s\n" % doc.rstrip()) |
|
399 | 404 | |
|
400 | 405 | if not ui.quiet: |
|
401 | 406 | # aliases |
|
402 | 407 | aliases = ', '.join(key.split('|')[1:]) |
|
403 | 408 | if aliases: |
|
404 | 409 | ui.write("\naliases: %s\n" % aliases) |
|
405 | 410 | |
|
406 | 411 | # options |
|
407 | 412 | if i[1]: |
|
408 | 413 | option_lists.append(("options", i[1])) |
|
409 | 414 | |
|
410 | 415 | else: |
|
411 | 416 | # program name |
|
412 | 417 | if ui.verbose or with_version: |
|
413 | 418 | show_version(ui) |
|
414 | 419 | else: |
|
415 | 420 | ui.status("Mercurial Distributed SCM\n") |
|
416 | 421 | ui.status('\n') |
|
417 | 422 | |
|
418 | 423 | # list of commands |
|
419 | 424 | if cmd == "shortlist": |
|
420 | 425 | ui.status('basic commands (use "hg help" ' |
|
421 | 426 | 'for the full list or option "-v" for details):\n\n') |
|
422 | 427 | elif ui.verbose: |
|
423 | 428 | ui.status('list of commands:\n\n') |
|
424 | 429 | else: |
|
425 | 430 | ui.status('list of commands (use "hg help -v" ' |
|
426 | 431 | 'to show aliases and global options):\n\n') |
|
427 | 432 | |
|
428 | 433 | h = {} |
|
429 | 434 | cmds = {} |
|
430 | 435 | for c, e in table.items(): |
|
431 | 436 | f = c.split("|")[0] |
|
432 | 437 | if cmd == "shortlist" and not f.startswith("^"): |
|
433 | 438 | continue |
|
434 | 439 | f = f.lstrip("^") |
|
435 | 440 | if not ui.debugflag and f.startswith("debug"): |
|
436 | 441 | continue |
|
437 | 442 | d = "" |
|
438 | 443 | if e[0].__doc__: |
|
439 | 444 | d = e[0].__doc__.splitlines(0)[0].rstrip() |
|
440 | 445 | h[f] = d |
|
441 | 446 | cmds[f]=c.lstrip("^") |
|
442 | 447 | |
|
443 | 448 | fns = h.keys() |
|
444 | 449 | fns.sort() |
|
445 | 450 | m = max(map(len, fns)) |
|
446 | 451 | for f in fns: |
|
447 | 452 | if ui.verbose: |
|
448 | 453 | commands = cmds[f].replace("|",", ") |
|
449 | 454 | ui.write(" %s:\n %s\n"%(commands,h[f])) |
|
450 | 455 | else: |
|
451 | 456 | ui.write(' %-*s %s\n' % (m, f, h[f])) |
|
452 | 457 | |
|
453 | 458 | # global options |
|
454 | 459 | if ui.verbose: |
|
455 | 460 | option_lists.append(("global options", globalopts)) |
|
456 | 461 | |
|
457 | 462 | # list all option lists |
|
458 | 463 | opt_output = [] |
|
459 | 464 | for title, options in option_lists: |
|
460 | 465 | opt_output.append(("\n%s:\n" % title, None)) |
|
461 | 466 | for shortopt, longopt, default, desc in options: |
|
462 | 467 | opt_output.append(("%2s%s" % (shortopt and "-%s" % shortopt, |
|
463 | 468 | longopt and " --%s" % longopt), |
|
464 | 469 | "%s%s" % (desc, |
|
465 | 470 | default and " (default: %s)" % default |
|
466 | 471 | or ""))) |
|
467 | 472 | |
|
468 | 473 | if opt_output: |
|
469 | 474 | opts_len = max([len(line[0]) for line in opt_output if line[1]]) |
|
470 | 475 | for first, second in opt_output: |
|
471 | 476 | if second: |
|
472 | 477 | ui.write(" %-*s %s\n" % (opts_len, first, second)) |
|
473 | 478 | else: |
|
474 | 479 | ui.write("%s\n" % first) |
|
475 | 480 | |
|
476 | 481 | # Commands start here, listed alphabetically |
|
477 | 482 | |
|
478 | 483 | def add(ui, repo, *pats, **opts): |
|
479 | 484 | '''add the specified files on the next commit''' |
|
480 | 485 | names = [] |
|
481 | 486 | for src, abs, rel, exact in walk(repo, pats, opts): |
|
482 | 487 | if exact: |
|
483 | 488 | names.append(abs) |
|
484 | 489 | elif repo.dirstate.state(abs) == '?': |
|
485 | 490 | ui.status('adding %s\n' % rel) |
|
486 | 491 | names.append(abs) |
|
487 | 492 | repo.add(names) |
|
488 | 493 | |
|
489 | 494 | def addremove(ui, repo, *pats, **opts): |
|
490 | 495 | """add all new files, delete all missing files""" |
|
491 | 496 | add, remove = [], [] |
|
492 | 497 | for src, abs, rel, exact in walk(repo, pats, opts): |
|
493 | 498 | if src == 'f' and repo.dirstate.state(abs) == '?': |
|
494 | 499 | add.append(abs) |
|
495 | 500 | if not exact: |
|
496 | 501 | ui.status('adding ', rel, '\n') |
|
497 | 502 | if repo.dirstate.state(abs) != 'r' and not os.path.exists(rel): |
|
498 | 503 | remove.append(abs) |
|
499 | 504 | if not exact: |
|
500 | 505 | ui.status('removing ', rel, '\n') |
|
501 | 506 | repo.add(add) |
|
502 | 507 | repo.remove(remove) |
|
503 | 508 | |
|
504 | 509 | def annotate(ui, repo, *pats, **opts): |
|
505 | 510 | """show changeset information per file line""" |
|
506 | 511 | def getnode(rev): |
|
507 | 512 | return short(repo.changelog.node(rev)) |
|
508 | 513 | |
|
509 | 514 | ucache = {} |
|
510 | 515 | def getname(rev): |
|
511 | 516 | cl = repo.changelog.read(repo.changelog.node(rev)) |
|
512 | 517 | return trimuser(ui, cl[1], rev, ucache) |
|
513 | 518 | |
|
514 | 519 | if not pats: |
|
515 | 520 | raise util.Abort('at least one file name or pattern required') |
|
516 | 521 | |
|
517 | 522 | opmap = [['user', getname], ['number', str], ['changeset', getnode]] |
|
518 | 523 | if not opts['user'] and not opts['changeset']: |
|
519 | 524 | opts['number'] = 1 |
|
520 | 525 | |
|
521 | 526 | if opts['rev']: |
|
522 | 527 | node = repo.changelog.lookup(opts['rev']) |
|
523 | 528 | else: |
|
524 | 529 | node = repo.dirstate.parents()[0] |
|
525 | 530 | change = repo.changelog.read(node) |
|
526 | 531 | mmap = repo.manifest.read(change[0]) |
|
527 | 532 | |
|
528 | 533 | for src, abs, rel, exact in walk(repo, pats, opts): |
|
529 | 534 | if abs not in mmap: |
|
530 | 535 | ui.warn("warning: %s is not in the repository!\n" % rel) |
|
531 | 536 | continue |
|
532 | 537 | |
|
533 | 538 | f = repo.file(abs) |
|
534 | 539 | if not opts['text'] and util.binary(f.read(mmap[abs])): |
|
535 | 540 | ui.write("%s: binary file\n" % rel) |
|
536 | 541 | continue |
|
537 | 542 | |
|
538 | 543 | lines = f.annotate(mmap[abs]) |
|
539 | 544 | pieces = [] |
|
540 | 545 | |
|
541 | 546 | for o, f in opmap: |
|
542 | 547 | if opts[o]: |
|
543 | 548 | l = [f(n) for n, dummy in lines] |
|
544 | 549 | if l: |
|
545 | 550 | m = max(map(len, l)) |
|
546 | 551 | pieces.append(["%*s" % (m, x) for x in l]) |
|
547 | 552 | |
|
548 | 553 | if pieces: |
|
549 | 554 | for p, l in zip(zip(*pieces), lines): |
|
550 | 555 | ui.write("%s: %s" % (" ".join(p), l[1])) |
|
551 | 556 | |
|
552 | 557 | def bundle(ui, repo, fname, dest="default-push", **opts): |
|
553 | 558 | """create a changegroup file""" |
|
554 | 559 | f = open(fname, "wb") |
|
555 | 560 | dest = ui.expandpath(dest) |
|
556 | 561 | other = hg.repository(ui, dest) |
|
557 | 562 | o = repo.findoutgoing(other) |
|
558 | 563 | cg = repo.changegroup(o) |
|
559 | 564 | |
|
560 | 565 | try: |
|
561 | 566 | f.write("HG10") |
|
562 | 567 | z = bz2.BZ2Compressor(9) |
|
563 | 568 | while 1: |
|
564 | 569 | chunk = cg.read(4096) |
|
565 | 570 | if not chunk: |
|
566 | 571 | break |
|
567 | 572 | f.write(z.compress(chunk)) |
|
568 | 573 | f.write(z.flush()) |
|
569 | 574 | except: |
|
570 | 575 | os.unlink(fname) |
|
571 | 576 | |
|
572 |
def cat(ui, repo, file1, |
|
|
573 |
"""output the latest or given revision of |
|
|
574 | r = repo.file(relpath(repo, [file1])[0]) | |
|
575 | if rev: | |
|
576 | try: | |
|
577 | # assume all revision numbers are for changesets | |
|
578 | n = repo.lookup(rev) | |
|
579 | change = repo.changelog.read(n) | |
|
580 | m = repo.manifest.read(change[0]) | |
|
581 | n = m[relpath(repo, [file1])[0]] | |
|
582 | except (hg.RepoError, KeyError): | |
|
577 | def cat(ui, repo, file1, *pats, **opts): | |
|
578 | """output the latest or given revisions of files""" | |
|
579 | mf = {} | |
|
580 | if opts['rev']: | |
|
581 | change = repo.changelog.read(repo.lookup(opts['rev'])) | |
|
582 | mf = repo.manifest.read(change[0]) | |
|
583 | for src, abs, rel, exact in walk(repo, (file1,) + pats, opts): | |
|
584 | r = repo.file(abs) | |
|
585 | if opts['rev']: | |
|
583 | 586 | try: |
|
584 |
n = |
|
|
585 |
except |
|
|
586 | raise util.Abort('cannot find file %s in rev %s', file1, rev) | |
|
587 | else: | |
|
588 | n = r.tip() | |
|
589 | fp = make_file(repo, r, opts['output'], node=n) | |
|
590 | fp.write(r.read(n)) | |
|
587 | n = mf[abs] | |
|
588 | except (hg.RepoError, KeyError): | |
|
589 | try: | |
|
590 | n = r.lookup(rev) | |
|
591 | except KeyError, inst: | |
|
592 | raise util.Abort('cannot find file %s in rev %s', rel, rev) | |
|
593 | else: | |
|
594 | n = r.tip() | |
|
595 | fp = make_file(repo, r, opts['output'], node=n, pathname=abs) | |
|
596 | fp.write(r.read(n)) | |
|
591 | 597 | |
|
592 | 598 | def clone(ui, source, dest=None, **opts): |
|
593 | 599 | """make a copy of an existing repository""" |
|
594 | 600 | if dest is None: |
|
595 | 601 | dest = os.path.basename(os.path.normpath(source)) |
|
596 | 602 | |
|
597 | 603 | if os.path.exists(dest): |
|
598 | 604 | raise util.Abort("destination '%s' already exists", dest) |
|
599 | 605 | |
|
600 | 606 | dest = os.path.realpath(dest) |
|
601 | 607 | |
|
602 | 608 | class Dircleanup: |
|
603 | 609 | def __init__(self, dir_): |
|
604 | 610 | self.rmtree = shutil.rmtree |
|
605 | 611 | self.dir_ = dir_ |
|
606 | 612 | os.mkdir(dir_) |
|
607 | 613 | def close(self): |
|
608 | 614 | self.dir_ = None |
|
609 | 615 | def __del__(self): |
|
610 | 616 | if self.dir_: |
|
611 | 617 | self.rmtree(self.dir_, True) |
|
612 | 618 | |
|
613 | 619 | if opts['ssh']: |
|
614 | 620 | ui.setconfig("ui", "ssh", opts['ssh']) |
|
615 | 621 | if opts['remotecmd']: |
|
616 | 622 | ui.setconfig("ui", "remotecmd", opts['remotecmd']) |
|
617 | 623 | |
|
618 | 624 | d = Dircleanup(dest) |
|
619 | 625 | if not os.path.exists(source): |
|
620 | 626 | source = ui.expandpath(source) |
|
621 | 627 | abspath = source |
|
622 | 628 | other = hg.repository(ui, source) |
|
623 | 629 | |
|
624 | 630 | copy = False |
|
625 | 631 | if other.dev() != -1: |
|
626 | 632 | abspath = os.path.abspath(source) |
|
627 | 633 | copy = True |
|
628 | 634 | |
|
629 | 635 | if copy: |
|
630 | 636 | try: |
|
631 | 637 | # we use a lock here because if we race with commit, we |
|
632 | 638 | # can end up with extra data in the cloned revlogs that's |
|
633 | 639 | # not pointed to by changesets, thus causing verify to |
|
634 | 640 | # fail |
|
635 | 641 | l1 = lock.lock(os.path.join(source, ".hg", "lock")) |
|
636 | 642 | except OSError: |
|
637 | 643 | copy = False |
|
638 | 644 | |
|
639 | 645 | if copy: |
|
640 | 646 | # we lock here to avoid premature writing to the target |
|
641 | 647 | os.mkdir(os.path.join(dest, ".hg")) |
|
642 | 648 | l2 = lock.lock(os.path.join(dest, ".hg", "lock")) |
|
643 | 649 | |
|
644 | 650 | files = "data 00manifest.d 00manifest.i 00changelog.d 00changelog.i" |
|
645 | 651 | for f in files.split(): |
|
646 | 652 | src = os.path.join(source, ".hg", f) |
|
647 | 653 | dst = os.path.join(dest, ".hg", f) |
|
648 | 654 | util.copyfiles(src, dst) |
|
649 | 655 | |
|
650 | 656 | repo = hg.repository(ui, dest) |
|
651 | 657 | |
|
652 | 658 | else: |
|
653 | 659 | repo = hg.repository(ui, dest, create=1) |
|
654 | 660 | repo.pull(other) |
|
655 | 661 | |
|
656 | 662 | f = repo.opener("hgrc", "w") |
|
657 | 663 | f.write("[paths]\n") |
|
658 | 664 | f.write("default = %s\n" % abspath) |
|
659 | 665 | |
|
660 | 666 | if not opts['noupdate']: |
|
661 | 667 | update(ui, repo) |
|
662 | 668 | |
|
663 | 669 | d.close() |
|
664 | 670 | |
|
665 | 671 | def commit(ui, repo, *pats, **opts): |
|
666 | 672 | """commit the specified files or all outstanding changes""" |
|
667 | 673 | if opts['text']: |
|
668 | 674 | ui.warn("Warning: -t and --text is deprecated," |
|
669 | 675 | " please use -m or --message instead.\n") |
|
670 | 676 | message = opts['message'] or opts['text'] |
|
671 | 677 | logfile = opts['logfile'] |
|
672 | 678 | if not message and logfile: |
|
673 | 679 | try: |
|
674 | 680 | if logfile == '-': |
|
675 | 681 | message = sys.stdin.read() |
|
676 | 682 | else: |
|
677 | 683 | message = open(logfile).read() |
|
678 | 684 | except IOError, why: |
|
679 | 685 | ui.warn("Can't read commit message %s: %s\n" % (logfile, why)) |
|
680 | 686 | |
|
681 | 687 | if opts['addremove']: |
|
682 | 688 | addremove(ui, repo, *pats, **opts) |
|
683 | 689 | cwd = repo.getcwd() |
|
684 | 690 | if not pats and cwd: |
|
685 | 691 | opts['include'] = [os.path.join(cwd, i) for i in opts['include']] |
|
686 | 692 | opts['exclude'] = [os.path.join(cwd, x) for x in opts['exclude']] |
|
687 | 693 | fns, match, anypats = matchpats(repo, (pats and repo.getcwd()) or '', |
|
688 | 694 | pats, opts) |
|
689 | 695 | if pats: |
|
690 | 696 | c, a, d, u = repo.changes(files=fns, match=match) |
|
691 | 697 | files = c + a + [fn for fn in d if repo.dirstate.state(fn) == 'r'] |
|
692 | 698 | else: |
|
693 | 699 | files = [] |
|
694 | 700 | try: |
|
695 | 701 | repo.commit(files, message, opts['user'], opts['date'], match) |
|
696 | 702 | except ValueError, inst: |
|
697 | 703 | raise util.Abort(str(inst)) |
|
698 | 704 | |
|
699 | 705 | def docopy(ui, repo, pats, opts): |
|
700 | 706 | if not pats: |
|
701 | 707 | raise util.Abort('no source or destination specified') |
|
702 | 708 | elif len(pats) == 1: |
|
703 | 709 | raise util.Abort('no destination specified') |
|
704 | 710 | pats = list(pats) |
|
705 | 711 | dest = pats.pop() |
|
706 | 712 | sources = [] |
|
707 | 713 | |
|
708 | 714 | def okaytocopy(abs, rel, exact): |
|
709 | 715 | reasons = {'?': 'is not managed', |
|
710 | 716 | 'a': 'has been marked for add'} |
|
711 | 717 | reason = reasons.get(repo.dirstate.state(abs)) |
|
712 | 718 | if reason: |
|
713 | 719 | if exact: ui.warn('%s: not copying - file %s\n' % (rel, reason)) |
|
714 | 720 | else: |
|
715 | 721 | return True |
|
716 | 722 | |
|
717 | 723 | for src, abs, rel, exact in walk(repo, pats, opts): |
|
718 | 724 | if okaytocopy(abs, rel, exact): |
|
719 | 725 | sources.append((abs, rel, exact)) |
|
720 | 726 | if not sources: |
|
721 | 727 | raise util.Abort('no files to copy') |
|
722 | 728 | |
|
723 | 729 | cwd = repo.getcwd() |
|
724 | 730 | absdest = util.canonpath(repo.root, cwd, dest) |
|
725 | 731 | reldest = util.pathto(cwd, absdest) |
|
726 | 732 | if os.path.exists(reldest): |
|
727 | 733 | destisfile = not os.path.isdir(reldest) |
|
728 | 734 | else: |
|
729 | 735 | destisfile = len(sources) == 1 or repo.dirstate.state(absdest) != '?' |
|
730 | 736 | |
|
731 | 737 | if destisfile: |
|
732 | 738 | if opts['parents']: |
|
733 | 739 | raise util.Abort('with --parents, destination must be a directory') |
|
734 | 740 | elif len(sources) > 1: |
|
735 | 741 | raise util.Abort('with multiple sources, destination must be a ' |
|
736 | 742 | 'directory') |
|
737 | 743 | errs, copied = 0, [] |
|
738 | 744 | for abs, rel, exact in sources: |
|
739 | 745 | if opts['parents']: |
|
740 | 746 | mydest = os.path.join(dest, rel) |
|
741 | 747 | elif destisfile: |
|
742 | 748 | mydest = reldest |
|
743 | 749 | else: |
|
744 | 750 | mydest = os.path.join(dest, os.path.basename(rel)) |
|
745 | 751 | myabsdest = util.canonpath(repo.root, cwd, mydest) |
|
746 | 752 | myreldest = util.pathto(cwd, myabsdest) |
|
747 | 753 | if not opts['force'] and repo.dirstate.state(myabsdest) not in 'a?': |
|
748 | 754 | ui.warn('%s: not overwriting - file already managed\n' % myreldest) |
|
749 | 755 | continue |
|
750 | 756 | mydestdir = os.path.dirname(myreldest) or '.' |
|
751 | 757 | if not opts['after']: |
|
752 | 758 | try: |
|
753 | 759 | if opts['parents']: os.makedirs(mydestdir) |
|
754 | 760 | elif not destisfile: os.mkdir(mydestdir) |
|
755 | 761 | except OSError, inst: |
|
756 | 762 | if inst.errno != errno.EEXIST: raise |
|
757 | 763 | if ui.verbose or not exact: |
|
758 | 764 | ui.status('copying %s to %s\n' % (rel, myreldest)) |
|
759 | 765 | if not opts['after']: |
|
760 | 766 | try: |
|
761 | 767 | shutil.copyfile(rel, myreldest) |
|
762 | 768 | n = repo.manifest.tip() |
|
763 | 769 | mf = repo.manifest.readflags(n) |
|
764 | 770 | util.set_exec(myreldest, util.is_exec(rel, mf[abs])) |
|
765 | 771 | except shutil.Error, inst: |
|
766 | 772 | raise util.Abort(str(inst)) |
|
767 | 773 | except IOError, inst: |
|
768 | 774 | if inst.errno == errno.ENOENT: |
|
769 | 775 | ui.warn('%s: deleted in working copy\n' % rel) |
|
770 | 776 | else: |
|
771 | 777 | ui.warn('%s: cannot copy - %s\n' % (rel, inst.strerror)) |
|
772 | 778 | errs += 1 |
|
773 | 779 | continue |
|
774 | 780 | repo.copy(abs, myabsdest) |
|
775 | 781 | copied.append((abs, rel, exact)) |
|
776 | 782 | if errs: |
|
777 | 783 | ui.warn('(consider using --after)\n') |
|
778 | 784 | return errs, copied |
|
779 | 785 | |
|
780 | 786 | def copy(ui, repo, *pats, **opts): |
|
781 | 787 | """mark files as copied for the next commit""" |
|
782 | 788 | errs, copied = docopy(ui, repo, pats, opts) |
|
783 | 789 | return errs |
|
784 | 790 | |
|
785 | 791 | def debugcheckstate(ui, repo): |
|
786 | 792 | """validate the correctness of the current dirstate""" |
|
787 | 793 | parent1, parent2 = repo.dirstate.parents() |
|
788 | 794 | repo.dirstate.read() |
|
789 | 795 | dc = repo.dirstate.map |
|
790 | 796 | keys = dc.keys() |
|
791 | 797 | keys.sort() |
|
792 | 798 | m1n = repo.changelog.read(parent1)[0] |
|
793 | 799 | m2n = repo.changelog.read(parent2)[0] |
|
794 | 800 | m1 = repo.manifest.read(m1n) |
|
795 | 801 | m2 = repo.manifest.read(m2n) |
|
796 | 802 | errors = 0 |
|
797 | 803 | for f in dc: |
|
798 | 804 | state = repo.dirstate.state(f) |
|
799 | 805 | if state in "nr" and f not in m1: |
|
800 | 806 | ui.warn("%s in state %s, but not in manifest1\n" % (f, state)) |
|
801 | 807 | errors += 1 |
|
802 | 808 | if state in "a" and f in m1: |
|
803 | 809 | ui.warn("%s in state %s, but also in manifest1\n" % (f, state)) |
|
804 | 810 | errors += 1 |
|
805 | 811 | if state in "m" and f not in m1 and f not in m2: |
|
806 | 812 | ui.warn("%s in state %s, but not in either manifest\n" % |
|
807 | 813 | (f, state)) |
|
808 | 814 | errors += 1 |
|
809 | 815 | for f in m1: |
|
810 | 816 | state = repo.dirstate.state(f) |
|
811 | 817 | if state not in "nrm": |
|
812 | 818 | ui.warn("%s in manifest1, but listed as state %s" % (f, state)) |
|
813 | 819 | errors += 1 |
|
814 | 820 | if errors: |
|
815 | 821 | raise util.Abort(".hg/dirstate inconsistent with current parent's manifest") |
|
816 | 822 | |
|
817 | 823 | def debugconfig(ui): |
|
818 | 824 | """show combined config settings from all hgrc files""" |
|
819 | 825 | try: |
|
820 | 826 | repo = hg.repository(ui) |
|
821 | 827 | except hg.RepoError: |
|
822 | 828 | pass |
|
823 | 829 | for section, name, value in ui.walkconfig(): |
|
824 | 830 | ui.write('%s.%s=%s\n' % (section, name, value)) |
|
825 | 831 | |
|
826 | 832 | def debugstate(ui, repo): |
|
827 | 833 | """show the contents of the current dirstate""" |
|
828 | 834 | repo.dirstate.read() |
|
829 | 835 | dc = repo.dirstate.map |
|
830 | 836 | keys = dc.keys() |
|
831 | 837 | keys.sort() |
|
832 | 838 | for file_ in keys: |
|
833 | 839 | ui.write("%c %3o %10d %s %s\n" |
|
834 | 840 | % (dc[file_][0], dc[file_][1] & 0777, dc[file_][2], |
|
835 | 841 | time.strftime("%x %X", |
|
836 | 842 | time.localtime(dc[file_][3])), file_)) |
|
837 | 843 | for f in repo.dirstate.copies: |
|
838 | 844 | ui.write("copy: %s -> %s\n" % (repo.dirstate.copies[f], f)) |
|
839 | 845 | |
|
840 | 846 | def debugdata(ui, file_, rev): |
|
841 | 847 | """dump the contents of an data file revision""" |
|
842 | 848 | r = revlog.revlog(file, file_[:-2] + ".i", file_) |
|
843 | 849 | ui.write(r.revision(r.lookup(rev))) |
|
844 | 850 | |
|
845 | 851 | def debugindex(ui, file_): |
|
846 | 852 | """dump the contents of an index file""" |
|
847 | 853 | r = revlog.revlog(file, file_, "") |
|
848 | 854 | ui.write(" rev offset length base linkrev" + |
|
849 | 855 | " nodeid p1 p2\n") |
|
850 | 856 | for i in range(r.count()): |
|
851 | 857 | e = r.index[i] |
|
852 | 858 | ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % ( |
|
853 | 859 | i, e[0], e[1], e[2], e[3], |
|
854 | 860 | short(e[6]), short(e[4]), short(e[5]))) |
|
855 | 861 | |
|
856 | 862 | def debugindexdot(ui, file_): |
|
857 | 863 | """dump an index DAG as a .dot file""" |
|
858 | 864 | r = revlog.revlog(file, file_, "") |
|
859 | 865 | ui.write("digraph G {\n") |
|
860 | 866 | for i in range(r.count()): |
|
861 | 867 | e = r.index[i] |
|
862 | 868 | ui.write("\t%d -> %d\n" % (r.rev(e[4]), i)) |
|
863 | 869 | if e[5] != nullid: |
|
864 | 870 | ui.write("\t%d -> %d\n" % (r.rev(e[5]), i)) |
|
865 | 871 | ui.write("}\n") |
|
866 | 872 | |
|
867 | 873 | def debugrename(ui, repo, file, rev=None): |
|
868 | 874 | """dump rename information""" |
|
869 | 875 | r = repo.file(relpath(repo, [file])[0]) |
|
870 | 876 | if rev: |
|
871 | 877 | try: |
|
872 | 878 | # assume all revision numbers are for changesets |
|
873 | 879 | n = repo.lookup(rev) |
|
874 | 880 | change = repo.changelog.read(n) |
|
875 | 881 | m = repo.manifest.read(change[0]) |
|
876 | 882 | n = m[relpath(repo, [file])[0]] |
|
877 | 883 | except hg.RepoError, KeyError: |
|
878 | 884 | n = r.lookup(rev) |
|
879 | 885 | else: |
|
880 | 886 | n = r.tip() |
|
881 | 887 | m = r.renamed(n) |
|
882 | 888 | if m: |
|
883 | 889 | ui.write("renamed from %s:%s\n" % (m[0], hex(m[1]))) |
|
884 | 890 | else: |
|
885 | 891 | ui.write("not renamed\n") |
|
886 | 892 | |
|
887 | 893 | def debugwalk(ui, repo, *pats, **opts): |
|
888 | 894 | """show how files match on given patterns""" |
|
889 | 895 | items = list(walk(repo, pats, opts)) |
|
890 | 896 | if not items: |
|
891 | 897 | return |
|
892 | 898 | fmt = '%%s %%-%ds %%-%ds %%s\n' % ( |
|
893 | 899 | max([len(abs) for (src, abs, rel, exact) in items]), |
|
894 | 900 | max([len(rel) for (src, abs, rel, exact) in items])) |
|
895 | 901 | for src, abs, rel, exact in items: |
|
896 | 902 | ui.write(fmt % (src, abs, rel, exact and 'exact' or '')) |
|
897 | 903 | |
|
898 | 904 | def diff(ui, repo, *pats, **opts): |
|
899 | 905 | """diff working directory (or selected files)""" |
|
900 | 906 | node1, node2 = None, None |
|
901 | 907 | revs = [repo.lookup(x) for x in opts['rev']] |
|
902 | 908 | |
|
903 | 909 | if len(revs) > 0: |
|
904 | 910 | node1 = revs[0] |
|
905 | 911 | if len(revs) > 1: |
|
906 | 912 | node2 = revs[1] |
|
907 | 913 | if len(revs) > 2: |
|
908 | 914 | raise util.Abort("too many revisions to diff") |
|
909 | 915 | |
|
910 | 916 | files = [] |
|
911 | 917 | match = util.always |
|
912 | 918 | if pats: |
|
913 | 919 | roots, match, results = makewalk(repo, pats, opts) |
|
914 | 920 | for src, abs, rel, exact in results: |
|
915 | 921 | files.append(abs) |
|
916 | 922 | |
|
917 | 923 | dodiff(sys.stdout, ui, repo, node1, node2, files, match=match, |
|
918 | 924 | text=opts['text']) |
|
919 | 925 | |
|
920 | 926 | def doexport(ui, repo, changeset, seqno, total, revwidth, opts): |
|
921 | 927 | node = repo.lookup(changeset) |
|
922 | 928 | prev, other = repo.changelog.parents(node) |
|
923 | 929 | change = repo.changelog.read(node) |
|
924 | 930 | |
|
925 | 931 | fp = make_file(repo, repo.changelog, opts['output'], |
|
926 | 932 | node=node, total=total, seqno=seqno, |
|
927 | 933 | revwidth=revwidth) |
|
928 | 934 | if fp != sys.stdout: |
|
929 | 935 | ui.note("%s\n" % fp.name) |
|
930 | 936 | |
|
931 | 937 | fp.write("# HG changeset patch\n") |
|
932 | 938 | fp.write("# User %s\n" % change[1]) |
|
933 | 939 | fp.write("# Node ID %s\n" % hex(node)) |
|
934 | 940 | fp.write("# Parent %s\n" % hex(prev)) |
|
935 | 941 | if other != nullid: |
|
936 | 942 | fp.write("# Parent %s\n" % hex(other)) |
|
937 | 943 | fp.write(change[4].rstrip()) |
|
938 | 944 | fp.write("\n\n") |
|
939 | 945 | |
|
940 | 946 | dodiff(fp, ui, repo, prev, node, text=opts['text']) |
|
941 | 947 | if fp != sys.stdout: |
|
942 | 948 | fp.close() |
|
943 | 949 | |
|
944 | 950 | def export(ui, repo, *changesets, **opts): |
|
945 | 951 | """dump the header and diffs for one or more changesets""" |
|
946 | 952 | if not changesets: |
|
947 | 953 | raise util.Abort("export requires at least one changeset") |
|
948 | 954 | seqno = 0 |
|
949 | 955 | revs = list(revrange(ui, repo, changesets)) |
|
950 | 956 | total = len(revs) |
|
951 | 957 | revwidth = max(map(len, revs)) |
|
952 | 958 | ui.note(len(revs) > 1 and "Exporting patches:\n" or "Exporting patch:\n") |
|
953 | 959 | for cset in revs: |
|
954 | 960 | seqno += 1 |
|
955 | 961 | doexport(ui, repo, cset, seqno, total, revwidth, opts) |
|
956 | 962 | |
|
957 | 963 | def forget(ui, repo, *pats, **opts): |
|
958 | 964 | """don't add the specified files on the next commit""" |
|
959 | 965 | forget = [] |
|
960 | 966 | for src, abs, rel, exact in walk(repo, pats, opts): |
|
961 | 967 | if repo.dirstate.state(abs) == 'a': |
|
962 | 968 | forget.append(abs) |
|
963 | 969 | if not exact: |
|
964 | 970 | ui.status('forgetting ', rel, '\n') |
|
965 | 971 | repo.forget(forget) |
|
966 | 972 | |
|
967 | 973 | def grep(ui, repo, pattern, *pats, **opts): |
|
968 | 974 | """search for a pattern in specified files and revisions""" |
|
969 | 975 | reflags = 0 |
|
970 | 976 | if opts['ignore_case']: |
|
971 | 977 | reflags |= re.I |
|
972 | 978 | regexp = re.compile(pattern, reflags) |
|
973 | 979 | sep, eol = ':', '\n' |
|
974 | 980 | if opts['print0']: |
|
975 | 981 | sep = eol = '\0' |
|
976 | 982 | |
|
977 | 983 | fcache = {} |
|
978 | 984 | def getfile(fn): |
|
979 | 985 | if fn not in fcache: |
|
980 | 986 | fcache[fn] = repo.file(fn) |
|
981 | 987 | return fcache[fn] |
|
982 | 988 | |
|
983 | 989 | def matchlines(body): |
|
984 | 990 | begin = 0 |
|
985 | 991 | linenum = 0 |
|
986 | 992 | while True: |
|
987 | 993 | match = regexp.search(body, begin) |
|
988 | 994 | if not match: |
|
989 | 995 | break |
|
990 | 996 | mstart, mend = match.span() |
|
991 | 997 | linenum += body.count('\n', begin, mstart) + 1 |
|
992 | 998 | lstart = body.rfind('\n', begin, mstart) + 1 or begin |
|
993 | 999 | lend = body.find('\n', mend) |
|
994 | 1000 | yield linenum, mstart - lstart, mend - lstart, body[lstart:lend] |
|
995 | 1001 | begin = lend + 1 |
|
996 | 1002 | |
|
997 | 1003 | class linestate: |
|
998 | 1004 | def __init__(self, line, linenum, colstart, colend): |
|
999 | 1005 | self.line = line |
|
1000 | 1006 | self.linenum = linenum |
|
1001 | 1007 | self.colstart = colstart |
|
1002 | 1008 | self.colend = colend |
|
1003 | 1009 | def __eq__(self, other): |
|
1004 | 1010 | return self.line == other.line |
|
1005 | 1011 | def __hash__(self): |
|
1006 | 1012 | return hash(self.line) |
|
1007 | 1013 | |
|
1008 | 1014 | matches = {} |
|
1009 | 1015 | def grepbody(fn, rev, body): |
|
1010 | 1016 | matches[rev].setdefault(fn, {}) |
|
1011 | 1017 | m = matches[rev][fn] |
|
1012 | 1018 | for lnum, cstart, cend, line in matchlines(body): |
|
1013 | 1019 | s = linestate(line, lnum, cstart, cend) |
|
1014 | 1020 | m[s] = s |
|
1015 | 1021 | |
|
1016 | 1022 | prev = {} |
|
1017 | 1023 | ucache = {} |
|
1018 | 1024 | def display(fn, rev, states, prevstates): |
|
1019 | 1025 | diff = list(sets.Set(states).symmetric_difference(sets.Set(prevstates))) |
|
1020 | 1026 | diff.sort(lambda x, y: cmp(x.linenum, y.linenum)) |
|
1021 | 1027 | counts = {'-': 0, '+': 0} |
|
1022 | 1028 | filerevmatches = {} |
|
1023 | 1029 | for l in diff: |
|
1024 | 1030 | if incrementing or not opts['all']: |
|
1025 | 1031 | change = ((l in prevstates) and '-') or '+' |
|
1026 | 1032 | r = rev |
|
1027 | 1033 | else: |
|
1028 | 1034 | change = ((l in states) and '-') or '+' |
|
1029 | 1035 | r = prev[fn] |
|
1030 | 1036 | cols = [fn, str(rev)] |
|
1031 | 1037 | if opts['line_number']: cols.append(str(l.linenum)) |
|
1032 | 1038 | if opts['all']: cols.append(change) |
|
1033 | 1039 | if opts['user']: cols.append(trimuser(ui, getchange(rev)[1], rev, |
|
1034 | 1040 | ucache)) |
|
1035 | 1041 | if opts['files_with_matches']: |
|
1036 | 1042 | c = (fn, rev) |
|
1037 | 1043 | if c in filerevmatches: continue |
|
1038 | 1044 | filerevmatches[c] = 1 |
|
1039 | 1045 | else: |
|
1040 | 1046 | cols.append(l.line) |
|
1041 | 1047 | ui.write(sep.join(cols), eol) |
|
1042 | 1048 | counts[change] += 1 |
|
1043 | 1049 | return counts['+'], counts['-'] |
|
1044 | 1050 | |
|
1045 | 1051 | fstate = {} |
|
1046 | 1052 | skip = {} |
|
1047 | 1053 | changeiter, getchange = walkchangerevs(ui, repo, repo.getcwd(), pats, opts) |
|
1048 | 1054 | count = 0 |
|
1049 | 1055 | for st, rev, fns in changeiter: |
|
1050 | 1056 | if st == 'window': |
|
1051 | 1057 | incrementing = rev |
|
1052 | 1058 | matches.clear() |
|
1053 | 1059 | elif st == 'add': |
|
1054 | 1060 | change = repo.changelog.read(repo.lookup(str(rev))) |
|
1055 | 1061 | mf = repo.manifest.read(change[0]) |
|
1056 | 1062 | matches[rev] = {} |
|
1057 | 1063 | for fn in fns: |
|
1058 | 1064 | if fn in skip: continue |
|
1059 | 1065 | fstate.setdefault(fn, {}) |
|
1060 | 1066 | try: |
|
1061 | 1067 | grepbody(fn, rev, getfile(fn).read(mf[fn])) |
|
1062 | 1068 | except KeyError: |
|
1063 | 1069 | pass |
|
1064 | 1070 | elif st == 'iter': |
|
1065 | 1071 | states = matches[rev].items() |
|
1066 | 1072 | states.sort() |
|
1067 | 1073 | for fn, m in states: |
|
1068 | 1074 | if fn in skip: continue |
|
1069 | 1075 | if incrementing or not opts['all'] or fstate[fn]: |
|
1070 | 1076 | pos, neg = display(fn, rev, m, fstate[fn]) |
|
1071 | 1077 | count += pos + neg |
|
1072 | 1078 | if pos and not opts['all']: |
|
1073 | 1079 | skip[fn] = True |
|
1074 | 1080 | fstate[fn] = m |
|
1075 | 1081 | prev[fn] = rev |
|
1076 | 1082 | |
|
1077 | 1083 | if not incrementing: |
|
1078 | 1084 | fstate = fstate.items() |
|
1079 | 1085 | fstate.sort() |
|
1080 | 1086 | for fn, state in fstate: |
|
1081 | 1087 | if fn in skip: continue |
|
1082 | 1088 | display(fn, rev, {}, state) |
|
1083 | 1089 | return (count == 0 and 1) or 0 |
|
1084 | 1090 | |
|
1085 | 1091 | def heads(ui, repo, **opts): |
|
1086 | 1092 | """show current repository heads""" |
|
1087 | 1093 | heads = repo.changelog.heads() |
|
1088 | 1094 | br = None |
|
1089 | 1095 | if opts['branches']: |
|
1090 | 1096 | br = repo.branchlookup(heads) |
|
1091 | 1097 | for n in repo.changelog.heads(): |
|
1092 | 1098 | show_changeset(ui, repo, changenode=n, brinfo=br) |
|
1093 | 1099 | |
|
1094 | 1100 | def identify(ui, repo): |
|
1095 | 1101 | """print information about the working copy""" |
|
1096 | 1102 | parents = [p for p in repo.dirstate.parents() if p != nullid] |
|
1097 | 1103 | if not parents: |
|
1098 | 1104 | ui.write("unknown\n") |
|
1099 | 1105 | return |
|
1100 | 1106 | |
|
1101 | 1107 | hexfunc = ui.verbose and hex or short |
|
1102 | 1108 | (c, a, d, u) = repo.changes() |
|
1103 | 1109 | output = ["%s%s" % ('+'.join([hexfunc(parent) for parent in parents]), |
|
1104 | 1110 | (c or a or d) and "+" or "")] |
|
1105 | 1111 | |
|
1106 | 1112 | if not ui.quiet: |
|
1107 | 1113 | # multiple tags for a single parent separated by '/' |
|
1108 | 1114 | parenttags = ['/'.join(tags) |
|
1109 | 1115 | for tags in map(repo.nodetags, parents) if tags] |
|
1110 | 1116 | # tags for multiple parents separated by ' + ' |
|
1111 | 1117 | if parenttags: |
|
1112 | 1118 | output.append(' + '.join(parenttags)) |
|
1113 | 1119 | |
|
1114 | 1120 | ui.write("%s\n" % ' '.join(output)) |
|
1115 | 1121 | |
|
1116 | 1122 | def import_(ui, repo, patch1, *patches, **opts): |
|
1117 | 1123 | """import an ordered set of patches""" |
|
1118 | 1124 | patches = (patch1,) + patches |
|
1119 | 1125 | |
|
1120 | 1126 | if not opts['force']: |
|
1121 | 1127 | (c, a, d, u) = repo.changes() |
|
1122 | 1128 | if c or a or d: |
|
1123 | 1129 | raise util.Abort("outstanding uncommitted changes") |
|
1124 | 1130 | |
|
1125 | 1131 | d = opts["base"] |
|
1126 | 1132 | strip = opts["strip"] |
|
1127 | 1133 | |
|
1128 | 1134 | mailre = re.compile(r'(?:From |[\w-]+:)') |
|
1129 | 1135 | diffre = re.compile(r'(?:diff -|--- .*\s+\w+ \w+ +\d+ \d+:\d+:\d+ \d+)') |
|
1130 | 1136 | |
|
1131 | 1137 | for patch in patches: |
|
1132 | 1138 | ui.status("applying %s\n" % patch) |
|
1133 | 1139 | pf = os.path.join(d, patch) |
|
1134 | 1140 | |
|
1135 | 1141 | message = [] |
|
1136 | 1142 | user = None |
|
1137 | 1143 | hgpatch = False |
|
1138 | 1144 | for line in file(pf): |
|
1139 | 1145 | line = line.rstrip() |
|
1140 | 1146 | if (not message and not hgpatch and |
|
1141 | 1147 | mailre.match(line) and not opts['force']): |
|
1142 | 1148 | if len(line) > 35: line = line[:32] + '...' |
|
1143 | 1149 | raise util.Abort('first line looks like a ' |
|
1144 | 1150 | 'mail header: ' + line) |
|
1145 | 1151 | if diffre.match(line): |
|
1146 | 1152 | break |
|
1147 | 1153 | elif hgpatch: |
|
1148 | 1154 | # parse values when importing the result of an hg export |
|
1149 | 1155 | if line.startswith("# User "): |
|
1150 | 1156 | user = line[7:] |
|
1151 | 1157 | ui.debug('User: %s\n' % user) |
|
1152 | 1158 | elif not line.startswith("# ") and line: |
|
1153 | 1159 | message.append(line) |
|
1154 | 1160 | hgpatch = False |
|
1155 | 1161 | elif line == '# HG changeset patch': |
|
1156 | 1162 | hgpatch = True |
|
1157 | 1163 | message = [] # We may have collected garbage |
|
1158 | 1164 | else: |
|
1159 | 1165 | message.append(line) |
|
1160 | 1166 | |
|
1161 | 1167 | # make sure message isn't empty |
|
1162 | 1168 | if not message: |
|
1163 | 1169 | message = "imported patch %s\n" % patch |
|
1164 | 1170 | else: |
|
1165 | 1171 | message = "%s\n" % '\n'.join(message) |
|
1166 | 1172 | ui.debug('message:\n%s\n' % message) |
|
1167 | 1173 | |
|
1168 | 1174 | f = os.popen("patch -p%d < '%s'" % (strip, pf)) |
|
1169 | 1175 | files = [] |
|
1170 | 1176 | for l in f.read().splitlines(): |
|
1171 | 1177 | l.rstrip('\r\n'); |
|
1172 | 1178 | ui.status("%s\n" % l) |
|
1173 | 1179 | if l.startswith('patching file '): |
|
1174 | 1180 | pf = l[14:] |
|
1175 | 1181 | if pf not in files: |
|
1176 | 1182 | files.append(pf) |
|
1177 | 1183 | patcherr = f.close() |
|
1178 | 1184 | if patcherr: |
|
1179 | 1185 | raise util.Abort("patch failed") |
|
1180 | 1186 | |
|
1181 | 1187 | if len(files) > 0: |
|
1182 | 1188 | addremove(ui, repo, *files) |
|
1183 | 1189 | repo.commit(files, message, user) |
|
1184 | 1190 | |
|
1185 | 1191 | def incoming(ui, repo, source="default", **opts): |
|
1186 | 1192 | """show new changesets found in source""" |
|
1187 | 1193 | source = ui.expandpath(source) |
|
1188 | 1194 | other = hg.repository(ui, source) |
|
1189 | 1195 | if not other.local(): |
|
1190 | 1196 | raise util.Abort("incoming doesn't work for remote repositories yet") |
|
1191 | 1197 | o = repo.findincoming(other) |
|
1192 | 1198 | if not o: |
|
1193 | 1199 | return |
|
1194 | 1200 | o = other.newer(o) |
|
1195 | 1201 | o.reverse() |
|
1196 | 1202 | for n in o: |
|
1197 | 1203 | show_changeset(ui, other, changenode=n) |
|
1198 | 1204 | if opts['patch']: |
|
1199 | 1205 | prev = other.changelog.parents(n)[0] |
|
1200 | 1206 | dodiff(ui, ui, other, prev, n) |
|
1201 | 1207 | ui.write("\n") |
|
1202 | 1208 | |
|
1203 | 1209 | def init(ui, dest="."): |
|
1204 | 1210 | """create a new repository in the given directory""" |
|
1205 | 1211 | if not os.path.exists(dest): |
|
1206 | 1212 | os.mkdir(dest) |
|
1207 | 1213 | hg.repository(ui, dest, create=1) |
|
1208 | 1214 | |
|
1209 | 1215 | def locate(ui, repo, *pats, **opts): |
|
1210 | 1216 | """locate files matching specific patterns""" |
|
1211 | 1217 | end = opts['print0'] and '\0' or '\n' |
|
1212 | 1218 | |
|
1213 | 1219 | for src, abs, rel, exact in walk(repo, pats, opts, '(?:.*/|)'): |
|
1214 | 1220 | if repo.dirstate.state(abs) == '?': |
|
1215 | 1221 | continue |
|
1216 | 1222 | if opts['fullpath']: |
|
1217 | 1223 | ui.write(os.path.join(repo.root, abs), end) |
|
1218 | 1224 | else: |
|
1219 | 1225 | ui.write(rel, end) |
|
1220 | 1226 | |
|
1221 | 1227 | def log(ui, repo, *pats, **opts): |
|
1222 | 1228 | """show revision history of entire repository or files""" |
|
1223 | 1229 | class dui: |
|
1224 | 1230 | # Implement and delegate some ui protocol. Save hunks of |
|
1225 | 1231 | # output for later display in the desired order. |
|
1226 | 1232 | def __init__(self, ui): |
|
1227 | 1233 | self.ui = ui |
|
1228 | 1234 | self.hunk = {} |
|
1229 | 1235 | def bump(self, rev): |
|
1230 | 1236 | self.rev = rev |
|
1231 | 1237 | self.hunk[rev] = [] |
|
1232 | 1238 | def note(self, *args): |
|
1233 | 1239 | if self.verbose: |
|
1234 | 1240 | self.write(*args) |
|
1235 | 1241 | def status(self, *args): |
|
1236 | 1242 | if not self.quiet: |
|
1237 | 1243 | self.write(*args) |
|
1238 | 1244 | def write(self, *args): |
|
1239 | 1245 | self.hunk[self.rev].append(args) |
|
1240 | 1246 | def __getattr__(self, key): |
|
1241 | 1247 | return getattr(self.ui, key) |
|
1242 | 1248 | cwd = repo.getcwd() |
|
1243 | 1249 | if not pats and cwd: |
|
1244 | 1250 | opts['include'] = [os.path.join(cwd, i) for i in opts['include']] |
|
1245 | 1251 | opts['exclude'] = [os.path.join(cwd, x) for x in opts['exclude']] |
|
1246 | 1252 | changeiter, getchange = walkchangerevs(ui, repo, (pats and cwd) or '', |
|
1247 | 1253 | pats, opts) |
|
1248 | 1254 | for st, rev, fns in changeiter: |
|
1249 | 1255 | if st == 'window': |
|
1250 | 1256 | du = dui(ui) |
|
1251 | 1257 | elif st == 'add': |
|
1252 | 1258 | du.bump(rev) |
|
1253 | 1259 | br = None |
|
1254 | 1260 | if opts['branch']: |
|
1255 | 1261 | br = repo.branchlookup([repo.changelog.node(rev)]) |
|
1256 | 1262 | show_changeset(du, repo, rev, brinfo=br) |
|
1257 | 1263 | if opts['patch']: |
|
1258 | 1264 | changenode = repo.changelog.node(rev) |
|
1259 | 1265 | prev, other = repo.changelog.parents(changenode) |
|
1260 | 1266 | dodiff(du, du, repo, prev, changenode, fns) |
|
1261 | 1267 | du.write("\n\n") |
|
1262 | 1268 | elif st == 'iter': |
|
1263 | 1269 | for args in du.hunk[rev]: |
|
1264 | 1270 | ui.write(*args) |
|
1265 | 1271 | |
|
1266 | 1272 | def manifest(ui, repo, rev=None): |
|
1267 | 1273 | """output the latest or given revision of the project manifest""" |
|
1268 | 1274 | if rev: |
|
1269 | 1275 | try: |
|
1270 | 1276 | # assume all revision numbers are for changesets |
|
1271 | 1277 | n = repo.lookup(rev) |
|
1272 | 1278 | change = repo.changelog.read(n) |
|
1273 | 1279 | n = change[0] |
|
1274 | 1280 | except hg.RepoError: |
|
1275 | 1281 | n = repo.manifest.lookup(rev) |
|
1276 | 1282 | else: |
|
1277 | 1283 | n = repo.manifest.tip() |
|
1278 | 1284 | m = repo.manifest.read(n) |
|
1279 | 1285 | mf = repo.manifest.readflags(n) |
|
1280 | 1286 | files = m.keys() |
|
1281 | 1287 | files.sort() |
|
1282 | 1288 | |
|
1283 | 1289 | for f in files: |
|
1284 | 1290 | ui.write("%40s %3s %s\n" % (hex(m[f]), mf[f] and "755" or "644", f)) |
|
1285 | 1291 | |
|
1286 | 1292 | def outgoing(ui, repo, dest="default-push", **opts): |
|
1287 | 1293 | """show changesets not found in destination""" |
|
1288 | 1294 | dest = ui.expandpath(dest) |
|
1289 | 1295 | other = hg.repository(ui, dest) |
|
1290 | 1296 | o = repo.findoutgoing(other) |
|
1291 | 1297 | o = repo.newer(o) |
|
1292 | 1298 | o.reverse() |
|
1293 | 1299 | for n in o: |
|
1294 | 1300 | show_changeset(ui, repo, changenode=n) |
|
1295 | 1301 | if opts['patch']: |
|
1296 | 1302 | prev = repo.changelog.parents(n)[0] |
|
1297 | 1303 | dodiff(ui, ui, repo, prev, n) |
|
1298 | 1304 | ui.write("\n") |
|
1299 | 1305 | |
|
1300 | 1306 | def parents(ui, repo, rev=None): |
|
1301 | 1307 | """show the parents of the working dir or revision""" |
|
1302 | 1308 | if rev: |
|
1303 | 1309 | p = repo.changelog.parents(repo.lookup(rev)) |
|
1304 | 1310 | else: |
|
1305 | 1311 | p = repo.dirstate.parents() |
|
1306 | 1312 | |
|
1307 | 1313 | for n in p: |
|
1308 | 1314 | if n != nullid: |
|
1309 | 1315 | show_changeset(ui, repo, changenode=n) |
|
1310 | 1316 | |
|
1311 | 1317 | def paths(ui, search=None): |
|
1312 | 1318 | """show definition of symbolic path names""" |
|
1313 | 1319 | try: |
|
1314 | 1320 | repo = hg.repository(ui=ui) |
|
1315 | 1321 | except hg.RepoError: |
|
1316 | 1322 | pass |
|
1317 | 1323 | |
|
1318 | 1324 | if search: |
|
1319 | 1325 | for name, path in ui.configitems("paths"): |
|
1320 | 1326 | if name == search: |
|
1321 | 1327 | ui.write("%s\n" % path) |
|
1322 | 1328 | return |
|
1323 | 1329 | ui.warn("not found!\n") |
|
1324 | 1330 | return 1 |
|
1325 | 1331 | else: |
|
1326 | 1332 | for name, path in ui.configitems("paths"): |
|
1327 | 1333 | ui.write("%s = %s\n" % (name, path)) |
|
1328 | 1334 | |
|
1329 | 1335 | def pull(ui, repo, source="default", **opts): |
|
1330 | 1336 | """pull changes from the specified source""" |
|
1331 | 1337 | source = ui.expandpath(source) |
|
1332 | 1338 | ui.status('pulling from %s\n' % (source)) |
|
1333 | 1339 | |
|
1334 | 1340 | if opts['ssh']: |
|
1335 | 1341 | ui.setconfig("ui", "ssh", opts['ssh']) |
|
1336 | 1342 | if opts['remotecmd']: |
|
1337 | 1343 | ui.setconfig("ui", "remotecmd", opts['remotecmd']) |
|
1338 | 1344 | |
|
1339 | 1345 | other = hg.repository(ui, source) |
|
1340 | 1346 | r = repo.pull(other) |
|
1341 | 1347 | if not r: |
|
1342 | 1348 | if opts['update']: |
|
1343 | 1349 | return update(ui, repo) |
|
1344 | 1350 | else: |
|
1345 | 1351 | ui.status("(run 'hg update' to get a working copy)\n") |
|
1346 | 1352 | |
|
1347 | 1353 | return r |
|
1348 | 1354 | |
|
1349 | 1355 | def push(ui, repo, dest="default-push", force=False, ssh=None, remotecmd=None): |
|
1350 | 1356 | """push changes to the specified destination""" |
|
1351 | 1357 | dest = ui.expandpath(dest) |
|
1352 | 1358 | ui.status('pushing to %s\n' % (dest)) |
|
1353 | 1359 | |
|
1354 | 1360 | if ssh: |
|
1355 | 1361 | ui.setconfig("ui", "ssh", ssh) |
|
1356 | 1362 | if remotecmd: |
|
1357 | 1363 | ui.setconfig("ui", "remotecmd", remotecmd) |
|
1358 | 1364 | |
|
1359 | 1365 | other = hg.repository(ui, dest) |
|
1360 | 1366 | r = repo.push(other, force) |
|
1361 | 1367 | return r |
|
1362 | 1368 | |
|
1363 | 1369 | def rawcommit(ui, repo, *flist, **rc): |
|
1364 | 1370 | "raw commit interface" |
|
1365 | 1371 | if rc['text']: |
|
1366 | 1372 | ui.warn("Warning: -t and --text is deprecated," |
|
1367 | 1373 | " please use -m or --message instead.\n") |
|
1368 | 1374 | message = rc['message'] or rc['text'] |
|
1369 | 1375 | if not message and rc['logfile']: |
|
1370 | 1376 | try: |
|
1371 | 1377 | message = open(rc['logfile']).read() |
|
1372 | 1378 | except IOError: |
|
1373 | 1379 | pass |
|
1374 | 1380 | if not message and not rc['logfile']: |
|
1375 | 1381 | raise util.Abort("missing commit message") |
|
1376 | 1382 | |
|
1377 | 1383 | files = relpath(repo, list(flist)) |
|
1378 | 1384 | if rc['files']: |
|
1379 | 1385 | files += open(rc['files']).read().splitlines() |
|
1380 | 1386 | |
|
1381 | 1387 | rc['parent'] = map(repo.lookup, rc['parent']) |
|
1382 | 1388 | |
|
1383 | 1389 | try: |
|
1384 | 1390 | repo.rawcommit(files, message, rc['user'], rc['date'], *rc['parent']) |
|
1385 | 1391 | except ValueError, inst: |
|
1386 | 1392 | raise util.Abort(str(inst)) |
|
1387 | 1393 | |
|
1388 | 1394 | def recover(ui, repo): |
|
1389 | 1395 | """roll back an interrupted transaction""" |
|
1390 | 1396 | repo.recover() |
|
1391 | 1397 | |
|
1392 | 1398 | def remove(ui, repo, pat, *pats, **opts): |
|
1393 | 1399 | """remove the specified files on the next commit""" |
|
1394 | 1400 | names = [] |
|
1395 | 1401 | def okaytoremove(abs, rel, exact): |
|
1396 | 1402 | c, a, d, u = repo.changes(files = [abs]) |
|
1397 | 1403 | reason = None |
|
1398 | 1404 | if c: reason = 'is modified' |
|
1399 | 1405 | elif a: reason = 'has been marked for add' |
|
1400 | 1406 | elif u: reason = 'is not managed' |
|
1401 | 1407 | if reason and exact: |
|
1402 | 1408 | ui.warn('not removing %s: file %s\n' % (rel, reason)) |
|
1403 | 1409 | else: |
|
1404 | 1410 | return True |
|
1405 | 1411 | for src, abs, rel, exact in walk(repo, (pat,) + pats, opts): |
|
1406 | 1412 | if okaytoremove(abs, rel, exact): |
|
1407 | 1413 | if ui.verbose or not exact: ui.status('removing %s\n' % rel) |
|
1408 | 1414 | names.append(abs) |
|
1409 | 1415 | for name in names: |
|
1410 | 1416 | try: |
|
1411 | 1417 | os.unlink(name) |
|
1412 | 1418 | except OSError, inst: |
|
1413 | 1419 | if inst.errno != errno.ENOENT: raise |
|
1414 | 1420 | repo.remove(names) |
|
1415 | 1421 | |
|
1416 | 1422 | def rename(ui, repo, *pats, **opts): |
|
1417 | 1423 | """rename files; equivalent of copy + remove""" |
|
1418 | 1424 | errs, copied = docopy(ui, repo, pats, opts) |
|
1419 | 1425 | names = [] |
|
1420 | 1426 | for abs, rel, exact in copied: |
|
1421 | 1427 | if ui.verbose or not exact: ui.status('removing %s\n' % rel) |
|
1422 | 1428 | try: |
|
1423 | 1429 | os.unlink(rel) |
|
1424 | 1430 | except OSError, inst: |
|
1425 | 1431 | if inst.errno != errno.ENOENT: raise |
|
1426 | 1432 | names.append(abs) |
|
1427 | 1433 | repo.remove(names) |
|
1428 | 1434 | return errs |
|
1429 | 1435 | |
|
1430 | 1436 | def revert(ui, repo, *names, **opts): |
|
1431 | 1437 | """revert modified files or dirs back to their unmodified states""" |
|
1432 | 1438 | node = opts['rev'] and repo.lookup(opts['rev']) or \ |
|
1433 | 1439 | repo.dirstate.parents()[0] |
|
1434 | 1440 | root = os.path.realpath(repo.root) |
|
1435 | 1441 | |
|
1436 | 1442 | def trimpath(p): |
|
1437 | 1443 | p = os.path.realpath(p) |
|
1438 | 1444 | if p.startswith(root): |
|
1439 | 1445 | rest = p[len(root):] |
|
1440 | 1446 | if not rest: |
|
1441 | 1447 | return rest |
|
1442 | 1448 | if p.startswith(os.sep): |
|
1443 | 1449 | return rest[1:] |
|
1444 | 1450 | return p |
|
1445 | 1451 | |
|
1446 | 1452 | relnames = map(trimpath, names or [os.getcwd()]) |
|
1447 | 1453 | chosen = {} |
|
1448 | 1454 | |
|
1449 | 1455 | def choose(name): |
|
1450 | 1456 | def body(name): |
|
1451 | 1457 | for r in relnames: |
|
1452 | 1458 | if not name.startswith(r): |
|
1453 | 1459 | continue |
|
1454 | 1460 | rest = name[len(r):] |
|
1455 | 1461 | if not rest: |
|
1456 | 1462 | return r, True |
|
1457 | 1463 | depth = rest.count(os.sep) |
|
1458 | 1464 | if not r: |
|
1459 | 1465 | if depth == 0 or not opts['nonrecursive']: |
|
1460 | 1466 | return r, True |
|
1461 | 1467 | elif rest[0] == os.sep: |
|
1462 | 1468 | if depth == 1 or not opts['nonrecursive']: |
|
1463 | 1469 | return r, True |
|
1464 | 1470 | return None, False |
|
1465 | 1471 | relname, ret = body(name) |
|
1466 | 1472 | if ret: |
|
1467 | 1473 | chosen[relname] = 1 |
|
1468 | 1474 | return ret |
|
1469 | 1475 | |
|
1470 | 1476 | r = repo.update(node, False, True, choose, False) |
|
1471 | 1477 | for n in relnames: |
|
1472 | 1478 | if n not in chosen: |
|
1473 | 1479 | ui.warn('error: no matches for %s\n' % n) |
|
1474 | 1480 | r = 1 |
|
1475 | 1481 | sys.stdout.flush() |
|
1476 | 1482 | return r |
|
1477 | 1483 | |
|
1478 | 1484 | def root(ui, repo): |
|
1479 | 1485 | """print the root (top) of the current working dir""" |
|
1480 | 1486 | ui.write(repo.root + "\n") |
|
1481 | 1487 | |
|
1482 | 1488 | def serve(ui, repo, **opts): |
|
1483 | 1489 | """export the repository via HTTP""" |
|
1484 | 1490 | |
|
1485 | 1491 | if opts["stdio"]: |
|
1486 | 1492 | fin, fout = sys.stdin, sys.stdout |
|
1487 | 1493 | sys.stdout = sys.stderr |
|
1488 | 1494 | |
|
1489 | 1495 | def getarg(): |
|
1490 | 1496 | argline = fin.readline()[:-1] |
|
1491 | 1497 | arg, l = argline.split() |
|
1492 | 1498 | val = fin.read(int(l)) |
|
1493 | 1499 | return arg, val |
|
1494 | 1500 | def respond(v): |
|
1495 | 1501 | fout.write("%d\n" % len(v)) |
|
1496 | 1502 | fout.write(v) |
|
1497 | 1503 | fout.flush() |
|
1498 | 1504 | |
|
1499 | 1505 | lock = None |
|
1500 | 1506 | |
|
1501 | 1507 | while 1: |
|
1502 | 1508 | cmd = fin.readline()[:-1] |
|
1503 | 1509 | if cmd == '': |
|
1504 | 1510 | return |
|
1505 | 1511 | if cmd == "heads": |
|
1506 | 1512 | h = repo.heads() |
|
1507 | 1513 | respond(" ".join(map(hex, h)) + "\n") |
|
1508 | 1514 | if cmd == "lock": |
|
1509 | 1515 | lock = repo.lock() |
|
1510 | 1516 | respond("") |
|
1511 | 1517 | if cmd == "unlock": |
|
1512 | 1518 | if lock: |
|
1513 | 1519 | lock.release() |
|
1514 | 1520 | lock = None |
|
1515 | 1521 | respond("") |
|
1516 | 1522 | elif cmd == "branches": |
|
1517 | 1523 | arg, nodes = getarg() |
|
1518 | 1524 | nodes = map(bin, nodes.split(" ")) |
|
1519 | 1525 | r = [] |
|
1520 | 1526 | for b in repo.branches(nodes): |
|
1521 | 1527 | r.append(" ".join(map(hex, b)) + "\n") |
|
1522 | 1528 | respond("".join(r)) |
|
1523 | 1529 | elif cmd == "between": |
|
1524 | 1530 | arg, pairs = getarg() |
|
1525 | 1531 | pairs = [map(bin, p.split("-")) for p in pairs.split(" ")] |
|
1526 | 1532 | r = [] |
|
1527 | 1533 | for b in repo.between(pairs): |
|
1528 | 1534 | r.append(" ".join(map(hex, b)) + "\n") |
|
1529 | 1535 | respond("".join(r)) |
|
1530 | 1536 | elif cmd == "changegroup": |
|
1531 | 1537 | nodes = [] |
|
1532 | 1538 | arg, roots = getarg() |
|
1533 | 1539 | nodes = map(bin, roots.split(" ")) |
|
1534 | 1540 | |
|
1535 | 1541 | cg = repo.changegroup(nodes) |
|
1536 | 1542 | while 1: |
|
1537 | 1543 | d = cg.read(4096) |
|
1538 | 1544 | if not d: |
|
1539 | 1545 | break |
|
1540 | 1546 | fout.write(d) |
|
1541 | 1547 | |
|
1542 | 1548 | fout.flush() |
|
1543 | 1549 | |
|
1544 | 1550 | elif cmd == "addchangegroup": |
|
1545 | 1551 | if not lock: |
|
1546 | 1552 | respond("not locked") |
|
1547 | 1553 | continue |
|
1548 | 1554 | respond("") |
|
1549 | 1555 | |
|
1550 | 1556 | r = repo.addchangegroup(fin) |
|
1551 | 1557 | respond("") |
|
1552 | 1558 | |
|
1553 | 1559 | optlist = "name templates style address port ipv6 accesslog errorlog" |
|
1554 | 1560 | for o in optlist.split(): |
|
1555 | 1561 | if opts[o]: |
|
1556 | 1562 | ui.setconfig("web", o, opts[o]) |
|
1557 | 1563 | |
|
1558 | 1564 | try: |
|
1559 | 1565 | httpd = hgweb.create_server(repo) |
|
1560 | 1566 | except socket.error, inst: |
|
1561 | 1567 | raise util.Abort('cannot start server: ' + inst.args[1]) |
|
1562 | 1568 | |
|
1563 | 1569 | if ui.verbose: |
|
1564 | 1570 | addr, port = httpd.socket.getsockname() |
|
1565 | 1571 | if addr == '0.0.0.0': |
|
1566 | 1572 | addr = socket.gethostname() |
|
1567 | 1573 | else: |
|
1568 | 1574 | try: |
|
1569 | 1575 | addr = socket.gethostbyaddr(addr)[0] |
|
1570 | 1576 | except socket.error: |
|
1571 | 1577 | pass |
|
1572 | 1578 | if port != 80: |
|
1573 | 1579 | ui.status('listening at http://%s:%d/\n' % (addr, port)) |
|
1574 | 1580 | else: |
|
1575 | 1581 | ui.status('listening at http://%s/\n' % addr) |
|
1576 | 1582 | httpd.serve_forever() |
|
1577 | 1583 | |
|
1578 | 1584 | def status(ui, repo, *pats, **opts): |
|
1579 | 1585 | '''show changed files in the working directory |
|
1580 | 1586 | |
|
1581 | 1587 | M = modified |
|
1582 | 1588 | A = added |
|
1583 | 1589 | R = removed |
|
1584 | 1590 | ? = not tracked |
|
1585 | 1591 | ''' |
|
1586 | 1592 | |
|
1587 | 1593 | cwd = repo.getcwd() |
|
1588 | 1594 | files, matchfn, anypats = matchpats(repo, cwd, pats, opts) |
|
1589 | 1595 | (c, a, d, u) = [[util.pathto(cwd, x) for x in n] |
|
1590 | 1596 | for n in repo.changes(files=files, match=matchfn)] |
|
1591 | 1597 | |
|
1592 | 1598 | changetypes = [('modified', 'M', c), |
|
1593 | 1599 | ('added', 'A', a), |
|
1594 | 1600 | ('removed', 'R', d), |
|
1595 | 1601 | ('unknown', '?', u)] |
|
1596 | 1602 | |
|
1597 | 1603 | end = opts['print0'] and '\0' or '\n' |
|
1598 | 1604 | |
|
1599 | 1605 | for opt, char, changes in ([ct for ct in changetypes if opts[ct[0]]] |
|
1600 | 1606 | or changetypes): |
|
1601 | 1607 | if opts['no_status']: |
|
1602 | 1608 | format = "%%s%s" % end |
|
1603 | 1609 | else: |
|
1604 | 1610 | format = "%s %%s%s" % (char, end); |
|
1605 | 1611 | |
|
1606 | 1612 | for f in changes: |
|
1607 | 1613 | ui.write(format % f) |
|
1608 | 1614 | |
|
1609 | 1615 | def tag(ui, repo, name, rev=None, **opts): |
|
1610 | 1616 | """add a tag for the current tip or a given revision""" |
|
1611 | 1617 | if opts['text']: |
|
1612 | 1618 | ui.warn("Warning: -t and --text is deprecated," |
|
1613 | 1619 | " please use -m or --message instead.\n") |
|
1614 | 1620 | if name == "tip": |
|
1615 | 1621 | raise util.Abort("the name 'tip' is reserved") |
|
1616 | 1622 | if rev: |
|
1617 | 1623 | r = hex(repo.lookup(rev)) |
|
1618 | 1624 | else: |
|
1619 | 1625 | r = hex(repo.changelog.tip()) |
|
1620 | 1626 | |
|
1621 | 1627 | if name.find(revrangesep) >= 0: |
|
1622 | 1628 | raise util.Abort("'%s' cannot be used in a tag name" % revrangesep) |
|
1623 | 1629 | |
|
1624 | 1630 | if opts['local']: |
|
1625 | 1631 | repo.opener("localtags", "a").write("%s %s\n" % (r, name)) |
|
1626 | 1632 | return |
|
1627 | 1633 | |
|
1628 | 1634 | (c, a, d, u) = repo.changes() |
|
1629 | 1635 | for x in (c, a, d, u): |
|
1630 | 1636 | if ".hgtags" in x: |
|
1631 | 1637 | raise util.Abort("working copy of .hgtags is changed " |
|
1632 | 1638 | "(please commit .hgtags manually)") |
|
1633 | 1639 | |
|
1634 | 1640 | repo.wfile(".hgtags", "ab").write("%s %s\n" % (r, name)) |
|
1635 | 1641 | if repo.dirstate.state(".hgtags") == '?': |
|
1636 | 1642 | repo.add([".hgtags"]) |
|
1637 | 1643 | |
|
1638 | 1644 | message = (opts['message'] or opts['text'] or |
|
1639 | 1645 | "Added tag %s for changeset %s" % (name, r)) |
|
1640 | 1646 | try: |
|
1641 | 1647 | repo.commit([".hgtags"], message, opts['user'], opts['date']) |
|
1642 | 1648 | except ValueError, inst: |
|
1643 | 1649 | raise util.Abort(str(inst)) |
|
1644 | 1650 | |
|
1645 | 1651 | def tags(ui, repo): |
|
1646 | 1652 | """list repository tags""" |
|
1647 | 1653 | |
|
1648 | 1654 | l = repo.tagslist() |
|
1649 | 1655 | l.reverse() |
|
1650 | 1656 | for t, n in l: |
|
1651 | 1657 | try: |
|
1652 | 1658 | r = "%5d:%s" % (repo.changelog.rev(n), hex(n)) |
|
1653 | 1659 | except KeyError: |
|
1654 | 1660 | r = " ?:?" |
|
1655 | 1661 | ui.write("%-30s %s\n" % (t, r)) |
|
1656 | 1662 | |
|
1657 | 1663 | def tip(ui, repo): |
|
1658 | 1664 | """show the tip revision""" |
|
1659 | 1665 | n = repo.changelog.tip() |
|
1660 | 1666 | show_changeset(ui, repo, changenode=n) |
|
1661 | 1667 | |
|
1662 | 1668 | def unbundle(ui, repo, fname): |
|
1663 | 1669 | """apply a changegroup file""" |
|
1664 | 1670 | f = urllib.urlopen(fname) |
|
1665 | 1671 | |
|
1666 | 1672 | if f.read(4) != "HG10": |
|
1667 | 1673 | raise util.Abort("%s: not a Mercurial bundle file" % fname) |
|
1668 | 1674 | |
|
1669 | 1675 | class bzread: |
|
1670 | 1676 | def __init__(self, f): |
|
1671 | 1677 | self.zd = bz2.BZ2Decompressor() |
|
1672 | 1678 | self.f = f |
|
1673 | 1679 | self.buf = "" |
|
1674 | 1680 | def read(self, l): |
|
1675 | 1681 | while l > len(self.buf): |
|
1676 | 1682 | r = self.f.read(4096) |
|
1677 | 1683 | if r: |
|
1678 | 1684 | self.buf += self.zd.decompress(r) |
|
1679 | 1685 | else: |
|
1680 | 1686 | break |
|
1681 | 1687 | d, self.buf = self.buf[:l], self.buf[l:] |
|
1682 | 1688 | return d |
|
1683 | 1689 | |
|
1684 | 1690 | repo.addchangegroup(bzread(f)) |
|
1685 | 1691 | |
|
1686 | 1692 | def undo(ui, repo): |
|
1687 | 1693 | """undo the last commit or pull |
|
1688 | 1694 | |
|
1689 | 1695 | Roll back the last pull or commit transaction on the |
|
1690 | 1696 | repository, restoring the project to its earlier state. |
|
1691 | 1697 | |
|
1692 | 1698 | This command should be used with care. There is only one level of |
|
1693 | 1699 | undo and there is no redo. |
|
1694 | 1700 | |
|
1695 | 1701 | This command is not intended for use on public repositories. Once |
|
1696 | 1702 | a change is visible for pull by other users, undoing it locally is |
|
1697 | 1703 | ineffective. |
|
1698 | 1704 | """ |
|
1699 | 1705 | repo.undo() |
|
1700 | 1706 | |
|
1701 | 1707 | def update(ui, repo, node=None, merge=False, clean=False, branch=None): |
|
1702 | 1708 | '''update or merge working directory |
|
1703 | 1709 | |
|
1704 | 1710 | If there are no outstanding changes in the working directory and |
|
1705 | 1711 | there is a linear relationship between the current version and the |
|
1706 | 1712 | requested version, the result is the requested version. |
|
1707 | 1713 | |
|
1708 | 1714 | Otherwise the result is a merge between the contents of the |
|
1709 | 1715 | current working directory and the requested version. Files that |
|
1710 | 1716 | changed between either parent are marked as changed for the next |
|
1711 | 1717 | commit and a commit must be performed before any further updates |
|
1712 | 1718 | are allowed. |
|
1713 | 1719 | ''' |
|
1714 | 1720 | if branch: |
|
1715 | 1721 | br = repo.branchlookup(branch=branch) |
|
1716 | 1722 | found = [] |
|
1717 | 1723 | for x in br: |
|
1718 | 1724 | if branch in br[x]: |
|
1719 | 1725 | found.append(x) |
|
1720 | 1726 | if len(found) > 1: |
|
1721 | 1727 | ui.warn("Found multiple heads for %s\n" % branch) |
|
1722 | 1728 | for x in found: |
|
1723 | 1729 | show_changeset(ui, repo, changenode=x, brinfo=br) |
|
1724 | 1730 | return 1 |
|
1725 | 1731 | if len(found) == 1: |
|
1726 | 1732 | node = found[0] |
|
1727 | 1733 | ui.warn("Using head %s for branch %s\n" % (short(node), branch)) |
|
1728 | 1734 | else: |
|
1729 | 1735 | ui.warn("branch %s not found\n" % (branch)) |
|
1730 | 1736 | return 1 |
|
1731 | 1737 | else: |
|
1732 | 1738 | node = node and repo.lookup(node) or repo.changelog.tip() |
|
1733 | 1739 | return repo.update(node, allow=merge, force=clean) |
|
1734 | 1740 | |
|
1735 | 1741 | def verify(ui, repo): |
|
1736 | 1742 | """verify the integrity of the repository""" |
|
1737 | 1743 | return repo.verify() |
|
1738 | 1744 | |
|
1739 | 1745 | # Command options and aliases are listed here, alphabetically |
|
1740 | 1746 | |
|
1741 | 1747 | table = { |
|
1742 | 1748 | "^add": |
|
1743 | 1749 | (add, |
|
1744 | 1750 | [('I', 'include', [], 'include path in search'), |
|
1745 | 1751 | ('X', 'exclude', [], 'exclude path from search')], |
|
1746 | 1752 | "hg add [OPTION]... [FILE]..."), |
|
1747 | 1753 | "addremove": |
|
1748 | 1754 | (addremove, |
|
1749 | 1755 | [('I', 'include', [], 'include path in search'), |
|
1750 | 1756 | ('X', 'exclude', [], 'exclude path from search')], |
|
1751 | 1757 | "hg addremove [OPTION]... [FILE]..."), |
|
1752 | 1758 | "^annotate": |
|
1753 | 1759 | (annotate, |
|
1754 | 1760 | [('r', 'rev', '', 'revision'), |
|
1755 | 1761 | ('a', 'text', None, 'treat all files as text'), |
|
1756 | 1762 | ('u', 'user', None, 'show user'), |
|
1757 | 1763 | ('n', 'number', None, 'show revision number'), |
|
1758 | 1764 | ('c', 'changeset', None, 'show changeset'), |
|
1759 | 1765 | ('I', 'include', [], 'include path in search'), |
|
1760 | 1766 | ('X', 'exclude', [], 'exclude path from search')], |
|
1761 | 1767 | 'hg annotate [OPTION]... FILE...'), |
|
1762 | 1768 | "bundle": |
|
1763 | 1769 | (bundle, |
|
1764 | 1770 | [], |
|
1765 | 1771 | 'hg bundle FILE DEST'), |
|
1766 | 1772 | "cat": |
|
1767 | 1773 | (cat, |
|
1768 | [('o', 'output', "", 'output to file')], | |
|
1769 | 'hg cat [-o OUTFILE] FILE [REV]'), | |
|
1774 | [('I', 'include', [], 'include path in search'), | |
|
1775 | ('X', 'exclude', [], 'exclude path from search'), | |
|
1776 | ('o', 'output', "", 'output to file'), | |
|
1777 | ('r', 'rev', '', 'revision')], | |
|
1778 | 'hg cat [OPTION]... FILE...'), | |
|
1770 | 1779 | "^clone": |
|
1771 | 1780 | (clone, |
|
1772 | 1781 | [('U', 'noupdate', None, 'skip update after cloning'), |
|
1773 | 1782 | ('e', 'ssh', "", 'ssh command'), |
|
1774 | 1783 | ('', 'remotecmd', "", 'remote hg command')], |
|
1775 | 1784 | 'hg clone [OPTION]... SOURCE [DEST]'), |
|
1776 | 1785 | "^commit|ci": |
|
1777 | 1786 | (commit, |
|
1778 | 1787 | [('A', 'addremove', None, 'run add/remove during commit'), |
|
1779 | 1788 | ('I', 'include', [], 'include path in search'), |
|
1780 | 1789 | ('X', 'exclude', [], 'exclude path from search'), |
|
1781 | 1790 | ('m', 'message', "", 'commit message'), |
|
1782 | 1791 | ('t', 'text', "", 'commit message (deprecated: use -m)'), |
|
1783 | 1792 | ('l', 'logfile', "", 'commit message file'), |
|
1784 | 1793 | ('d', 'date', "", 'date code'), |
|
1785 | 1794 | ('u', 'user', "", 'user')], |
|
1786 | 1795 | 'hg commit [OPTION]... [FILE]...'), |
|
1787 | 1796 | "copy|cp": (copy, |
|
1788 | 1797 | [('I', 'include', [], 'include path in search'), |
|
1789 | 1798 | ('X', 'exclude', [], 'exclude path from search'), |
|
1790 | 1799 | ('A', 'after', None, 'record a copy after it has happened'), |
|
1791 | 1800 | ('f', 'force', None, 'replace destination if it exists'), |
|
1792 | 1801 | ('p', 'parents', None, 'append source path to dest')], |
|
1793 | 1802 | 'hg copy [OPTION]... [SOURCE]... DEST'), |
|
1794 | 1803 | "debugcheckstate": (debugcheckstate, [], 'debugcheckstate'), |
|
1795 | 1804 | "debugconfig": (debugconfig, [], 'debugconfig'), |
|
1796 | 1805 | "debugstate": (debugstate, [], 'debugstate'), |
|
1797 | 1806 | "debugdata": (debugdata, [], 'debugdata FILE REV'), |
|
1798 | 1807 | "debugindex": (debugindex, [], 'debugindex FILE'), |
|
1799 | 1808 | "debugindexdot": (debugindexdot, [], 'debugindexdot FILE'), |
|
1800 | 1809 | "debugrename": (debugrename, [], 'debugrename FILE [REV]'), |
|
1801 | 1810 | "debugwalk": |
|
1802 | 1811 | (debugwalk, |
|
1803 | 1812 | [('I', 'include', [], 'include path in search'), |
|
1804 | 1813 | ('X', 'exclude', [], 'exclude path from search')], |
|
1805 | 1814 | 'debugwalk [OPTION]... [FILE]...'), |
|
1806 | 1815 | "^diff": |
|
1807 | 1816 | (diff, |
|
1808 | 1817 | [('r', 'rev', [], 'revision'), |
|
1809 | 1818 | ('a', 'text', None, 'treat all files as text'), |
|
1810 | 1819 | ('I', 'include', [], 'include path in search'), |
|
1811 | 1820 | ('X', 'exclude', [], 'exclude path from search')], |
|
1812 | 1821 | 'hg diff [-a] [-I] [-X] [-r REV1 [-r REV2]] [FILE]...'), |
|
1813 | 1822 | "^export": |
|
1814 | 1823 | (export, |
|
1815 | 1824 | [('o', 'output', "", 'output to file'), |
|
1816 | 1825 | ('a', 'text', None, 'treat all files as text')], |
|
1817 | 1826 | "hg export [-a] [-o OUTFILE] REV..."), |
|
1818 | 1827 | "forget": |
|
1819 | 1828 | (forget, |
|
1820 | 1829 | [('I', 'include', [], 'include path in search'), |
|
1821 | 1830 | ('X', 'exclude', [], 'exclude path from search')], |
|
1822 | 1831 | "hg forget [OPTION]... FILE..."), |
|
1823 | 1832 | "grep": |
|
1824 | 1833 | (grep, |
|
1825 | 1834 | [('0', 'print0', None, 'end fields with NUL'), |
|
1826 | 1835 | ('I', 'include', [], 'include path in search'), |
|
1827 | 1836 | ('X', 'exclude', [], 'include path in search'), |
|
1828 | 1837 | ('', 'all', None, 'print all revisions with matches'), |
|
1829 | 1838 | ('i', 'ignore-case', None, 'ignore case when matching'), |
|
1830 | 1839 | ('l', 'files-with-matches', None, 'print names of files and revs with matches'), |
|
1831 | 1840 | ('n', 'line-number', None, 'print line numbers'), |
|
1832 | 1841 | ('r', 'rev', [], 'search in revision rev'), |
|
1833 | 1842 | ('u', 'user', None, 'print user who made change')], |
|
1834 | 1843 | "hg grep [OPTION]... PATTERN [FILE]..."), |
|
1835 | 1844 | "heads": |
|
1836 | 1845 | (heads, |
|
1837 | 1846 | [('b', 'branches', None, 'find branch info')], |
|
1838 | 1847 | 'hg heads [-b]'), |
|
1839 | 1848 | "help": (help_, [], 'hg help [COMMAND]'), |
|
1840 | 1849 | "identify|id": (identify, [], 'hg identify'), |
|
1841 | 1850 | "import|patch": |
|
1842 | 1851 | (import_, |
|
1843 | 1852 | [('p', 'strip', 1, 'path strip'), |
|
1844 | 1853 | ('f', 'force', None, 'skip check for outstanding changes'), |
|
1845 | 1854 | ('b', 'base', "", 'base path')], |
|
1846 | 1855 | "hg import [-f] [-p NUM] [-b BASE] PATCH..."), |
|
1847 | 1856 | "incoming|in": (incoming, |
|
1848 | 1857 | [('p', 'patch', None, 'show patch')], |
|
1849 | 1858 | 'hg incoming [-p] [SOURCE]'), |
|
1850 | 1859 | "^init": (init, [], 'hg init [DEST]'), |
|
1851 | 1860 | "locate": |
|
1852 | 1861 | (locate, |
|
1853 | 1862 | [('r', 'rev', '', 'revision'), |
|
1854 | 1863 | ('0', 'print0', None, 'end filenames with NUL'), |
|
1855 | 1864 | ('f', 'fullpath', None, 'print complete paths'), |
|
1856 | 1865 | ('I', 'include', [], 'include path in search'), |
|
1857 | 1866 | ('X', 'exclude', [], 'exclude path from search')], |
|
1858 | 1867 | 'hg locate [OPTION]... [PATTERN]...'), |
|
1859 | 1868 | "^log|history": |
|
1860 | 1869 | (log, |
|
1861 | 1870 | [('I', 'include', [], 'include path in search'), |
|
1862 | 1871 | ('X', 'exclude', [], 'exclude path from search'), |
|
1863 | 1872 | ('b', 'branch', None, 'show branches'), |
|
1864 | 1873 | ('r', 'rev', [], 'revision'), |
|
1865 | 1874 | ('p', 'patch', None, 'show patch')], |
|
1866 | 1875 | 'hg log [-I] [-X] [-r REV]... [-p] [FILE]'), |
|
1867 | 1876 | "manifest": (manifest, [], 'hg manifest [REV]'), |
|
1868 | 1877 | "outgoing|out": (outgoing, |
|
1869 | 1878 | [('p', 'patch', None, 'show patch')], |
|
1870 | 1879 | 'hg outgoing [-p] [DEST]'), |
|
1871 | 1880 | "parents": (parents, [], 'hg parents [REV]'), |
|
1872 | 1881 | "paths": (paths, [], 'hg paths [NAME]'), |
|
1873 | 1882 | "^pull": |
|
1874 | 1883 | (pull, |
|
1875 | 1884 | [('u', 'update', None, 'update working directory'), |
|
1876 | 1885 | ('e', 'ssh', "", 'ssh command'), |
|
1877 | 1886 | ('', 'remotecmd', "", 'remote hg command')], |
|
1878 | 1887 | 'hg pull [-u] [-e FILE] [--remotecmd FILE] [SOURCE]'), |
|
1879 | 1888 | "^push": |
|
1880 | 1889 | (push, |
|
1881 | 1890 | [('f', 'force', None, 'force push'), |
|
1882 | 1891 | ('e', 'ssh', "", 'ssh command'), |
|
1883 | 1892 | ('', 'remotecmd', "", 'remote hg command')], |
|
1884 | 1893 | 'hg push [-f] [-e FILE] [--remotecmd FILE] [DEST]'), |
|
1885 | 1894 | "rawcommit": |
|
1886 | 1895 | (rawcommit, |
|
1887 | 1896 | [('p', 'parent', [], 'parent'), |
|
1888 | 1897 | ('d', 'date', "", 'date code'), |
|
1889 | 1898 | ('u', 'user', "", 'user'), |
|
1890 | 1899 | ('F', 'files', "", 'file list'), |
|
1891 | 1900 | ('m', 'message', "", 'commit message'), |
|
1892 | 1901 | ('t', 'text', "", 'commit message (deprecated: use -m)'), |
|
1893 | 1902 | ('l', 'logfile', "", 'commit message file')], |
|
1894 | 1903 | 'hg rawcommit [OPTION]... [FILE]...'), |
|
1895 | 1904 | "recover": (recover, [], "hg recover"), |
|
1896 | 1905 | "^remove|rm": (remove, |
|
1897 | 1906 | [('I', 'include', [], 'include path in search'), |
|
1898 | 1907 | ('X', 'exclude', [], 'exclude path from search')], |
|
1899 | 1908 | "hg remove [OPTION]... FILE..."), |
|
1900 | 1909 | "rename|mv": (rename, |
|
1901 | 1910 | [('I', 'include', [], 'include path in search'), |
|
1902 | 1911 | ('X', 'exclude', [], 'exclude path from search'), |
|
1903 | 1912 | ('A', 'after', None, 'record a copy after it has happened'), |
|
1904 | 1913 | ('f', 'force', None, 'replace destination if it exists'), |
|
1905 | 1914 | ('p', 'parents', None, 'append source path to dest')], |
|
1906 | 1915 | 'hg rename [OPTION]... [SOURCE]... DEST'), |
|
1907 | 1916 | "^revert": |
|
1908 | 1917 | (revert, |
|
1909 | 1918 | [("n", "nonrecursive", None, "don't recurse into subdirs"), |
|
1910 | 1919 | ("r", "rev", "", "revision")], |
|
1911 | 1920 | "hg revert [-n] [-r REV] [NAME]..."), |
|
1912 | 1921 | "root": (root, [], "hg root"), |
|
1913 | 1922 | "^serve": |
|
1914 | 1923 | (serve, |
|
1915 | 1924 | [('A', 'accesslog', '', 'access log file'), |
|
1916 | 1925 | ('E', 'errorlog', '', 'error log file'), |
|
1917 | 1926 | ('p', 'port', 0, 'listen port'), |
|
1918 | 1927 | ('a', 'address', '', 'interface address'), |
|
1919 | 1928 | ('n', 'name', "", 'repository name'), |
|
1920 | 1929 | ('', 'stdio', None, 'for remote clients'), |
|
1921 | 1930 | ('t', 'templates', "", 'template directory'), |
|
1922 | 1931 | ('', 'style', "", 'template style'), |
|
1923 | 1932 | ('6', 'ipv6', None, 'use IPv6 in addition to IPv4')], |
|
1924 | 1933 | "hg serve [OPTION]..."), |
|
1925 | 1934 | "^status": |
|
1926 | 1935 | (status, |
|
1927 | 1936 | [('m', 'modified', None, 'show only modified files'), |
|
1928 | 1937 | ('a', 'added', None, 'show only added files'), |
|
1929 | 1938 | ('r', 'removed', None, 'show only removed files'), |
|
1930 | 1939 | ('u', 'unknown', None, 'show only unknown (not tracked) files'), |
|
1931 | 1940 | ('n', 'no-status', None, 'hide status prefix'), |
|
1932 | 1941 | ('0', 'print0', None, 'end filenames with NUL'), |
|
1933 | 1942 | ('I', 'include', [], 'include path in search'), |
|
1934 | 1943 | ('X', 'exclude', [], 'exclude path from search')], |
|
1935 | 1944 | "hg status [OPTION]... [FILE]..."), |
|
1936 | 1945 | "tag": |
|
1937 | 1946 | (tag, |
|
1938 | 1947 | [('l', 'local', None, 'make the tag local'), |
|
1939 | 1948 | ('m', 'message', "", 'commit message'), |
|
1940 | 1949 | ('t', 'text', "", 'commit message (deprecated: use -m)'), |
|
1941 | 1950 | ('d', 'date', "", 'date code'), |
|
1942 | 1951 | ('u', 'user', "", 'user')], |
|
1943 | 1952 | 'hg tag [OPTION]... NAME [REV]'), |
|
1944 | 1953 | "tags": (tags, [], 'hg tags'), |
|
1945 | 1954 | "tip": (tip, [], 'hg tip'), |
|
1946 | 1955 | "unbundle": |
|
1947 | 1956 | (unbundle, |
|
1948 | 1957 | [], |
|
1949 | 1958 | 'hg unbundle FILE'), |
|
1950 | 1959 | "undo": (undo, [], 'hg undo'), |
|
1951 | 1960 | "^update|up|checkout|co": |
|
1952 | 1961 | (update, |
|
1953 | 1962 | [('b', 'branch', "", 'checkout the head of a specific branch'), |
|
1954 | 1963 | ('m', 'merge', None, 'allow merging of conflicts'), |
|
1955 | 1964 | ('C', 'clean', None, 'overwrite locally modified files')], |
|
1956 | 1965 | 'hg update [-b TAG] [-m] [-C] [REV]'), |
|
1957 | 1966 | "verify": (verify, [], 'hg verify'), |
|
1958 | 1967 | "version": (show_version, [], 'hg version'), |
|
1959 | 1968 | } |
|
1960 | 1969 | |
|
1961 | 1970 | globalopts = [ |
|
1962 | 1971 | ('R', 'repository', "", 'repository root directory'), |
|
1963 | 1972 | ('', 'cwd', '', 'change working directory'), |
|
1964 | 1973 | ('y', 'noninteractive', None, 'run non-interactively'), |
|
1965 | 1974 | ('q', 'quiet', None, 'quiet mode'), |
|
1966 | 1975 | ('v', 'verbose', None, 'verbose mode'), |
|
1967 | 1976 | ('', 'debug', None, 'debug mode'), |
|
1968 | 1977 | ('', 'debugger', None, 'start debugger'), |
|
1969 | 1978 | ('', 'traceback', None, 'print traceback on exception'), |
|
1970 | 1979 | ('', 'time', None, 'time how long the command takes'), |
|
1971 | 1980 | ('', 'profile', None, 'profile'), |
|
1972 | 1981 | ('', 'version', None, 'output version information and exit'), |
|
1973 | 1982 | ('h', 'help', None, 'display help and exit'), |
|
1974 | 1983 | ] |
|
1975 | 1984 | |
|
1976 | 1985 | norepo = ("clone init version help debugconfig debugdata" |
|
1977 | 1986 | " debugindex debugindexdot paths") |
|
1978 | 1987 | |
|
1979 | 1988 | def find(cmd): |
|
1980 | 1989 | for e in table.keys(): |
|
1981 | 1990 | if re.match("(%s)$" % e, cmd): |
|
1982 | 1991 | return e, table[e] |
|
1983 | 1992 | |
|
1984 | 1993 | raise UnknownCommand(cmd) |
|
1985 | 1994 | |
|
1986 | 1995 | class SignalInterrupt(Exception): |
|
1987 | 1996 | """Exception raised on SIGTERM and SIGHUP.""" |
|
1988 | 1997 | |
|
1989 | 1998 | def catchterm(*args): |
|
1990 | 1999 | raise SignalInterrupt |
|
1991 | 2000 | |
|
1992 | 2001 | def run(): |
|
1993 | 2002 | sys.exit(dispatch(sys.argv[1:])) |
|
1994 | 2003 | |
|
1995 | 2004 | class ParseError(Exception): |
|
1996 | 2005 | """Exception raised on errors in parsing the command line.""" |
|
1997 | 2006 | |
|
1998 | 2007 | def parse(args): |
|
1999 | 2008 | options = {} |
|
2000 | 2009 | cmdoptions = {} |
|
2001 | 2010 | |
|
2002 | 2011 | try: |
|
2003 | 2012 | args = fancyopts.fancyopts(args, globalopts, options) |
|
2004 | 2013 | except fancyopts.getopt.GetoptError, inst: |
|
2005 | 2014 | raise ParseError(None, inst) |
|
2006 | 2015 | |
|
2007 | 2016 | if args: |
|
2008 | 2017 | cmd, args = args[0], args[1:] |
|
2009 | 2018 | i = find(cmd)[1] |
|
2010 | 2019 | c = list(i[1]) |
|
2011 | 2020 | else: |
|
2012 | 2021 | cmd = None |
|
2013 | 2022 | c = [] |
|
2014 | 2023 | |
|
2015 | 2024 | # combine global options into local |
|
2016 | 2025 | for o in globalopts: |
|
2017 | 2026 | c.append((o[0], o[1], options[o[1]], o[3])) |
|
2018 | 2027 | |
|
2019 | 2028 | try: |
|
2020 | 2029 | args = fancyopts.fancyopts(args, c, cmdoptions) |
|
2021 | 2030 | except fancyopts.getopt.GetoptError, inst: |
|
2022 | 2031 | raise ParseError(cmd, inst) |
|
2023 | 2032 | |
|
2024 | 2033 | # separate global options back out |
|
2025 | 2034 | for o in globalopts: |
|
2026 | 2035 | n = o[1] |
|
2027 | 2036 | options[n] = cmdoptions[n] |
|
2028 | 2037 | del cmdoptions[n] |
|
2029 | 2038 | |
|
2030 | 2039 | return (cmd, cmd and i[0] or None, args, options, cmdoptions) |
|
2031 | 2040 | |
|
2032 | 2041 | def dispatch(args): |
|
2033 | 2042 | signal.signal(signal.SIGTERM, catchterm) |
|
2034 | 2043 | try: |
|
2035 | 2044 | signal.signal(signal.SIGHUP, catchterm) |
|
2036 | 2045 | except AttributeError: |
|
2037 | 2046 | pass |
|
2038 | 2047 | |
|
2039 | 2048 | u = ui.ui() |
|
2040 | 2049 | external = [] |
|
2041 | 2050 | for x in u.extensions(): |
|
2042 | 2051 | if x[1]: |
|
2043 | 2052 | mod = imp.load_source(x[0], x[1]) |
|
2044 | 2053 | else: |
|
2045 | 2054 | def importh(name): |
|
2046 | 2055 | mod = __import__(name) |
|
2047 | 2056 | components = name.split('.') |
|
2048 | 2057 | for comp in components[1:]: |
|
2049 | 2058 | mod = getattr(mod, comp) |
|
2050 | 2059 | return mod |
|
2051 | 2060 | mod = importh(x[0]) |
|
2052 | 2061 | external.append(mod) |
|
2053 | 2062 | for x in external: |
|
2054 | 2063 | for t in x.cmdtable: |
|
2055 | 2064 | if t in table: |
|
2056 | 2065 | u.warn("module %s override %s\n" % (x.__name__, t)) |
|
2057 | 2066 | table.update(x.cmdtable) |
|
2058 | 2067 | |
|
2059 | 2068 | try: |
|
2060 | 2069 | cmd, func, args, options, cmdoptions = parse(args) |
|
2061 | 2070 | except ParseError, inst: |
|
2062 | 2071 | if inst.args[0]: |
|
2063 | 2072 | u.warn("hg %s: %s\n" % (inst.args[0], inst.args[1])) |
|
2064 | 2073 | help_(u, inst.args[0]) |
|
2065 | 2074 | else: |
|
2066 | 2075 | u.warn("hg: %s\n" % inst.args[1]) |
|
2067 | 2076 | help_(u, 'shortlist') |
|
2068 | 2077 | sys.exit(-1) |
|
2069 | 2078 | except UnknownCommand, inst: |
|
2070 | 2079 | u.warn("hg: unknown command '%s'\n" % inst.args[0]) |
|
2071 | 2080 | help_(u, 'shortlist') |
|
2072 | 2081 | sys.exit(1) |
|
2073 | 2082 | |
|
2074 | 2083 | if options["time"]: |
|
2075 | 2084 | def get_times(): |
|
2076 | 2085 | t = os.times() |
|
2077 | 2086 | if t[4] == 0.0: # Windows leaves this as zero, so use time.clock() |
|
2078 | 2087 | t = (t[0], t[1], t[2], t[3], time.clock()) |
|
2079 | 2088 | return t |
|
2080 | 2089 | s = get_times() |
|
2081 | 2090 | def print_time(): |
|
2082 | 2091 | t = get_times() |
|
2083 | 2092 | u.warn("Time: real %.3f secs (user %.3f+%.3f sys %.3f+%.3f)\n" % |
|
2084 | 2093 | (t[4]-s[4], t[0]-s[0], t[2]-s[2], t[1]-s[1], t[3]-s[3])) |
|
2085 | 2094 | atexit.register(print_time) |
|
2086 | 2095 | |
|
2087 | 2096 | u.updateopts(options["verbose"], options["debug"], options["quiet"], |
|
2088 | 2097 | not options["noninteractive"]) |
|
2089 | 2098 | |
|
2090 | 2099 | # enter the debugger before command execution |
|
2091 | 2100 | if options['debugger']: |
|
2092 | 2101 | pdb.set_trace() |
|
2093 | 2102 | |
|
2094 | 2103 | try: |
|
2095 | 2104 | try: |
|
2096 | 2105 | if options['help']: |
|
2097 | 2106 | help_(u, cmd, options['version']) |
|
2098 | 2107 | sys.exit(0) |
|
2099 | 2108 | elif options['version']: |
|
2100 | 2109 | show_version(u) |
|
2101 | 2110 | sys.exit(0) |
|
2102 | 2111 | elif not cmd: |
|
2103 | 2112 | help_(u, 'shortlist') |
|
2104 | 2113 | sys.exit(0) |
|
2105 | 2114 | |
|
2106 | 2115 | if options['cwd']: |
|
2107 | 2116 | try: |
|
2108 | 2117 | os.chdir(options['cwd']) |
|
2109 | 2118 | except OSError, inst: |
|
2110 | 2119 | raise util.Abort('%s: %s' % |
|
2111 | 2120 | (options['cwd'], inst.strerror)) |
|
2112 | 2121 | |
|
2113 | 2122 | if cmd not in norepo.split(): |
|
2114 | 2123 | path = options["repository"] or "" |
|
2115 | 2124 | repo = hg.repository(ui=u, path=path) |
|
2116 | 2125 | for x in external: |
|
2117 | 2126 | x.reposetup(u, repo) |
|
2118 | 2127 | d = lambda: func(u, repo, *args, **cmdoptions) |
|
2119 | 2128 | else: |
|
2120 | 2129 | d = lambda: func(u, *args, **cmdoptions) |
|
2121 | 2130 | |
|
2122 | 2131 | if options['profile']: |
|
2123 | 2132 | import hotshot, hotshot.stats |
|
2124 | 2133 | prof = hotshot.Profile("hg.prof") |
|
2125 | 2134 | r = prof.runcall(d) |
|
2126 | 2135 | prof.close() |
|
2127 | 2136 | stats = hotshot.stats.load("hg.prof") |
|
2128 | 2137 | stats.strip_dirs() |
|
2129 | 2138 | stats.sort_stats('time', 'calls') |
|
2130 | 2139 | stats.print_stats(40) |
|
2131 | 2140 | return r |
|
2132 | 2141 | else: |
|
2133 | 2142 | return d() |
|
2134 | 2143 | except: |
|
2135 | 2144 | # enter the debugger when we hit an exception |
|
2136 | 2145 | if options['debugger']: |
|
2137 | 2146 | pdb.post_mortem(sys.exc_info()[2]) |
|
2138 | 2147 | if options['traceback']: |
|
2139 | 2148 | traceback.print_exc() |
|
2140 | 2149 | raise |
|
2141 | 2150 | except hg.RepoError, inst: |
|
2142 | 2151 | u.warn("abort: ", inst, "!\n") |
|
2143 | 2152 | except revlog.RevlogError, inst: |
|
2144 | 2153 | u.warn("abort: ", inst, "!\n") |
|
2145 | 2154 | except SignalInterrupt: |
|
2146 | 2155 | u.warn("killed!\n") |
|
2147 | 2156 | except KeyboardInterrupt: |
|
2148 | 2157 | try: |
|
2149 | 2158 | u.warn("interrupted!\n") |
|
2150 | 2159 | except IOError, inst: |
|
2151 | 2160 | if inst.errno == errno.EPIPE: |
|
2152 | 2161 | if u.debugflag: |
|
2153 | 2162 | u.warn("\nbroken pipe\n") |
|
2154 | 2163 | else: |
|
2155 | 2164 | raise |
|
2156 | 2165 | except IOError, inst: |
|
2157 | 2166 | if hasattr(inst, "code"): |
|
2158 | 2167 | u.warn("abort: %s\n" % inst) |
|
2159 | 2168 | elif hasattr(inst, "reason"): |
|
2160 | 2169 | u.warn("abort: error: %s\n" % inst.reason[1]) |
|
2161 | 2170 | elif hasattr(inst, "args") and inst[0] == errno.EPIPE: |
|
2162 | 2171 | if u.debugflag: |
|
2163 | 2172 | u.warn("broken pipe\n") |
|
2164 | 2173 | else: |
|
2165 | 2174 | raise |
|
2166 | 2175 | except OSError, inst: |
|
2167 | 2176 | if hasattr(inst, "filename"): |
|
2168 | 2177 | u.warn("abort: %s: %s\n" % (inst.strerror, inst.filename)) |
|
2169 | 2178 | else: |
|
2170 | 2179 | u.warn("abort: %s\n" % inst.strerror) |
|
2171 | 2180 | except util.Abort, inst: |
|
2172 | 2181 | u.warn('abort: ', inst.args[0] % inst.args[1:], '\n') |
|
2173 | 2182 | sys.exit(1) |
|
2174 | 2183 | except TypeError, inst: |
|
2175 | 2184 | # was this an argument error? |
|
2176 | 2185 | tb = traceback.extract_tb(sys.exc_info()[2]) |
|
2177 | 2186 | if len(tb) > 2: # no |
|
2178 | 2187 | raise |
|
2179 | 2188 | u.debug(inst, "\n") |
|
2180 | 2189 | u.warn("%s: invalid arguments\n" % cmd) |
|
2181 | 2190 | help_(u, cmd) |
|
2182 | 2191 | except UnknownCommand, inst: |
|
2183 | 2192 | u.warn("hg: unknown command '%s'\n" % inst.args[0]) |
|
2184 | 2193 | help_(u, 'shortlist') |
|
2185 | 2194 | except SystemExit: |
|
2186 | 2195 | # don't catch this in the catch-all below |
|
2187 | 2196 | raise |
|
2188 | 2197 | except: |
|
2189 | 2198 | u.warn("** unknown exception encountered, details follow\n") |
|
2190 | 2199 | u.warn("** report bug details to mercurial@selenic.com\n") |
|
2191 | 2200 | raise |
|
2192 | 2201 | |
|
2193 | 2202 | sys.exit(-1) |
@@ -1,211 +1,211 b'' | |||
|
1 | 1 | Mercurial Distributed SCM |
|
2 | 2 | |
|
3 | 3 | basic commands (use "hg help" for the full list or option "-v" for details): |
|
4 | 4 | |
|
5 | 5 | add add the specified files on the next commit |
|
6 | 6 | annotate show changeset information per file line |
|
7 | 7 | clone make a copy of an existing repository |
|
8 | 8 | commit commit the specified files or all outstanding changes |
|
9 | 9 | diff diff working directory (or selected files) |
|
10 | 10 | export dump the header and diffs for one or more changesets |
|
11 | 11 | init create a new repository in the given directory |
|
12 | 12 | log show revision history of entire repository or files |
|
13 | 13 | pull pull changes from the specified source |
|
14 | 14 | push push changes to the specified destination |
|
15 | 15 | remove remove the specified files on the next commit |
|
16 | 16 | revert revert modified files or dirs back to their unmodified states |
|
17 | 17 | serve export the repository via HTTP |
|
18 | 18 | status show changed files in the working directory |
|
19 | 19 | update update or merge working directory |
|
20 | 20 | add add the specified files on the next commit |
|
21 | 21 | annotate show changeset information per file line |
|
22 | 22 | clone make a copy of an existing repository |
|
23 | 23 | commit commit the specified files or all outstanding changes |
|
24 | 24 | diff diff working directory (or selected files) |
|
25 | 25 | export dump the header and diffs for one or more changesets |
|
26 | 26 | init create a new repository in the given directory |
|
27 | 27 | log show revision history of entire repository or files |
|
28 | 28 | pull pull changes from the specified source |
|
29 | 29 | push push changes to the specified destination |
|
30 | 30 | remove remove the specified files on the next commit |
|
31 | 31 | revert revert modified files or dirs back to their unmodified states |
|
32 | 32 | serve export the repository via HTTP |
|
33 | 33 | status show changed files in the working directory |
|
34 | 34 | update update or merge working directory |
|
35 | 35 | Mercurial Distributed SCM |
|
36 | 36 | |
|
37 | 37 | list of commands (use "hg help -v" to show aliases and global options): |
|
38 | 38 | |
|
39 | 39 | add add the specified files on the next commit |
|
40 | 40 | addremove add all new files, delete all missing files |
|
41 | 41 | annotate show changeset information per file line |
|
42 | 42 | bundle create a changegroup file |
|
43 |
cat output the latest or given revision of |
|
|
43 | cat output the latest or given revisions of files | |
|
44 | 44 | clone make a copy of an existing repository |
|
45 | 45 | commit commit the specified files or all outstanding changes |
|
46 | 46 | copy mark files as copied for the next commit |
|
47 | 47 | diff diff working directory (or selected files) |
|
48 | 48 | export dump the header and diffs for one or more changesets |
|
49 | 49 | forget don't add the specified files on the next commit |
|
50 | 50 | grep search for a pattern in specified files and revisions |
|
51 | 51 | heads show current repository heads |
|
52 | 52 | help show help for a given command or all commands |
|
53 | 53 | identify print information about the working copy |
|
54 | 54 | import import an ordered set of patches |
|
55 | 55 | incoming show new changesets found in source |
|
56 | 56 | init create a new repository in the given directory |
|
57 | 57 | locate locate files matching specific patterns |
|
58 | 58 | log show revision history of entire repository or files |
|
59 | 59 | manifest output the latest or given revision of the project manifest |
|
60 | 60 | outgoing show changesets not found in destination |
|
61 | 61 | parents show the parents of the working dir or revision |
|
62 | 62 | paths show definition of symbolic path names |
|
63 | 63 | pull pull changes from the specified source |
|
64 | 64 | push push changes to the specified destination |
|
65 | 65 | rawcommit raw commit interface |
|
66 | 66 | recover roll back an interrupted transaction |
|
67 | 67 | remove remove the specified files on the next commit |
|
68 | 68 | rename rename files; equivalent of copy + remove |
|
69 | 69 | revert revert modified files or dirs back to their unmodified states |
|
70 | 70 | root print the root (top) of the current working dir |
|
71 | 71 | serve export the repository via HTTP |
|
72 | 72 | status show changed files in the working directory |
|
73 | 73 | tag add a tag for the current tip or a given revision |
|
74 | 74 | tags list repository tags |
|
75 | 75 | tip show the tip revision |
|
76 | 76 | unbundle apply a changegroup file |
|
77 | 77 | undo undo the last commit or pull |
|
78 | 78 | update update or merge working directory |
|
79 | 79 | verify verify the integrity of the repository |
|
80 | 80 | version output version and copyright information |
|
81 | 81 | add add the specified files on the next commit |
|
82 | 82 | addremove add all new files, delete all missing files |
|
83 | 83 | annotate show changeset information per file line |
|
84 | 84 | bundle create a changegroup file |
|
85 |
cat output the latest or given revision of |
|
|
85 | cat output the latest or given revisions of files | |
|
86 | 86 | clone make a copy of an existing repository |
|
87 | 87 | commit commit the specified files or all outstanding changes |
|
88 | 88 | copy mark files as copied for the next commit |
|
89 | 89 | diff diff working directory (or selected files) |
|
90 | 90 | export dump the header and diffs for one or more changesets |
|
91 | 91 | forget don't add the specified files on the next commit |
|
92 | 92 | grep search for a pattern in specified files and revisions |
|
93 | 93 | heads show current repository heads |
|
94 | 94 | help show help for a given command or all commands |
|
95 | 95 | identify print information about the working copy |
|
96 | 96 | import import an ordered set of patches |
|
97 | 97 | incoming show new changesets found in source |
|
98 | 98 | init create a new repository in the given directory |
|
99 | 99 | locate locate files matching specific patterns |
|
100 | 100 | log show revision history of entire repository or files |
|
101 | 101 | manifest output the latest or given revision of the project manifest |
|
102 | 102 | outgoing show changesets not found in destination |
|
103 | 103 | parents show the parents of the working dir or revision |
|
104 | 104 | paths show definition of symbolic path names |
|
105 | 105 | pull pull changes from the specified source |
|
106 | 106 | push push changes to the specified destination |
|
107 | 107 | rawcommit raw commit interface |
|
108 | 108 | recover roll back an interrupted transaction |
|
109 | 109 | remove remove the specified files on the next commit |
|
110 | 110 | rename rename files; equivalent of copy + remove |
|
111 | 111 | revert revert modified files or dirs back to their unmodified states |
|
112 | 112 | root print the root (top) of the current working dir |
|
113 | 113 | serve export the repository via HTTP |
|
114 | 114 | status show changed files in the working directory |
|
115 | 115 | tag add a tag for the current tip or a given revision |
|
116 | 116 | tags list repository tags |
|
117 | 117 | tip show the tip revision |
|
118 | 118 | unbundle apply a changegroup file |
|
119 | 119 | undo undo the last commit or pull |
|
120 | 120 | update update or merge working directory |
|
121 | 121 | verify verify the integrity of the repository |
|
122 | 122 | version output version and copyright information |
|
123 | 123 | hg add [OPTION]... [FILE]... |
|
124 | 124 | |
|
125 | 125 | add the specified files on the next commit |
|
126 | 126 | |
|
127 | 127 | options: |
|
128 | 128 | |
|
129 | 129 | -I --include include path in search |
|
130 | 130 | -X --exclude exclude path from search |
|
131 | 131 | hg add: option --skjdfks not recognized |
|
132 | 132 | hg add [OPTION]... [FILE]... |
|
133 | 133 | |
|
134 | 134 | add the specified files on the next commit |
|
135 | 135 | |
|
136 | 136 | options: |
|
137 | 137 | |
|
138 | 138 | -I --include include path in search |
|
139 | 139 | -X --exclude exclude path from search |
|
140 | 140 | hg diff [-a] [-I] [-X] [-r REV1 [-r REV2]] [FILE]... |
|
141 | 141 | |
|
142 | 142 | diff working directory (or selected files) |
|
143 | 143 | |
|
144 | 144 | options: |
|
145 | 145 | |
|
146 | 146 | -r --rev revision |
|
147 | 147 | -a --text treat all files as text |
|
148 | 148 | -I --include include path in search |
|
149 | 149 | -X --exclude exclude path from search |
|
150 | 150 | hg status [OPTION]... [FILE]... |
|
151 | 151 | |
|
152 | 152 | show changed files in the working directory |
|
153 | 153 | |
|
154 | 154 | M = modified |
|
155 | 155 | A = added |
|
156 | 156 | R = removed |
|
157 | 157 | ? = not tracked |
|
158 | 158 | |
|
159 | 159 | options: |
|
160 | 160 | |
|
161 | 161 | -m --modified show only modified files |
|
162 | 162 | -a --added show only added files |
|
163 | 163 | -r --removed show only removed files |
|
164 | 164 | -u --unknown show only unknown (not tracked) files |
|
165 | 165 | -n --no-status hide status prefix |
|
166 | 166 | -0 --print0 end filenames with NUL |
|
167 | 167 | -I --include include path in search |
|
168 | 168 | -X --exclude exclude path from search |
|
169 | 169 | hg status [OPTION]... [FILE]... |
|
170 | 170 | |
|
171 | 171 | show changed files in the working directory |
|
172 | 172 | hg: unknown command 'foo' |
|
173 | 173 | Mercurial Distributed SCM |
|
174 | 174 | |
|
175 | 175 | basic commands (use "hg help" for the full list or option "-v" for details): |
|
176 | 176 | |
|
177 | 177 | add add the specified files on the next commit |
|
178 | 178 | annotate show changeset information per file line |
|
179 | 179 | clone make a copy of an existing repository |
|
180 | 180 | commit commit the specified files or all outstanding changes |
|
181 | 181 | diff diff working directory (or selected files) |
|
182 | 182 | export dump the header and diffs for one or more changesets |
|
183 | 183 | init create a new repository in the given directory |
|
184 | 184 | log show revision history of entire repository or files |
|
185 | 185 | pull pull changes from the specified source |
|
186 | 186 | push push changes to the specified destination |
|
187 | 187 | remove remove the specified files on the next commit |
|
188 | 188 | revert revert modified files or dirs back to their unmodified states |
|
189 | 189 | serve export the repository via HTTP |
|
190 | 190 | status show changed files in the working directory |
|
191 | 191 | update update or merge working directory |
|
192 | 192 | hg: unknown command 'skjdfks' |
|
193 | 193 | Mercurial Distributed SCM |
|
194 | 194 | |
|
195 | 195 | basic commands (use "hg help" for the full list or option "-v" for details): |
|
196 | 196 | |
|
197 | 197 | add add the specified files on the next commit |
|
198 | 198 | annotate show changeset information per file line |
|
199 | 199 | clone make a copy of an existing repository |
|
200 | 200 | commit commit the specified files or all outstanding changes |
|
201 | 201 | diff diff working directory (or selected files) |
|
202 | 202 | export dump the header and diffs for one or more changesets |
|
203 | 203 | init create a new repository in the given directory |
|
204 | 204 | log show revision history of entire repository or files |
|
205 | 205 | pull pull changes from the specified source |
|
206 | 206 | push push changes to the specified destination |
|
207 | 207 | remove remove the specified files on the next commit |
|
208 | 208 | revert revert modified files or dirs back to their unmodified states |
|
209 | 209 | serve export the repository via HTTP |
|
210 | 210 | status show changed files in the working directory |
|
211 | 211 | update update or merge working directory |
General Comments 0
You need to be logged in to leave comments.
Login now