##// END OF EJS Templates
[PATCH] add clone command...
mpm@selenic.com -
r485:c5705ab9 default
parent child Browse files
Show More
@@ -1,356 +1,377 b''
1 HG(1)
1 HG(1)
2 =====
2 =====
3 Matt Mackall <mpm@selenic.com>
3 Matt Mackall <mpm@selenic.com>
4 v0.6, 24 Jun 2005
4 v0.6, 24 Jun 2005
5
5
6 NAME
6 NAME
7 ----
7 ----
8 hg - Mercurial source code management system
8 hg - Mercurial source code management system
9
9
10 SYNOPSIS
10 SYNOPSIS
11 --------
11 --------
12 'hg' [-v -d -q -y] <command> [command options] [files]
12 'hg' [-v -d -q -y] <command> [command options] [files]
13
13
14 DESCRIPTION
14 DESCRIPTION
15 -----------
15 -----------
16 The hg(1) command provides a command line interface to the Mercurial system.
16 The hg(1) command provides a command line interface to the Mercurial system.
17
17
18 OPTIONS
18 OPTIONS
19 -------
19 -------
20
20
21 --debug, -d::
21 --debug, -d::
22 enable debugging output
22 enable debugging output
23
23
24 --quiet, -q::
24 --quiet, -q::
25 suppress output
25 suppress output
26
26
27 --verbose, -v::
27 --verbose, -v::
28 enable additional output
28 enable additional output
29
29
30 --noninteractive, -y::
30 --noninteractive, -y::
31 do not prompt, assume 'yes' for any required answers
31 do not prompt, assume 'yes' for any required answers
32
32
33 COMMAND ELEMENTS
33 COMMAND ELEMENTS
34 ----------------
34 ----------------
35
35
36 files ...::
36 files ...::
37 indicates one or more filename or relative path filenames
37 indicates one or more filename or relative path filenames
38
38
39 path::
39 path::
40 indicates a path on the local machine
40 indicates a path on the local machine
41
41
42 revision::
42 revision::
43 indicates a changeset which can be specified as a changeset revision
43 indicates a changeset which can be specified as a changeset revision
44 number, a tag, or a unique substring of the changeset hash value
44 number, a tag, or a unique substring of the changeset hash value
45
45
46 repository path::
46 repository path::
47 is either the pathname of a local repository of the URI of a remote
47 is either the pathname of a local repository of the URI of a remote
48 repository. There are two available URI protocols, http:// which is
48 repository. There are two available URI protocols, http:// which is
49 fast and the old-http:// protocol which is much slower but does not
49 fast and the old-http:// protocol which is much slower but does not
50 require a special server on the web host.
50 require a special server on the web host.
51
51
52 COMMANDS
52 COMMANDS
53 --------
53 --------
54
54
55 add [files ...]::
55 add [files ...]::
56 Add the given files to the repository. Note that this just schedules the
56 Add the given files to the repository. Note that this just schedules the
57 files for addition at the next hg commit time.
57 files for addition at the next hg commit time.
58
58
59 addremove::
59 addremove::
60 Add all new files and remove all missing files from the repository. New
60 Add all new files and remove all missing files from the repository. New
61 files are ignored if they match any of the patterns in .hgignore
61 files are ignored if they match any of the patterns in .hgignore
62
62
63 annotate [-r <rev> -u -n -c] [files ...]::
63 annotate [-r <rev> -u -n -c] [files ...]::
64 List the files with each line showing the revision id responsible
64 List the files with each line showing the revision id responsible
65 for that line.
65 for that line.
66
66
67 options:
67 options:
68 -r, --revision <rev> annotate the specified revision
68 -r, --revision <rev> annotate the specified revision
69 -u, --user list the author
69 -u, --user list the author
70 -c, --changeset list the changeset
70 -c, --changeset list the changeset
71 -n, --number list the revision number (default)
71 -n, --number list the revision number (default)
72
72
73 cat <file> [revision]::
73 cat <file> [revision]::
74 Output the given revision or tip of the specified file to stdout.
74 Output the given revision or tip of the specified file to stdout.
75
75
76 clone [-U] <source> [dest]::
77 Create a new copy of an existing repository.
78
79 If the specified source is on the same filesystem, the repository
80 will be copied via hardlinks. This is the fastest and most
81 space-efficient mode of operation.
82
83 If the destination directory is not specified, it defaults to the
84 current directory.
85
86 If the destination is specified, but does not exist, it is created.
87
88 The source is added to .hg/hgrc in the new copy as the default for
89 future pulls.
90
91 options:
92 -U, --no-update do not update the new working directory
93
76 commit [-A -t -l <file> -t <text> -u <user> -d <datecode>] [files...]::
94 commit [-A -t -l <file> -t <text> -u <user> -d <datecode>] [files...]::
77 Commit all changed files in the working dir to the repository. This uses
95 Commit all changed files in the working dir to the repository. This uses
78 the EDITOR environment variable to bring up an editor to add a commit
96 the EDITOR environment variable to bring up an editor to add a commit
79 comment.
97 comment.
80
98
81 Options:
99 Options:
82
100
83 -A, --addremove run addremove during commit
101 -A, --addremove run addremove during commit
84 -t, --text <text> use <text> as commit message
102 -t, --text <text> use <text> as commit message
85 -l, --logfile <file> read the commit message from the specified
103 -l, --logfile <file> read the commit message from the specified
86 file
104 file
87 -d, --date <datecode> use the specified date code
105 -d, --date <datecode> use the specified date code
88 -u, --user <user> record commit as the specified user
106 -u, --user <user> record commit as the specified user
89
107
90 aliases: ci
108 aliases: ci
91
109
92 copy <source> <dest>::
110 copy <source> <dest>::
93 Mark a file as copied or renamed for the next commit.
111 Mark a file as copied or renamed for the next commit.
94
112
95 diff [-r revision] [-r revision] [files ...]::
113 diff [-r revision] [-r revision] [files ...]::
96 Generate a unified diff of the indicated files. If there are no
114 Generate a unified diff of the indicated files. If there are no
97 revisions specified, the working directory file is compared to
115 revisions specified, the working directory file is compared to
98 the tip, one revision specified indicates a comparison between the
116 the tip, one revision specified indicates a comparison between the
99 working directory file and the specified revision, and two revisions
117 working directory file and the specified revision, and two revisions
100 compares the two versions specified.
118 compares the two versions specified.
101
119
102 export [revision]::
120 export [revision]::
103 Print the changeset header (author, changeset hash, parent, and commit
121 Print the changeset header (author, changeset hash, parent, and commit
104 comment) and the diffs for a particular revision.
122 comment) and the diffs for a particular revision.
105
123
106 forget [files]::
124 forget [files]::
107 Undo an 'hg add' scheduled for the next commit.
125 Undo an 'hg add' scheduled for the next commit.
108
126
109 heads::
127 heads::
110 Show all changesets with no children. These are the "heads" of
128 Show all changesets with no children. These are the "heads" of
111 development branches and are the usual targets for updates and merges.
129 development branches and are the usual targets for updates and merges.
112
130
113 history::
131 history::
114 Print the revision history of the repository. Use the -v switch
132 Print the revision history of the repository. Use the -v switch
115 for more detail.
133 for more detail.
116
134
117 identify::
135 identify::
118 Print a short identifier of the current state of the repo. This
136 Print a short identifier of the current state of the repo. This
119 includes one or two parent hash identifiers, followed by
137 includes one or two parent hash identifiers, followed by
120 a "+" if there are uncommitted changes in the working directory,
138 a "+" if there are uncommitted changes in the working directory,
121 followed by a list of tags for this revision.
139 followed by a list of tags for this revision.
122
140
123 aliases: id
141 aliases: id
124
142
125 import [-p <n> -b <base> -q] <patches>::
143 import [-p <n> -b <base> -q] <patches>::
126 Import the listed patches and commit them individually.
144 Import the listed patches and commit them individually.
127
145
128 options:
146 options:
129 -p, --strip <n> directory strip option for patch
147 -p, --strip <n> directory strip option for patch
130 -b <path> base directory to read patches from
148 -b <path> base directory to read patches from
131
149
132 aliases: patch
150 aliases: patch
133
151
134 init [-u] [source]::
152 init [-u] [source]::
135 Initialize a repository in the current directory.
153 Initialize a repository in the current directory.
136
154
155 NOTE: The following use is deprecated, and will be removed soon;
156 use the "hg clone" command instead.
157
137 If a source is specified, pull that source into the repository.
158 If a source is specified, pull that source into the repository.
138 This source is added to .hg/hgrc as the default for future pulls
159 This source is added to .hg/hgrc as the default for future pulls
139 in this repository.
160 in this repository.
140
161
141 If the specified source is on the same filesystem, the repository
162 If the specified source is on the same filesystem, the repository
142 will be copied via hardlinks. This is the fastest and most
163 will be copied via hardlinks. This is the fastest and most
143 space-efficient mode of operation.
164 space-efficient mode of operation.
144
165
145 options:
166 options:
146 -u, --update update the working directory to match the tip
167 -u, --update update the working directory to match the tip
147
168
148 log <file>::
169 log <file>::
149 Print the revision history of the specified file.
170 Print the revision history of the specified file.
150
171
151 manifest [revision]::
172 manifest [revision]::
152 Print the indicated revision of the manifest (list of version controlled
173 Print the indicated revision of the manifest (list of version controlled
153 files).
174 files).
154
175
155 parents::
176 parents::
156 Print the working directory's parent revisions.
177 Print the working directory's parent revisions.
157
178
158 pull <repository path>::
179 pull <repository path>::
159 Pull any changes from the specified repository to the repository in the
180 Pull any changes from the specified repository to the repository in the
160 current directory.
181 current directory.
161
182
162 options:
183 options:
163 -u, --update update the working directory to tip after pull
184 -u, --update update the working directory to tip after pull
164
185
165 push <destination>::
186 push <destination>::
166 Push changes from the local repository to the specified
187 Push changes from the local repository to the specified
167 destination. If the destination is local, this is identical to a
188 destination. If the destination is local, this is identical to a
168 a pull in that directory from the current directory.
189 a pull in that directory from the current directory.
169
190
170 The other currently available push method is SSH. This requires an
191 The other currently available push method is SSH. This requires an
171 accessible shell account on the destination machine and a copy of
192 accessible shell account on the destination machine and a copy of
172 hg in the remote path. Destinations are specified in the following
193 hg in the remote path. Destinations are specified in the following
173 form:
194 form:
174
195
175 ssh://[user@]host[:port]/path
196 ssh://[user@]host[:port]/path
176
197
177 rawcommit [-p -d -u -F -t -l]::
198 rawcommit [-p -d -u -F -t -l]::
178 Primarily useful for importing from other SCMs.
199 Primarily useful for importing from other SCMs.
179
200
180 recover::
201 recover::
181 Recover from an interrupted commit or pull. This should only be
202 Recover from an interrupted commit or pull. This should only be
182 necessary when Mercurial suggests it.
203 necessary when Mercurial suggests it.
183
204
184 remove [files ...]::
205 remove [files ...]::
185 Schedule the indicated files for removal from the repository at the next
206 Schedule the indicated files for removal from the repository at the next
186 commit.
207 commit.
187
208
188 aliases: rm
209 aliases: rm
189
210
190 root::
211 root::
191 Print the root directory of the current repository.
212 Print the root directory of the current repository.
192
213
193 serve [-a addr -n name -p port -t templatedir]::
214 serve [-a addr -n name -p port -t templatedir]::
194 Start a local HTTP repository browser and pull server.
215 Start a local HTTP repository browser and pull server.
195
216
196 options:
217 options:
197 -a, --address <addr> address to use
218 -a, --address <addr> address to use
198 -p, --port <n> port to use (default: 8000)
219 -p, --port <n> port to use (default: 8000)
199 -n, --name <name> name to show in web pages (default: working dir)
220 -n, --name <name> name to show in web pages (default: working dir)
200 -t, --templatedir <path> web templates to use
221 -t, --templatedir <path> web templates to use
201
222
202 status::
223 status::
203 Show changed files in the working directory.
224 Show changed files in the working directory.
204
225
205 C = changed
226 C = changed
206 A = added
227 A = added
207 R = removed
228 R = removed
208 ? = not tracked
229 ? = not tracked
209
230
210 tag [-t <text> -d <datecode> -u <user>] <name> [revision]::
231 tag [-t <text> -d <datecode> -u <user>] <name> [revision]::
211 Add a tag <name> to the specified revision or the tip.
232 Add a tag <name> to the specified revision or the tip.
212
233
213 options:
234 options:
214 -t, --text <text> message for tag commit log entry
235 -t, --text <text> message for tag commit log entry
215 -d, --date <datecode> datecode for commit
236 -d, --date <datecode> datecode for commit
216 -u, --user <user> user for commit
237 -u, --user <user> user for commit
217
238
218 tags::
239 tags::
219 List the repository tags.
240 List the repository tags.
220
241
221 tip::
242 tip::
222 Show the tip revision.
243 Show the tip revision.
223
244
224 undo::
245 undo::
225 Undo the last commit or pull transaction.
246 Undo the last commit or pull transaction.
226
247
227 update [-m -C] [revision]::
248 update [-m -C] [revision]::
228 Update or merge the working directory to a specified revision.
249 Update or merge the working directory to a specified revision.
229
250
230 If there are no outstanding changes in the working directory and
251 If there are no outstanding changes in the working directory and
231 there is a linear relationship between the current version and the
252 there is a linear relationship between the current version and the
232 requested version, the result is the requested version.
253 requested version, the result is the requested version.
233
254
234 Otherwise the result is a merge between the contents of the
255 Otherwise the result is a merge between the contents of the
235 current working directory and the requested version. Files that
256 current working directory and the requested version. Files that
236 changed between either parent are marked as changed for the next
257 changed between either parent are marked as changed for the next
237 commit and a commit must be performed before any further updates
258 commit and a commit must be performed before any further updates
238 are allowed. Merging will not be performed without the -m flag.
259 are allowed. Merging will not be performed without the -m flag.
239
260
240 The -C switch will tell Mercurial to forcibly update to the
261 The -C switch will tell Mercurial to forcibly update to the
241 specified version, adding, removing, and overwriting locally
262 specified version, adding, removing, and overwriting locally
242 changed fils as necessary.
263 changed fils as necessary.
243
264
244 options:
265 options:
245 -m, --merge allow merging of branches
266 -m, --merge allow merging of branches
246 -C, --clean overwrite locally modified files
267 -C, --clean overwrite locally modified files
247
268
248 aliases: up checkout co
269 aliases: up checkout co
249
270
250 verify::
271 verify::
251 Verify the integrity of the current repository.
272 Verify the integrity of the current repository.
252
273
253 This will perform an extensive check of the repository's
274 This will perform an extensive check of the repository's
254 integrity, validating the hashes and checksums of each entry in
275 integrity, validating the hashes and checksums of each entry in
255 the changelog, manifest, and tracked files, as well as the
276 the changelog, manifest, and tracked files, as well as the
256 integrity of their crosslinks and indices.
277 integrity of their crosslinks and indices.
257
278
258
279
259 ENVIRONMENT VARIABLES
280 ENVIRONMENT VARIABLES
260 ---------------------
281 ---------------------
261
282
262 HGEDITOR::
283 HGEDITOR::
263 This is the name of the editor to use when committing. Defaults to the
284 This is the name of the editor to use when committing. Defaults to the
264 value of EDITOR.
285 value of EDITOR.
265
286
266 HGMERGE::
287 HGMERGE::
267 An executable to use for resolving merge conflicts. The program ,
288 An executable to use for resolving merge conflicts. The program ,
268 will be executed with three arguments: local file, remote file,
289 will be executed with three arguments: local file, remote file,
269 ancestor file.
290 ancestor file.
270
291
271 The default program is "hgmerge", which is a shell script provided
292 The default program is "hgmerge", which is a shell script provided
272 by Mercurial with some sensible defaults.
293 by Mercurial with some sensible defaults.
273
294
274 HGUSER::
295 HGUSER::
275 This is the string used for the author of a commit.
296 This is the string used for the author of a commit.
276
297
277 EMAIL::
298 EMAIL::
278 If HGUSER is not set, this will be used as the author for a commit.
299 If HGUSER is not set, this will be used as the author for a commit.
279
300
280 LOGNAME::
301 LOGNAME::
281 If neither HGUSER nor EMAIL is set, LOGNAME will be used (with
302 If neither HGUSER nor EMAIL is set, LOGNAME will be used (with
282 '@hostname' appended) as the author value for a commit.
303 '@hostname' appended) as the author value for a commit.
283
304
284 EDITOR::
305 EDITOR::
285 This is the name of the editor used in the hgmerge script. It will be
306 This is the name of the editor used in the hgmerge script. It will be
286 used for commit messages, too, if HGEDITOR isn't set. Defaults to 'vi'.
307 used for commit messages, too, if HGEDITOR isn't set. Defaults to 'vi'.
287
308
288 PYTHONPATH::
309 PYTHONPATH::
289 This is used by Python to find imported modules and may need to be set
310 This is used by Python to find imported modules and may need to be set
290 appropriately if Mercurial is not installed system-wide.
311 appropriately if Mercurial is not installed system-wide.
291
312
292 FILES
313 FILES
293 -----
314 -----
294 .hgignore::
315 .hgignore::
295 This file contains regular expressions (one per line) that describe file
316 This file contains regular expressions (one per line) that describe file
296 names that should be ignored by hg.
317 names that should be ignored by hg.
297
318
298 .hgtags::
319 .hgtags::
299 This file contains changeset hash values and text tag names (one of each
320 This file contains changeset hash values and text tag names (one of each
300 seperated by spaces) that correspond to tagged versions of the repository
321 seperated by spaces) that correspond to tagged versions of the repository
301 contents.
322 contents.
302
323
303 $HOME/.hgrc, .hg/hgrc::
324 $HOME/.hgrc, .hg/hgrc::
304 This file contains defaults and configuration. Values in .hg/hgrc
325 This file contains defaults and configuration. Values in .hg/hgrc
305 override those in .hgrc.
326 override those in .hgrc.
306
327
307 NAMED REPOSITORIES
328 NAMED REPOSITORIES
308 ------------------
329 ------------------
309
330
310 To give symbolic names to a repository, create a section in .hgrc
331 To give symbolic names to a repository, create a section in .hgrc
311 or .hg/hgrc containing assignments of names to paths.
332 or .hg/hgrc containing assignments of names to paths.
312
333
313 Example:
334 Example:
314
335
315 [paths]
336 [paths]
316 hg = http://selenic.com/hg
337 hg = http://selenic.com/hg
317 tah = http://hg.intevation.org/mercurial-tah/
338 tah = http://hg.intevation.org/mercurial-tah/
318
339
319 NON_TRANSPARENT PROXY SUPPORT
340 NON_TRANSPARENT PROXY SUPPORT
320 -----------------------------
341 -----------------------------
321
342
322 To access a Mercurial repository through a proxy,
343 To access a Mercurial repository through a proxy,
323 create a file $HOME/.hgrc in the following format:
344 create a file $HOME/.hgrc in the following format:
324
345
325 [http_proxy]
346 [http_proxy]
326 host=myproxy:8080
347 host=myproxy:8080
327 user=<username>
348 user=<username>
328 passwd=<password>
349 passwd=<password>
329 no=<localhost1>,<localhost2>,<localhost3>,...
350 no=<localhost1>,<localhost2>,<localhost3>,...
330
351
331 "user","passwd" fields are used for authenticating proxies,
352 "user","passwd" fields are used for authenticating proxies,
332 "no" is a comma-separated list of local host names
353 "no" is a comma-separated list of local host names
333 for which proxy must be bypassed.
354 for which proxy must be bypassed.
334
355
335 BUGS
356 BUGS
336 ----
357 ----
337 Probably lots, please post them to the mailing list (See Resources below)
358 Probably lots, please post them to the mailing list (See Resources below)
338 when you find them.
359 when you find them.
339
360
340 AUTHOR
361 AUTHOR
341 ------
362 ------
342 Written by Matt Mackall <mpm@selenic.com>
363 Written by Matt Mackall <mpm@selenic.com>
343
364
344 RESOURCES
365 RESOURCES
345 ---------
366 ---------
346 http://selenic.com/mercurial[Main Web Site]
367 http://selenic.com/mercurial[Main Web Site]
347
368
348 http://selenic.com/hg[Source code repository]
369 http://selenic.com/hg[Source code repository]
349
370
350 http://selenic.com/mailman/listinfo/mercurial[Mailing list]
371 http://selenic.com/mailman/listinfo/mercurial[Mailing list]
351
372
352 COPYING
373 COPYING
353 -------
374 -------
354 Copyright (C) 2005 Matt Mackall.
375 Copyright (C) 2005 Matt Mackall.
355 Free use of this software is granted under the terms of the GNU General
376 Free use of this software is granted under the terms of the GNU General
356 Public License (GPL).
377 Public License (GPL).
@@ -1,876 +1,892 b''
1 # commands.py - command processing for mercurial
1 # commands.py - command processing for mercurial
2 #
2 #
3 # Copyright 2005 Matt Mackall <mpm@selenic.com>
3 # Copyright 2005 Matt Mackall <mpm@selenic.com>
4 #
4 #
5 # This software may be used and distributed according to the terms
5 # This software may be used and distributed according to the terms
6 # of the GNU General Public License, incorporated herein by reference.
6 # of the GNU General Public License, incorporated herein by reference.
7
7
8 import os, re, sys, signal
8 import os, re, sys, signal
9 import fancyopts, ui, hg, util
9 import fancyopts, ui, hg, util
10 from demandload import *
10 from demandload import *
11 demandload(globals(), "mdiff time hgweb traceback random signal errno version")
11 demandload(globals(), "mdiff time hgweb traceback random signal errno version")
12
12
13 class UnknownCommand(Exception): pass
13 class UnknownCommand(Exception): pass
14
14
15 def filterfiles(filters, files):
15 def filterfiles(filters, files):
16 l = [ x for x in files if x in filters ]
16 l = [ x for x in files if x in filters ]
17
17
18 for t in filters:
18 for t in filters:
19 if t and t[-1] != "/": t += "/"
19 if t and t[-1] != "/": t += "/"
20 l += [ x for x in files if x.startswith(t) ]
20 l += [ x for x in files if x.startswith(t) ]
21 return l
21 return l
22
22
23 def relfilter(repo, files):
23 def relfilter(repo, files):
24 if os.getcwd() != repo.root:
24 if os.getcwd() != repo.root:
25 p = os.getcwd()[len(repo.root) + 1: ]
25 p = os.getcwd()[len(repo.root) + 1: ]
26 return filterfiles([util.pconvert(p)], files)
26 return filterfiles([util.pconvert(p)], files)
27 return files
27 return files
28
28
29 def relpath(repo, args):
29 def relpath(repo, args):
30 if os.getcwd() != repo.root:
30 if os.getcwd() != repo.root:
31 p = os.getcwd()[len(repo.root) + 1: ]
31 p = os.getcwd()[len(repo.root) + 1: ]
32 return [ util.pconvert(os.path.normpath(os.path.join(p, x))) for x in args ]
32 return [ util.pconvert(os.path.normpath(os.path.join(p, x))) for x in args ]
33 return args
33 return args
34
34
35 def dodiff(ui, repo, path, files = None, node1 = None, node2 = None):
35 def dodiff(ui, repo, path, files = None, node1 = None, node2 = None):
36 def date(c):
36 def date(c):
37 return time.asctime(time.gmtime(float(c[2].split(' ')[0])))
37 return time.asctime(time.gmtime(float(c[2].split(' ')[0])))
38
38
39 if node2:
39 if node2:
40 change = repo.changelog.read(node2)
40 change = repo.changelog.read(node2)
41 mmap2 = repo.manifest.read(change[0])
41 mmap2 = repo.manifest.read(change[0])
42 (c, a, d) = repo.diffrevs(node1, node2)
42 (c, a, d) = repo.diffrevs(node1, node2)
43 def read(f): return repo.file(f).read(mmap2[f])
43 def read(f): return repo.file(f).read(mmap2[f])
44 date2 = date(change)
44 date2 = date(change)
45 else:
45 else:
46 date2 = time.asctime()
46 date2 = time.asctime()
47 (c, a, d, u) = repo.diffdir(path, node1)
47 (c, a, d, u) = repo.diffdir(path, node1)
48 if not node1:
48 if not node1:
49 node1 = repo.dirstate.parents()[0]
49 node1 = repo.dirstate.parents()[0]
50 def read(f): return repo.wfile(f).read()
50 def read(f): return repo.wfile(f).read()
51
51
52 if ui.quiet:
52 if ui.quiet:
53 r = None
53 r = None
54 else:
54 else:
55 hexfunc = ui.verbose and hg.hex or hg.short
55 hexfunc = ui.verbose and hg.hex or hg.short
56 r = [hexfunc(node) for node in [node1, node2] if node]
56 r = [hexfunc(node) for node in [node1, node2] if node]
57
57
58 change = repo.changelog.read(node1)
58 change = repo.changelog.read(node1)
59 mmap = repo.manifest.read(change[0])
59 mmap = repo.manifest.read(change[0])
60 date1 = date(change)
60 date1 = date(change)
61
61
62 if files:
62 if files:
63 c, a, d = map(lambda x: filterfiles(files, x), (c, a, d))
63 c, a, d = map(lambda x: filterfiles(files, x), (c, a, d))
64
64
65 for f in c:
65 for f in c:
66 to = None
66 to = None
67 if f in mmap:
67 if f in mmap:
68 to = repo.file(f).read(mmap[f])
68 to = repo.file(f).read(mmap[f])
69 tn = read(f)
69 tn = read(f)
70 sys.stdout.write(mdiff.unidiff(to, date1, tn, date2, f, r))
70 sys.stdout.write(mdiff.unidiff(to, date1, tn, date2, f, r))
71 for f in a:
71 for f in a:
72 to = None
72 to = None
73 tn = read(f)
73 tn = read(f)
74 sys.stdout.write(mdiff.unidiff(to, date1, tn, date2, f, r))
74 sys.stdout.write(mdiff.unidiff(to, date1, tn, date2, f, r))
75 for f in d:
75 for f in d:
76 to = repo.file(f).read(mmap[f])
76 to = repo.file(f).read(mmap[f])
77 tn = None
77 tn = None
78 sys.stdout.write(mdiff.unidiff(to, date1, tn, date2, f, r))
78 sys.stdout.write(mdiff.unidiff(to, date1, tn, date2, f, r))
79
79
80 def show_changeset(ui, repo, rev=0, changenode=None, filelog=None):
80 def show_changeset(ui, repo, rev=0, changenode=None, filelog=None):
81 """show a single changeset or file revision"""
81 """show a single changeset or file revision"""
82 changelog = repo.changelog
82 changelog = repo.changelog
83 if filelog:
83 if filelog:
84 log = filelog
84 log = filelog
85 filerev = rev
85 filerev = rev
86 node = filenode = filelog.node(filerev)
86 node = filenode = filelog.node(filerev)
87 changerev = filelog.linkrev(filenode)
87 changerev = filelog.linkrev(filenode)
88 changenode = changenode or changelog.node(changerev)
88 changenode = changenode or changelog.node(changerev)
89 else:
89 else:
90 log = changelog
90 log = changelog
91 changerev = rev
91 changerev = rev
92 if changenode is None:
92 if changenode is None:
93 changenode = changelog.node(changerev)
93 changenode = changelog.node(changerev)
94 elif not changerev:
94 elif not changerev:
95 rev = changerev = changelog.rev(changenode)
95 rev = changerev = changelog.rev(changenode)
96 node = changenode
96 node = changenode
97
97
98 if ui.quiet:
98 if ui.quiet:
99 ui.write("%d:%s\n" % (rev, hg.hex(node)))
99 ui.write("%d:%s\n" % (rev, hg.hex(node)))
100 return
100 return
101
101
102 changes = changelog.read(changenode)
102 changes = changelog.read(changenode)
103
103
104 parents = [(log.rev(parent), hg.hex(parent))
104 parents = [(log.rev(parent), hg.hex(parent))
105 for parent in log.parents(node)
105 for parent in log.parents(node)
106 if ui.debugflag or parent != hg.nullid]
106 if ui.debugflag or parent != hg.nullid]
107 if not ui.debugflag and len(parents) == 1 and parents[0][0] == rev-1:
107 if not ui.debugflag and len(parents) == 1 and parents[0][0] == rev-1:
108 parents = []
108 parents = []
109
109
110 if filelog:
110 if filelog:
111 ui.write("revision: %d:%s\n" % (filerev, hg.hex(filenode)))
111 ui.write("revision: %d:%s\n" % (filerev, hg.hex(filenode)))
112 for parent in parents:
112 for parent in parents:
113 ui.write("parent: %d:%s\n" % parent)
113 ui.write("parent: %d:%s\n" % parent)
114 ui.status("changeset: %d:%s\n" % (changerev, hg.hex(changenode)))
114 ui.status("changeset: %d:%s\n" % (changerev, hg.hex(changenode)))
115 else:
115 else:
116 ui.write("changeset: %d:%s\n" % (changerev, hg.hex(changenode)))
116 ui.write("changeset: %d:%s\n" % (changerev, hg.hex(changenode)))
117 for tag in repo.nodetags(changenode):
117 for tag in repo.nodetags(changenode):
118 ui.status("tag: %s\n" % tag)
118 ui.status("tag: %s\n" % tag)
119 for parent in parents:
119 for parent in parents:
120 ui.write("parent: %d:%s\n" % parent)
120 ui.write("parent: %d:%s\n" % parent)
121 ui.note("manifest: %d:%s\n" % (repo.manifest.rev(changes[0]),
121 ui.note("manifest: %d:%s\n" % (repo.manifest.rev(changes[0]),
122 hg.hex(changes[0])))
122 hg.hex(changes[0])))
123 ui.status("user: %s\n" % changes[1])
123 ui.status("user: %s\n" % changes[1])
124 ui.status("date: %s\n" % time.asctime(
124 ui.status("date: %s\n" % time.asctime(
125 time.localtime(float(changes[2].split(' ')[0]))))
125 time.localtime(float(changes[2].split(' ')[0]))))
126 ui.note("files: %s\n" % " ".join(changes[3]))
126 ui.note("files: %s\n" % " ".join(changes[3]))
127 description = changes[4].strip()
127 description = changes[4].strip()
128 if description:
128 if description:
129 if ui.verbose:
129 if ui.verbose:
130 ui.status("description:\n")
130 ui.status("description:\n")
131 ui.status(description)
131 ui.status(description)
132 ui.status("\n")
132 ui.status("\n")
133 else:
133 else:
134 ui.status("summary: %s\n" % description.splitlines()[0])
134 ui.status("summary: %s\n" % description.splitlines()[0])
135 ui.status("\n")
135 ui.status("\n")
136
136
137 def show_version(ui):
137 def show_version(ui):
138 """output version and copyright information"""
138 """output version and copyright information"""
139 ui.write("Mercurial version %s\n" % version.get_version())
139 ui.write("Mercurial version %s\n" % version.get_version())
140 ui.status(
140 ui.status(
141 "\nCopyright (C) 2005 Matt Mackall <mpm@selenic.com>\n"
141 "\nCopyright (C) 2005 Matt Mackall <mpm@selenic.com>\n"
142 "This is free software; see the source for copying conditions. "
142 "This is free software; see the source for copying conditions. "
143 "There is NO\nwarranty; "
143 "There is NO\nwarranty; "
144 "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
144 "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
145 )
145 )
146
146
147 def help(ui, cmd=None):
147 def help(ui, cmd=None):
148 '''show help for a given command or all commands'''
148 '''show help for a given command or all commands'''
149 if cmd:
149 if cmd:
150 try:
150 try:
151 i = find(cmd)
151 i = find(cmd)
152 ui.write("%s\n\n" % i[2])
152 ui.write("%s\n\n" % i[2])
153
153
154 if i[1]:
154 if i[1]:
155 for s, l, d, c in i[1]:
155 for s, l, d, c in i[1]:
156 opt=' '
156 opt=' '
157 if s: opt = opt + '-' + s + ' '
157 if s: opt = opt + '-' + s + ' '
158 if l: opt = opt + '--' + l + ' '
158 if l: opt = opt + '--' + l + ' '
159 if d: opt = opt + '(' + str(d) + ')'
159 if d: opt = opt + '(' + str(d) + ')'
160 ui.write(opt, "\n")
160 ui.write(opt, "\n")
161 if c: ui.write(' %s\n' % c)
161 if c: ui.write(' %s\n' % c)
162 ui.write("\n")
162 ui.write("\n")
163
163
164 ui.write(i[0].__doc__, "\n")
164 ui.write(i[0].__doc__, "\n")
165 except UnknownCommand:
165 except UnknownCommand:
166 ui.warn("hg: unknown command %s\n" % cmd)
166 ui.warn("hg: unknown command %s\n" % cmd)
167 sys.exit(0)
167 sys.exit(0)
168 else:
168 else:
169 if not ui.quiet:
169 if not ui.quiet:
170 show_version(ui)
170 show_version(ui)
171 ui.write('\n')
171 ui.write('\n')
172 ui.write('hg commands:\n\n')
172 ui.write('hg commands:\n\n')
173
173
174 h = {}
174 h = {}
175 for c, e in table.items():
175 for c, e in table.items():
176 f = c.split("|")[0]
176 f = c.split("|")[0]
177 if f.startswith("debug"):
177 if f.startswith("debug"):
178 continue
178 continue
179 d = ""
179 d = ""
180 if e[0].__doc__:
180 if e[0].__doc__:
181 d = e[0].__doc__.splitlines(0)[0].rstrip()
181 d = e[0].__doc__.splitlines(0)[0].rstrip()
182 h[f] = d
182 h[f] = d
183
183
184 fns = h.keys()
184 fns = h.keys()
185 fns.sort()
185 fns.sort()
186 m = max(map(len, fns))
186 m = max(map(len, fns))
187 for f in fns:
187 for f in fns:
188 ui.write(' %-*s %s\n' % (m, f, h[f]))
188 ui.write(' %-*s %s\n' % (m, f, h[f]))
189
189
190 # Commands start here, listed alphabetically
190 # Commands start here, listed alphabetically
191
191
192 def add(ui, repo, file, *files):
192 def add(ui, repo, file, *files):
193 '''add the specified files on the next commit'''
193 '''add the specified files on the next commit'''
194 repo.add(relpath(repo, (file,) + files))
194 repo.add(relpath(repo, (file,) + files))
195
195
196 def addremove(ui, repo, *files):
196 def addremove(ui, repo, *files):
197 """add all new files, delete all missing files"""
197 """add all new files, delete all missing files"""
198 if files:
198 if files:
199 files = relpath(repo, files)
199 files = relpath(repo, files)
200 d = []
200 d = []
201 u = []
201 u = []
202 for f in files:
202 for f in files:
203 p = repo.wjoin(f)
203 p = repo.wjoin(f)
204 s = repo.dirstate.state(f)
204 s = repo.dirstate.state(f)
205 isfile = os.path.isfile(p)
205 isfile = os.path.isfile(p)
206 if s != 'r' and not isfile:
206 if s != 'r' and not isfile:
207 d.append(f)
207 d.append(f)
208 elif s not in 'nmai' and isfile:
208 elif s not in 'nmai' and isfile:
209 u.append(f)
209 u.append(f)
210 else:
210 else:
211 (c, a, d, u) = repo.diffdir(repo.root)
211 (c, a, d, u) = repo.diffdir(repo.root)
212 repo.add(u)
212 repo.add(u)
213 repo.remove(d)
213 repo.remove(d)
214
214
215 def annotate(u, repo, file, *files, **ops):
215 def annotate(u, repo, file, *files, **ops):
216 """show changeset information per file line"""
216 """show changeset information per file line"""
217 def getnode(rev):
217 def getnode(rev):
218 return hg.short(repo.changelog.node(rev))
218 return hg.short(repo.changelog.node(rev))
219
219
220 def getname(rev):
220 def getname(rev):
221 try:
221 try:
222 return bcache[rev]
222 return bcache[rev]
223 except KeyError:
223 except KeyError:
224 cl = repo.changelog.read(repo.changelog.node(rev))
224 cl = repo.changelog.read(repo.changelog.node(rev))
225 name = cl[1]
225 name = cl[1]
226 f = name.find('@')
226 f = name.find('@')
227 if f >= 0:
227 if f >= 0:
228 name = name[:f]
228 name = name[:f]
229 bcache[rev] = name
229 bcache[rev] = name
230 return name
230 return name
231
231
232 bcache = {}
232 bcache = {}
233 opmap = [['user', getname], ['number', str], ['changeset', getnode]]
233 opmap = [['user', getname], ['number', str], ['changeset', getnode]]
234 if not ops['user'] and not ops['changeset']:
234 if not ops['user'] and not ops['changeset']:
235 ops['number'] = 1
235 ops['number'] = 1
236
236
237 node = repo.dirstate.parents()[0]
237 node = repo.dirstate.parents()[0]
238 if ops['revision']:
238 if ops['revision']:
239 node = repo.changelog.lookup(ops['revision'])
239 node = repo.changelog.lookup(ops['revision'])
240 change = repo.changelog.read(node)
240 change = repo.changelog.read(node)
241 mmap = repo.manifest.read(change[0])
241 mmap = repo.manifest.read(change[0])
242 for f in relpath(repo, (file,) + files):
242 for f in relpath(repo, (file,) + files):
243 lines = repo.file(f).annotate(mmap[f])
243 lines = repo.file(f).annotate(mmap[f])
244 pieces = []
244 pieces = []
245
245
246 for o, f in opmap:
246 for o, f in opmap:
247 if ops[o]:
247 if ops[o]:
248 l = [ f(n) for n,t in lines ]
248 l = [ f(n) for n,t in lines ]
249 m = max(map(len, l))
249 m = max(map(len, l))
250 pieces.append([ "%*s" % (m, x) for x in l])
250 pieces.append([ "%*s" % (m, x) for x in l])
251
251
252 for p,l in zip(zip(*pieces), lines):
252 for p,l in zip(zip(*pieces), lines):
253 u.write(" ".join(p) + ": " + l[1])
253 u.write(" ".join(p) + ": " + l[1])
254
254
255 def cat(ui, repo, file, rev = []):
255 def cat(ui, repo, file, rev = []):
256 """output the latest or given revision of a file"""
256 """output the latest or given revision of a file"""
257 r = repo.file(relpath(repo, [file])[0])
257 r = repo.file(relpath(repo, [file])[0])
258 n = r.tip()
258 n = r.tip()
259 if rev: n = r.lookup(rev)
259 if rev: n = r.lookup(rev)
260 sys.stdout.write(r.read(n))
260 sys.stdout.write(r.read(n))
261
261
262 def clone(ui, source, dest = None, **opts):
263 """make a copy of an existing repository"""
264 paths = {}
265 for name, path in ui.configitems("paths"):
266 paths[name] = path
267
268 if source in paths: source = paths[source]
269
270 if dest is None:
271 dest = os.getcwd()
272 elif not os.path.exists(dest):
273 os.makedirs(dest)
274
275 link = 0
276 if not source.startswith("http://"):
277 source = os.path.realpath(source)
278 d1 = os.stat(dest).st_dev
279 d2 = os.stat(source).st_dev
280 if d1 == d2: link = 1
281
282 os.chdir(dest)
283
284 if link:
285 ui.debug("copying by hardlink\n")
286 os.system("cp -al %s/.hg .hg" % source)
287 try:
288 os.remove(".hg/dirstate")
289 except: pass
290
291 repo = hg.repository(ui, ".")
292
293 else:
294 repo = hg.repository(ui, ".", create=1)
295 other = hg.repository(ui, source)
296 cg = repo.getchangegroup(other)
297 repo.addchangegroup(cg)
298
299 f = repo.opener("hgrc", "w")
300 f.write("[paths]\n")
301 f.write("default = %s\n" % source)
302
303 if not opts['no-update']:
304 update(ui, repo)
305
262 def commit(ui, repo, *files, **opts):
306 def commit(ui, repo, *files, **opts):
263 """commit the specified files or all outstanding changes"""
307 """commit the specified files or all outstanding changes"""
264 text = opts['text']
308 text = opts['text']
265 if not text and opts['logfile']:
309 if not text and opts['logfile']:
266 try: text = open(opts['logfile']).read()
310 try: text = open(opts['logfile']).read()
267 except IOError: pass
311 except IOError: pass
268
312
269 if opts['addremove']:
313 if opts['addremove']:
270 addremove(ui, repo, *files)
314 addremove(ui, repo, *files)
271 repo.commit(relpath(repo, files), text, opts['user'], opts['date'])
315 repo.commit(relpath(repo, files), text, opts['user'], opts['date'])
272
316
273 def copy(ui, repo, source, dest):
317 def copy(ui, repo, source, dest):
274 """mark a file as copied or renamed for the next commit"""
318 """mark a file as copied or renamed for the next commit"""
275 return repo.copy(*relpath(repo, (source, dest)))
319 return repo.copy(*relpath(repo, (source, dest)))
276
320
277 def debugcheckdirstate(ui, repo):
321 def debugcheckdirstate(ui, repo):
278 parent1, parent2 = repo.dirstate.parents()
322 parent1, parent2 = repo.dirstate.parents()
279 dc = repo.dirstate.dup()
323 dc = repo.dirstate.dup()
280 keys = dc.keys()
324 keys = dc.keys()
281 keys.sort()
325 keys.sort()
282 m1n = repo.changelog.read(parent1)[0]
326 m1n = repo.changelog.read(parent1)[0]
283 m2n = repo.changelog.read(parent2)[0]
327 m2n = repo.changelog.read(parent2)[0]
284 m1 = repo.manifest.read(m1n)
328 m1 = repo.manifest.read(m1n)
285 m2 = repo.manifest.read(m2n)
329 m2 = repo.manifest.read(m2n)
286 errors = 0
330 errors = 0
287 for f in dc:
331 for f in dc:
288 state = repo.dirstate.state(f)
332 state = repo.dirstate.state(f)
289 if state in "nr" and f not in m1:
333 if state in "nr" and f not in m1:
290 print "%s in state %s, but not listed in manifest1" % (f, state)
334 print "%s in state %s, but not listed in manifest1" % (f, state)
291 errors += 1
335 errors += 1
292 if state in "a" and f in m1:
336 if state in "a" and f in m1:
293 print "%s in state %s, but also listed in manifest1" % (f, state)
337 print "%s in state %s, but also listed in manifest1" % (f, state)
294 errors += 1
338 errors += 1
295 if state in "m" and f not in m1 and f not in m2:
339 if state in "m" and f not in m1 and f not in m2:
296 print "%s in state %s, but not listed in either manifest" % (f, state)
340 print "%s in state %s, but not listed in either manifest" % (f, state)
297 errors += 1
341 errors += 1
298 for f in m1:
342 for f in m1:
299 state = repo.dirstate.state(f)
343 state = repo.dirstate.state(f)
300 if state not in "nrm":
344 if state not in "nrm":
301 print "%s in manifest1, but listed as state %s" % (f, state)
345 print "%s in manifest1, but listed as state %s" % (f, state)
302 errors += 1
346 errors += 1
303 if errors:
347 if errors:
304 print ".hg/dirstate inconsistent with current parent's manifest, aborting"
348 print ".hg/dirstate inconsistent with current parent's manifest, aborting"
305 sys.exit(1)
349 sys.exit(1)
306
350
307 def debugdumpdirstate(ui, repo):
351 def debugdumpdirstate(ui, repo):
308 dc = repo.dirstate.dup()
352 dc = repo.dirstate.dup()
309 keys = dc.keys()
353 keys = dc.keys()
310 keys.sort()
354 keys.sort()
311 for file in keys:
355 for file in keys:
312 print "%s => %c" % (file, dc[file][0])
356 print "%s => %c" % (file, dc[file][0])
313
357
314 def debugindex(ui, file):
358 def debugindex(ui, file):
315 r = hg.revlog(hg.opener(""), file, "")
359 r = hg.revlog(hg.opener(""), file, "")
316 print " rev offset length base linkrev"+\
360 print " rev offset length base linkrev"+\
317 " p1 p2 nodeid"
361 " p1 p2 nodeid"
318 for i in range(r.count()):
362 for i in range(r.count()):
319 e = r.index[i]
363 e = r.index[i]
320 print "% 6d % 9d % 7d % 6d % 7d %s.. %s.. %s.." % (
364 print "% 6d % 9d % 7d % 6d % 7d %s.. %s.. %s.." % (
321 i, e[0], e[1], e[2], e[3],
365 i, e[0], e[1], e[2], e[3],
322 hg.hex(e[4][:5]), hg.hex(e[5][:5]), hg.hex(e[6][:5]))
366 hg.hex(e[4][:5]), hg.hex(e[5][:5]), hg.hex(e[6][:5]))
323
367
324 def debugindexdot(ui, file):
368 def debugindexdot(ui, file):
325 r = hg.revlog(hg.opener(""), file, "")
369 r = hg.revlog(hg.opener(""), file, "")
326 print "digraph G {"
370 print "digraph G {"
327 for i in range(r.count()):
371 for i in range(r.count()):
328 e = r.index[i]
372 e = r.index[i]
329 print "\t%d -> %d" % (r.rev(e[4]), i)
373 print "\t%d -> %d" % (r.rev(e[4]), i)
330 if e[5] != hg.nullid:
374 if e[5] != hg.nullid:
331 print "\t%d -> %d" % (r.rev(e[5]), i)
375 print "\t%d -> %d" % (r.rev(e[5]), i)
332 print "}"
376 print "}"
333
377
334 def diff(ui, repo, *files, **opts):
378 def diff(ui, repo, *files, **opts):
335 """diff working directory (or selected files)"""
379 """diff working directory (or selected files)"""
336 revs = []
380 revs = []
337 if opts['rev']:
381 if opts['rev']:
338 revs = map(lambda x: repo.lookup(x), opts['rev'])
382 revs = map(lambda x: repo.lookup(x), opts['rev'])
339
383
340 if len(revs) > 2:
384 if len(revs) > 2:
341 ui.warn("too many revisions to diff\n")
385 ui.warn("too many revisions to diff\n")
342 sys.exit(1)
386 sys.exit(1)
343
387
344 if files:
388 if files:
345 files = relpath(repo, files)
389 files = relpath(repo, files)
346 else:
390 else:
347 files = relpath(repo, [""])
391 files = relpath(repo, [""])
348
392
349 dodiff(ui, repo, os.getcwd(), files, *revs)
393 dodiff(ui, repo, os.getcwd(), files, *revs)
350
394
351 def export(ui, repo, changeset):
395 def export(ui, repo, changeset):
352 """dump the changeset header and diffs for a revision"""
396 """dump the changeset header and diffs for a revision"""
353 node = repo.lookup(changeset)
397 node = repo.lookup(changeset)
354 prev, other = repo.changelog.parents(node)
398 prev, other = repo.changelog.parents(node)
355 change = repo.changelog.read(node)
399 change = repo.changelog.read(node)
356 print "# HG changeset patch"
400 print "# HG changeset patch"
357 print "# User %s" % change[1]
401 print "# User %s" % change[1]
358 print "# Node ID %s" % hg.hex(node)
402 print "# Node ID %s" % hg.hex(node)
359 print "# Parent %s" % hg.hex(prev)
403 print "# Parent %s" % hg.hex(prev)
360 print
404 print
361 if other != hg.nullid:
405 if other != hg.nullid:
362 print "# Parent %s" % hg.hex(other)
406 print "# Parent %s" % hg.hex(other)
363 print change[4].rstrip()
407 print change[4].rstrip()
364 print
408 print
365
409
366 dodiff(ui, repo, "", None, prev, node)
410 dodiff(ui, repo, "", None, prev, node)
367
411
368 def forget(ui, repo, file, *files):
412 def forget(ui, repo, file, *files):
369 """don't add the specified files on the next commit"""
413 """don't add the specified files on the next commit"""
370 repo.forget(relpath(repo, (file,) + files))
414 repo.forget(relpath(repo, (file,) + files))
371
415
372 def heads(ui, repo):
416 def heads(ui, repo):
373 """show current repository heads"""
417 """show current repository heads"""
374 for n in repo.changelog.heads():
418 for n in repo.changelog.heads():
375 show_changeset(ui, repo, changenode=n)
419 show_changeset(ui, repo, changenode=n)
376
420
377 def history(ui, repo):
421 def history(ui, repo):
378 """show the changelog history"""
422 """show the changelog history"""
379 for i in range(repo.changelog.count() - 1, -1, -1):
423 for i in range(repo.changelog.count() - 1, -1, -1):
380 show_changeset(ui, repo, rev=i)
424 show_changeset(ui, repo, rev=i)
381
425
382 def identify(ui, repo):
426 def identify(ui, repo):
383 """print information about the working copy"""
427 """print information about the working copy"""
384 parents = [p for p in repo.dirstate.parents() if p != hg.nullid]
428 parents = [p for p in repo.dirstate.parents() if p != hg.nullid]
385 if not parents:
429 if not parents:
386 ui.write("unknown\n")
430 ui.write("unknown\n")
387 return
431 return
388
432
389 hexfunc = ui.verbose and hg.hex or hg.short
433 hexfunc = ui.verbose and hg.hex or hg.short
390 (c, a, d, u) = repo.diffdir(repo.root)
434 (c, a, d, u) = repo.diffdir(repo.root)
391 output = ["%s%s" % ('+'.join([hexfunc(parent) for parent in parents]),
435 output = ["%s%s" % ('+'.join([hexfunc(parent) for parent in parents]),
392 (c or a or d) and "+" or "")]
436 (c or a or d) and "+" or "")]
393
437
394 if not ui.quiet:
438 if not ui.quiet:
395 # multiple tags for a single parent separated by '/'
439 # multiple tags for a single parent separated by '/'
396 parenttags = ['/'.join(tags)
440 parenttags = ['/'.join(tags)
397 for tags in map(repo.nodetags, parents) if tags]
441 for tags in map(repo.nodetags, parents) if tags]
398 # tags for multiple parents separated by ' + '
442 # tags for multiple parents separated by ' + '
399 output.append(' + '.join(parenttags))
443 output.append(' + '.join(parenttags))
400
444
401 ui.write("%s\n" % ' '.join(output))
445 ui.write("%s\n" % ' '.join(output))
402
446
403 def import_(ui, repo, patch1, *patches, **opts):
447 def import_(ui, repo, patch1, *patches, **opts):
404 """import an ordered set of patches"""
448 """import an ordered set of patches"""
405 try:
449 try:
406 import psyco
450 import psyco
407 psyco.full()
451 psyco.full()
408 except:
452 except:
409 pass
453 pass
410
454
411 patches = (patch1,) + patches
455 patches = (patch1,) + patches
412
456
413 d = opts["base"]
457 d = opts["base"]
414 strip = opts["strip"]
458 strip = opts["strip"]
415
459
416 for patch in patches:
460 for patch in patches:
417 ui.status("applying %s\n" % patch)
461 ui.status("applying %s\n" % patch)
418 pf = os.path.join(d, patch)
462 pf = os.path.join(d, patch)
419
463
420 text = ""
464 text = ""
421 for l in file(pf):
465 for l in file(pf):
422 if l[:4] == "--- ": break
466 if l[:4] == "--- ": break
423 text += l
467 text += l
424
468
425 # make sure text isn't empty
469 # make sure text isn't empty
426 if not text: text = "imported patch %s\n" % patch
470 if not text: text = "imported patch %s\n" % patch
427
471
428 f = os.popen("patch -p%d < %s" % (strip, pf))
472 f = os.popen("patch -p%d < %s" % (strip, pf))
429 files = []
473 files = []
430 for l in f.read().splitlines():
474 for l in f.read().splitlines():
431 l.rstrip('\r\n');
475 l.rstrip('\r\n');
432 ui.status("%s\n" % l)
476 ui.status("%s\n" % l)
433 if l[:14] == 'patching file ':
477 if l[:14] == 'patching file ':
434 pf = l[14:]
478 pf = l[14:]
435 if pf not in files:
479 if pf not in files:
436 files.append(pf)
480 files.append(pf)
437 patcherr = f.close()
481 patcherr = f.close()
438 if patcherr:
482 if patcherr:
439 sys.stderr.write("patch failed")
483 sys.stderr.write("patch failed")
440 sys.exit(1)
484 sys.exit(1)
441
485
442 if len(files) > 0:
486 if len(files) > 0:
443 addremove(ui, repo, *files)
487 addremove(ui, repo, *files)
444 repo.commit(files, text)
488 repo.commit(files, text)
445
489
446 def init(ui, source=None, **opts):
490 def init(ui, source=None, **opts):
447 """create a new repository or copy an existing one"""
491 """create a new repository or (deprecated, use clone) copy an existing one"""
448
492
449 if source:
493 if source:
450 paths = {}
494 ui.warn("this use of init is deprecated: use \"hg clone\" instead\n")
451 for name, path in ui.configitems("paths"):
495 opts['no-update'] = not opts['update']
452 paths[name] = path
496 clone(ui, source, None, **opts)
453
454 if source in paths: source = paths[source]
455
456 link = 0
457 if not source.startswith("http://"):
458 d1 = os.stat(os.getcwd()).st_dev
459 d2 = os.stat(source).st_dev
460 if d1 == d2: link = 1
461
462 if link:
463 ui.debug("copying by hardlink\n")
464 os.system("cp -al %s/.hg .hg" % source)
465 try:
466 os.remove(".hg/dirstate")
467 except: pass
468
469 repo = hg.repository(ui, ".")
470
471 else:
472 repo = hg.repository(ui, ".", create=1)
473 other = hg.repository(ui, source)
474 cg = repo.getchangegroup(other)
475 repo.addchangegroup(cg)
476
477 f = repo.opener("hgrc", "w")
478 f.write("[paths]\n")
479 f.write("default = %s\n" % source)
480
481 if opts['update']:
482 update(ui, repo)
483 else:
497 else:
484 repo = hg.repository(ui, ".", create=1)
498 repo = hg.repository(ui, ".", create=1)
485
499
486 def log(ui, repo, f):
500 def log(ui, repo, f):
487 """show the revision history of a single file"""
501 """show the revision history of a single file"""
488 f = relpath(repo, [f])[0]
502 f = relpath(repo, [f])[0]
489
503
490 r = repo.file(f)
504 r = repo.file(f)
491 for i in range(r.count() - 1, -1, -1):
505 for i in range(r.count() - 1, -1, -1):
492 show_changeset(ui, repo, filelog=r, rev=i)
506 show_changeset(ui, repo, filelog=r, rev=i)
493
507
494 def manifest(ui, repo, rev = []):
508 def manifest(ui, repo, rev = []):
495 """output the latest or given revision of the project manifest"""
509 """output the latest or given revision of the project manifest"""
496 n = repo.manifest.tip()
510 n = repo.manifest.tip()
497 if rev:
511 if rev:
498 n = repo.manifest.lookup(rev)
512 n = repo.manifest.lookup(rev)
499 m = repo.manifest.read(n)
513 m = repo.manifest.read(n)
500 mf = repo.manifest.readflags(n)
514 mf = repo.manifest.readflags(n)
501 files = m.keys()
515 files = m.keys()
502 files.sort()
516 files.sort()
503
517
504 for f in files:
518 for f in files:
505 ui.write("%40s %3s %s\n" % (hg.hex(m[f]), mf[f] and "755" or "644", f))
519 ui.write("%40s %3s %s\n" % (hg.hex(m[f]), mf[f] and "755" or "644", f))
506
520
507 def parents(ui, repo, node = None):
521 def parents(ui, repo, node = None):
508 '''show the parents of the current working dir'''
522 '''show the parents of the current working dir'''
509 if node:
523 if node:
510 p = repo.changelog.parents(repo.lookup(hg.bin(node)))
524 p = repo.changelog.parents(repo.lookup(hg.bin(node)))
511 else:
525 else:
512 p = repo.dirstate.parents()
526 p = repo.dirstate.parents()
513
527
514 for n in p:
528 for n in p:
515 if n != hg.nullid:
529 if n != hg.nullid:
516 show_changeset(ui, repo, changenode=n)
530 show_changeset(ui, repo, changenode=n)
517
531
518 def pull(ui, repo, source="default", **opts):
532 def pull(ui, repo, source="default", **opts):
519 """pull changes from the specified source"""
533 """pull changes from the specified source"""
520 paths = {}
534 paths = {}
521 for name, path in ui.configitems("paths"):
535 for name, path in ui.configitems("paths"):
522 paths[name] = path
536 paths[name] = path
523
537
524 if source in paths:
538 if source in paths:
525 source = paths[source]
539 source = paths[source]
526
540
527 ui.status('pulling from %s\n' % (source))
541 ui.status('pulling from %s\n' % (source))
528
542
529 other = hg.repository(ui, source)
543 other = hg.repository(ui, source)
530 cg = repo.getchangegroup(other)
544 cg = repo.getchangegroup(other)
531 r = repo.addchangegroup(cg)
545 r = repo.addchangegroup(cg)
532 if cg and not r:
546 if cg and not r:
533 if opts['update']:
547 if opts['update']:
534 return update(ui, repo)
548 return update(ui, repo)
535 else:
549 else:
536 ui.status("(run 'hg update' to get a working copy)\n")
550 ui.status("(run 'hg update' to get a working copy)\n")
537
551
538 return r
552 return r
539
553
540 def push(ui, repo, dest="default-push"):
554 def push(ui, repo, dest="default-push"):
541 """push changes to the specified destination"""
555 """push changes to the specified destination"""
542 paths = {}
556 paths = {}
543 for name, path in ui.configitems("paths"):
557 for name, path in ui.configitems("paths"):
544 paths[name] = path
558 paths[name] = path
545
559
546 if dest in paths: dest = paths[dest]
560 if dest in paths: dest = paths[dest]
547
561
548 if not dest.startswith("ssh://"):
562 if not dest.startswith("ssh://"):
549 ui.warn("abort: can only push to ssh:// destinations currently\n")
563 ui.warn("abort: can only push to ssh:// destinations currently\n")
550 return 1
564 return 1
551
565
552 m = re.match(r'ssh://(([^@]+)@)?([^:/]+)(:(\d+))?(/(.*))?', dest)
566 m = re.match(r'ssh://(([^@]+)@)?([^:/]+)(:(\d+))?(/(.*))?', dest)
553 if not m:
567 if not m:
554 ui.warn("abort: couldn't parse destination %s\n" % dest)
568 ui.warn("abort: couldn't parse destination %s\n" % dest)
555 return 1
569 return 1
556
570
557 user, host, port, path = map(m.group, (2, 3, 5, 7))
571 user, host, port, path = map(m.group, (2, 3, 5, 7))
558 host = user and ("%s@%s" % (user, host)) or host
572 host = user and ("%s@%s" % (user, host)) or host
559 port = port and (" -p %s") % port or ""
573 port = port and (" -p %s") % port or ""
560 path = path or ""
574 path = path or ""
561
575
562 sport = random.randrange(30000, 60000)
576 sport = random.randrange(30000, 60000)
563 cmd = "ssh %s%s -R %d:localhost:%d 'cd %s; hg pull http://localhost:%d/'"
577 cmd = "ssh %s%s -R %d:localhost:%d 'cd %s; hg pull http://localhost:%d/'"
564 cmd = cmd % (host, port, sport+1, sport, path, sport+1)
578 cmd = cmd % (host, port, sport+1, sport, path, sport+1)
565
579
566 child = os.fork()
580 child = os.fork()
567 if not child:
581 if not child:
568 sys.stdout = file("/dev/null", "w")
582 sys.stdout = file("/dev/null", "w")
569 sys.stderr = sys.stdout
583 sys.stderr = sys.stdout
570 hgweb.server(repo.root, "pull", "", "localhost", sport)
584 hgweb.server(repo.root, "pull", "", "localhost", sport)
571 else:
585 else:
572 r = os.system(cmd)
586 r = os.system(cmd)
573 os.kill(child, signal.SIGTERM)
587 os.kill(child, signal.SIGTERM)
574 return r
588 return r
575
589
576 def rawcommit(ui, repo, *flist, **rc):
590 def rawcommit(ui, repo, *flist, **rc):
577 "raw commit interface"
591 "raw commit interface"
578
592
579 text = rc['text']
593 text = rc['text']
580 if not text and rc['logfile']:
594 if not text and rc['logfile']:
581 try: text = open(rc['logfile']).read()
595 try: text = open(rc['logfile']).read()
582 except IOError: pass
596 except IOError: pass
583 if not text and not rc['logfile']:
597 if not text and not rc['logfile']:
584 print "missing commit text"
598 print "missing commit text"
585 return 1
599 return 1
586
600
587 files = relpath(repo, list(flist))
601 files = relpath(repo, list(flist))
588 if rc['files']:
602 if rc['files']:
589 files += open(rc['files']).read().splitlines()
603 files += open(rc['files']).read().splitlines()
590
604
591 rc['parent'] = map(repo.lookup, rc['parent'])
605 rc['parent'] = map(repo.lookup, rc['parent'])
592
606
593 repo.rawcommit(files, text, rc['user'], rc['date'], *rc['parent'])
607 repo.rawcommit(files, text, rc['user'], rc['date'], *rc['parent'])
594
608
595 def recover(ui, repo):
609 def recover(ui, repo):
596 """roll back an interrupted transaction"""
610 """roll back an interrupted transaction"""
597 repo.recover()
611 repo.recover()
598
612
599 def remove(ui, repo, file, *files):
613 def remove(ui, repo, file, *files):
600 """remove the specified files on the next commit"""
614 """remove the specified files on the next commit"""
601 repo.remove(relpath(repo, (file,) + files))
615 repo.remove(relpath(repo, (file,) + files))
602
616
603 def root(ui, repo):
617 def root(ui, repo):
604 """print the root (top) of the current working dir"""
618 """print the root (top) of the current working dir"""
605 ui.write(repo.root + "\n")
619 ui.write(repo.root + "\n")
606
620
607 def serve(ui, repo, **opts):
621 def serve(ui, repo, **opts):
608 """export the repository via HTTP"""
622 """export the repository via HTTP"""
609 hgweb.server(repo.root, opts["name"], opts["templates"],
623 hgweb.server(repo.root, opts["name"], opts["templates"],
610 opts["address"], opts["port"])
624 opts["address"], opts["port"])
611
625
612 def status(ui, repo):
626 def status(ui, repo):
613 '''show changed files in the working directory
627 '''show changed files in the working directory
614
628
615 C = changed
629 C = changed
616 A = added
630 A = added
617 R = removed
631 R = removed
618 ? = not tracked'''
632 ? = not tracked'''
619
633
620 (c, a, d, u) = repo.diffdir(os.getcwd())
634 (c, a, d, u) = repo.diffdir(os.getcwd())
621 (c, a, d, u) = map(lambda x: relfilter(repo, x), (c, a, d, u))
635 (c, a, d, u) = map(lambda x: relfilter(repo, x), (c, a, d, u))
622
636
623 for f in c: print "C", f
637 for f in c: print "C", f
624 for f in a: print "A", f
638 for f in a: print "A", f
625 for f in d: print "R", f
639 for f in d: print "R", f
626 for f in u: print "?", f
640 for f in u: print "?", f
627
641
628 def tag(ui, repo, name, rev = None, **opts):
642 def tag(ui, repo, name, rev = None, **opts):
629 """add a tag for the current tip or a given revision"""
643 """add a tag for the current tip or a given revision"""
630
644
631 if name == "tip":
645 if name == "tip":
632 ui.warn("abort: 'tip' is a reserved name!\n")
646 ui.warn("abort: 'tip' is a reserved name!\n")
633 return -1
647 return -1
634
648
635 (c, a, d, u) = repo.diffdir(repo.root)
649 (c, a, d, u) = repo.diffdir(repo.root)
636 for x in (c, a, d, u):
650 for x in (c, a, d, u):
637 if ".hgtags" in x:
651 if ".hgtags" in x:
638 ui.warn("abort: working copy of .hgtags is changed!\n")
652 ui.warn("abort: working copy of .hgtags is changed!\n")
639 ui.status("(please commit .hgtags manually)\n")
653 ui.status("(please commit .hgtags manually)\n")
640 return -1
654 return -1
641
655
642 if rev:
656 if rev:
643 r = hg.hex(repo.lookup(rev))
657 r = hg.hex(repo.lookup(rev))
644 else:
658 else:
645 r = hg.hex(repo.changelog.tip())
659 r = hg.hex(repo.changelog.tip())
646
660
647 add = 0
661 add = 0
648 if not os.path.exists(repo.wjoin(".hgtags")): add = 1
662 if not os.path.exists(repo.wjoin(".hgtags")): add = 1
649 repo.wfile(".hgtags", "a").write("%s %s\n" % (r, name))
663 repo.wfile(".hgtags", "a").write("%s %s\n" % (r, name))
650 if add: repo.add([".hgtags"])
664 if add: repo.add([".hgtags"])
651
665
652 if not opts['text']:
666 if not opts['text']:
653 opts['text'] = "Added tag %s for changeset %s" % (name, r)
667 opts['text'] = "Added tag %s for changeset %s" % (name, r)
654
668
655 repo.commit([".hgtags"], opts['text'], opts['user'], opts['date'])
669 repo.commit([".hgtags"], opts['text'], opts['user'], opts['date'])
656
670
657 def tags(ui, repo):
671 def tags(ui, repo):
658 """list repository tags"""
672 """list repository tags"""
659
673
660 l = repo.tagslist()
674 l = repo.tagslist()
661 l.reverse()
675 l.reverse()
662 for t, n in l:
676 for t, n in l:
663 try:
677 try:
664 r = "%5d:%s" % (repo.changelog.rev(n), hg.hex(n))
678 r = "%5d:%s" % (repo.changelog.rev(n), hg.hex(n))
665 except KeyError:
679 except KeyError:
666 r = " ?:?"
680 r = " ?:?"
667 ui.write("%-30s %s\n" % (t, r))
681 ui.write("%-30s %s\n" % (t, r))
668
682
669 def tip(ui, repo):
683 def tip(ui, repo):
670 """show the tip revision"""
684 """show the tip revision"""
671 n = repo.changelog.tip()
685 n = repo.changelog.tip()
672 show_changeset(ui, repo, changenode=n)
686 show_changeset(ui, repo, changenode=n)
673
687
674 def undo(ui, repo):
688 def undo(ui, repo):
675 """undo the last transaction"""
689 """undo the last transaction"""
676 repo.undo()
690 repo.undo()
677
691
678 def update(ui, repo, node=None, merge=False, clean=False):
692 def update(ui, repo, node=None, merge=False, clean=False):
679 '''update or merge working directory
693 '''update or merge working directory
680
694
681 If there are no outstanding changes in the working directory and
695 If there are no outstanding changes in the working directory and
682 there is a linear relationship between the current version and the
696 there is a linear relationship between the current version and the
683 requested version, the result is the requested version.
697 requested version, the result is the requested version.
684
698
685 Otherwise the result is a merge between the contents of the
699 Otherwise the result is a merge between the contents of the
686 current working directory and the requested version. Files that
700 current working directory and the requested version. Files that
687 changed between either parent are marked as changed for the next
701 changed between either parent are marked as changed for the next
688 commit and a commit must be performed before any further updates
702 commit and a commit must be performed before any further updates
689 are allowed.
703 are allowed.
690 '''
704 '''
691 node = node and repo.lookup(node) or repo.changelog.tip()
705 node = node and repo.lookup(node) or repo.changelog.tip()
692 return repo.update(node, allow=merge, force=clean)
706 return repo.update(node, allow=merge, force=clean)
693
707
694 def verify(ui, repo):
708 def verify(ui, repo):
695 """verify the integrity of the repository"""
709 """verify the integrity of the repository"""
696 return repo.verify()
710 return repo.verify()
697
711
698 # Command options and aliases are listed here, alphabetically
712 # Command options and aliases are listed here, alphabetically
699
713
700 table = {
714 table = {
701 "add": (add, [], "hg add [files]"),
715 "add": (add, [], "hg add [files]"),
702 "addremove": (addremove, [], "hg addremove [files]"),
716 "addremove": (addremove, [], "hg addremove [files]"),
703 "annotate": (annotate,
717 "annotate": (annotate,
704 [('r', 'revision', '', 'revision'),
718 [('r', 'revision', '', 'revision'),
705 ('u', 'user', None, 'show user'),
719 ('u', 'user', None, 'show user'),
706 ('n', 'number', None, 'show revision number'),
720 ('n', 'number', None, 'show revision number'),
707 ('c', 'changeset', None, 'show changeset')],
721 ('c', 'changeset', None, 'show changeset')],
708 'hg annotate [-u] [-c] [-n] [-r id] [files]'),
722 'hg annotate [-u] [-c] [-n] [-r id] [files]'),
709 "cat": (cat, [], 'hg cat <file> [rev]'),
723 "cat": (cat, [], 'hg cat <file> [rev]'),
724 "clone": (clone, [('U', 'no-update', None, 'skip update after cloning')],
725 'hg clone [options] <source> [dest]'),
710 "commit|ci": (commit,
726 "commit|ci": (commit,
711 [('t', 'text', "", 'commit text'),
727 [('t', 'text', "", 'commit text'),
712 ('A', 'addremove', None, 'run add/remove during commit'),
728 ('A', 'addremove', None, 'run add/remove during commit'),
713 ('l', 'logfile', "", 'commit text file'),
729 ('l', 'logfile', "", 'commit text file'),
714 ('d', 'date', "", 'data'),
730 ('d', 'date', "", 'data'),
715 ('u', 'user', "", 'user')],
731 ('u', 'user', "", 'user')],
716 'hg commit [files]'),
732 'hg commit [files]'),
717 "copy": (copy, [], 'hg copy <source> <dest>'),
733 "copy": (copy, [], 'hg copy <source> <dest>'),
718 "debugcheckdirstate": (debugcheckdirstate, [], 'debugcheckdirstate'),
734 "debugcheckdirstate": (debugcheckdirstate, [], 'debugcheckdirstate'),
719 "debugdumpdirstate": (debugdumpdirstate, [], 'debugdumpdirstate'),
735 "debugdumpdirstate": (debugdumpdirstate, [], 'debugdumpdirstate'),
720 "debugindex": (debugindex, [], 'debugindex <file>'),
736 "debugindex": (debugindex, [], 'debugindex <file>'),
721 "debugindexdot": (debugindexdot, [], 'debugindexdot <file>'),
737 "debugindexdot": (debugindexdot, [], 'debugindexdot <file>'),
722 "diff": (diff, [('r', 'rev', [], 'revision')],
738 "diff": (diff, [('r', 'rev', [], 'revision')],
723 'hg diff [-r A] [-r B] [files]'),
739 'hg diff [-r A] [-r B] [files]'),
724 "export": (export, [], "hg export <changeset>"),
740 "export": (export, [], "hg export <changeset>"),
725 "forget": (forget, [], "hg forget [files]"),
741 "forget": (forget, [], "hg forget [files]"),
726 "heads": (heads, [], 'hg heads'),
742 "heads": (heads, [], 'hg heads'),
727 "history": (history, [], 'hg history'),
743 "history": (history, [], 'hg history'),
728 "help": (help, [], 'hg help [command]'),
744 "help": (help, [], 'hg help [command]'),
729 "identify|id": (identify, [], 'hg identify'),
745 "identify|id": (identify, [], 'hg identify'),
730 "import|patch": (import_,
746 "import|patch": (import_,
731 [('p', 'strip', 1, 'path strip'),
747 [('p', 'strip', 1, 'path strip'),
732 ('b', 'base', "", 'base path')],
748 ('b', 'base', "", 'base path')],
733 "hg import [options] <patches>"),
749 "hg import [options] <patches>"),
734 "init": (init, [('u', 'update', None, 'update after init')],
750 "init": (init, [('u', 'update', None, 'update after init')],
735 'hg init [options] [url]'),
751 'hg init [options] [url]'),
736 "log": (log, [], 'hg log <file>'),
752 "log": (log, [], 'hg log <file>'),
737 "manifest": (manifest, [], 'hg manifest [rev]'),
753 "manifest": (manifest, [], 'hg manifest [rev]'),
738 "parents": (parents, [], 'hg parents [node]'),
754 "parents": (parents, [], 'hg parents [node]'),
739 "pull": (pull,
755 "pull": (pull,
740 [('u', 'update', None, 'update working directory')],
756 [('u', 'update', None, 'update working directory')],
741 'hg pull [options] [source]'),
757 'hg pull [options] [source]'),
742 "push": (push, [], 'hg push <destination>'),
758 "push": (push, [], 'hg push <destination>'),
743 "rawcommit": (rawcommit,
759 "rawcommit": (rawcommit,
744 [('p', 'parent', [], 'parent'),
760 [('p', 'parent', [], 'parent'),
745 ('d', 'date', "", 'data'),
761 ('d', 'date', "", 'data'),
746 ('u', 'user', "", 'user'),
762 ('u', 'user', "", 'user'),
747 ('F', 'files', "", 'file list'),
763 ('F', 'files', "", 'file list'),
748 ('t', 'text', "", 'commit text'),
764 ('t', 'text', "", 'commit text'),
749 ('l', 'logfile', "", 'commit text file')],
765 ('l', 'logfile', "", 'commit text file')],
750 'hg rawcommit [options] [files]'),
766 'hg rawcommit [options] [files]'),
751 "recover": (recover, [], "hg recover"),
767 "recover": (recover, [], "hg recover"),
752 "remove|rm": (remove, [], "hg remove [files]"),
768 "remove|rm": (remove, [], "hg remove [files]"),
753 "root": (root, [], "hg root"),
769 "root": (root, [], "hg root"),
754 "serve": (serve, [('p', 'port', 8000, 'listen port'),
770 "serve": (serve, [('p', 'port', 8000, 'listen port'),
755 ('a', 'address', '', 'interface address'),
771 ('a', 'address', '', 'interface address'),
756 ('n', 'name', os.getcwd(), 'repository name'),
772 ('n', 'name', os.getcwd(), 'repository name'),
757 ('t', 'templates', "", 'template map')],
773 ('t', 'templates', "", 'template map')],
758 "hg serve [options]"),
774 "hg serve [options]"),
759 "status": (status, [], 'hg status'),
775 "status": (status, [], 'hg status'),
760 "tag": (tag, [('t', 'text', "", 'commit text'),
776 "tag": (tag, [('t', 'text', "", 'commit text'),
761 ('d', 'date', "", 'date'),
777 ('d', 'date', "", 'date'),
762 ('u', 'user', "", 'user')],
778 ('u', 'user', "", 'user')],
763 'hg tag [options] <name> [rev]'),
779 'hg tag [options] <name> [rev]'),
764 "tags": (tags, [], 'hg tags'),
780 "tags": (tags, [], 'hg tags'),
765 "tip": (tip, [], 'hg tip'),
781 "tip": (tip, [], 'hg tip'),
766 "undo": (undo, [], 'hg undo'),
782 "undo": (undo, [], 'hg undo'),
767 "update|up|checkout|co":
783 "update|up|checkout|co":
768 (update,
784 (update,
769 [('m', 'merge', None, 'allow merging of conflicts'),
785 [('m', 'merge', None, 'allow merging of conflicts'),
770 ('C', 'clean', None, 'overwrite locally modified files')],
786 ('C', 'clean', None, 'overwrite locally modified files')],
771 'hg update [options] [node]'),
787 'hg update [options] [node]'),
772 "verify": (verify, [], 'hg verify'),
788 "verify": (verify, [], 'hg verify'),
773 "version": (show_version, [], 'hg version'),
789 "version": (show_version, [], 'hg version'),
774 }
790 }
775
791
776 norepo = "init version help debugindex debugindexdot"
792 norepo = "clone init version help debugindex debugindexdot"
777
793
778 def find(cmd):
794 def find(cmd):
779 for e in table.keys():
795 for e in table.keys():
780 if re.match("(%s)$" % e, cmd):
796 if re.match("(%s)$" % e, cmd):
781 return table[e]
797 return table[e]
782
798
783 raise UnknownCommand(cmd)
799 raise UnknownCommand(cmd)
784
800
785 class SignalInterrupt(Exception): pass
801 class SignalInterrupt(Exception): pass
786
802
787 def catchterm(*args):
803 def catchterm(*args):
788 raise SignalInterrupt
804 raise SignalInterrupt
789
805
790 def run():
806 def run():
791 sys.exit(dispatch(sys.argv[1:]))
807 sys.exit(dispatch(sys.argv[1:]))
792
808
793 def dispatch(args):
809 def dispatch(args):
794 options = {}
810 options = {}
795 opts = [('v', 'verbose', None, 'verbose'),
811 opts = [('v', 'verbose', None, 'verbose'),
796 ('d', 'debug', None, 'debug'),
812 ('d', 'debug', None, 'debug'),
797 ('q', 'quiet', None, 'quiet'),
813 ('q', 'quiet', None, 'quiet'),
798 ('p', 'profile', None, 'profile'),
814 ('p', 'profile', None, 'profile'),
799 ('y', 'noninteractive', None, 'run non-interactively'),
815 ('y', 'noninteractive', None, 'run non-interactively'),
800 ('', 'version', None, 'output version information and exit'),
816 ('', 'version', None, 'output version information and exit'),
801 ]
817 ]
802
818
803 args = fancyopts.fancyopts(args, opts, options,
819 args = fancyopts.fancyopts(args, opts, options,
804 'hg [options] <command> [options] [files]')
820 'hg [options] <command> [options] [files]')
805
821
806 if not args:
822 if not args:
807 cmd = "help"
823 cmd = "help"
808 else:
824 else:
809 cmd, args = args[0], args[1:]
825 cmd, args = args[0], args[1:]
810
826
811 u = ui.ui(options["verbose"], options["debug"], options["quiet"],
827 u = ui.ui(options["verbose"], options["debug"], options["quiet"],
812 not options["noninteractive"])
828 not options["noninteractive"])
813
829
814 if options["version"]:
830 if options["version"]:
815 show_version(u)
831 show_version(u)
816 sys.exit(0)
832 sys.exit(0)
817
833
818 try:
834 try:
819 i = find(cmd)
835 i = find(cmd)
820 except UnknownCommand:
836 except UnknownCommand:
821 u.warn("hg: unknown command '%s'\n" % cmd)
837 u.warn("hg: unknown command '%s'\n" % cmd)
822 help(u)
838 help(u)
823 sys.exit(1)
839 sys.exit(1)
824
840
825 signal.signal(signal.SIGTERM, catchterm)
841 signal.signal(signal.SIGTERM, catchterm)
826
842
827 cmdoptions = {}
843 cmdoptions = {}
828 try:
844 try:
829 args = fancyopts.fancyopts(args, i[1], cmdoptions, i[2])
845 args = fancyopts.fancyopts(args, i[1], cmdoptions, i[2])
830 except fancyopts.getopt.GetoptError, inst:
846 except fancyopts.getopt.GetoptError, inst:
831 u.warn("hg %s: %s\n" % (cmd, inst))
847 u.warn("hg %s: %s\n" % (cmd, inst))
832 help(u, cmd)
848 help(u, cmd)
833 sys.exit(-1)
849 sys.exit(-1)
834
850
835 if cmd not in norepo.split():
851 if cmd not in norepo.split():
836 repo = hg.repository(ui = u)
852 repo = hg.repository(ui = u)
837 d = lambda: i[0](u, repo, *args, **cmdoptions)
853 d = lambda: i[0](u, repo, *args, **cmdoptions)
838 else:
854 else:
839 d = lambda: i[0](u, *args, **cmdoptions)
855 d = lambda: i[0](u, *args, **cmdoptions)
840
856
841 try:
857 try:
842 if options['profile']:
858 if options['profile']:
843 import hotshot, hotshot.stats
859 import hotshot, hotshot.stats
844 prof = hotshot.Profile("hg.prof")
860 prof = hotshot.Profile("hg.prof")
845 r = prof.runcall(d)
861 r = prof.runcall(d)
846 prof.close()
862 prof.close()
847 stats = hotshot.stats.load("hg.prof")
863 stats = hotshot.stats.load("hg.prof")
848 stats.strip_dirs()
864 stats.strip_dirs()
849 stats.sort_stats('time', 'calls')
865 stats.sort_stats('time', 'calls')
850 stats.print_stats(40)
866 stats.print_stats(40)
851 return r
867 return r
852 else:
868 else:
853 return d()
869 return d()
854 except SignalInterrupt:
870 except SignalInterrupt:
855 u.warn("killed!\n")
871 u.warn("killed!\n")
856 except KeyboardInterrupt:
872 except KeyboardInterrupt:
857 u.warn("interrupted!\n")
873 u.warn("interrupted!\n")
858 except IOError, inst:
874 except IOError, inst:
859 if hasattr(inst, "code"):
875 if hasattr(inst, "code"):
860 u.warn("abort: %s\n" % inst)
876 u.warn("abort: %s\n" % inst)
861 elif hasattr(inst, "reason"):
877 elif hasattr(inst, "reason"):
862 u.warn("abort: error %d: %s\n" % (inst.reason[0], inst.reason[1]))
878 u.warn("abort: error %d: %s\n" % (inst.reason[0], inst.reason[1]))
863 elif hasattr(inst, "args") and inst[0] == errno.EPIPE:
879 elif hasattr(inst, "args") and inst[0] == errno.EPIPE:
864 u.warn("broken pipe\n")
880 u.warn("broken pipe\n")
865 else:
881 else:
866 raise
882 raise
867 except TypeError, inst:
883 except TypeError, inst:
868 # was this an argument error?
884 # was this an argument error?
869 tb = traceback.extract_tb(sys.exc_info()[2])
885 tb = traceback.extract_tb(sys.exc_info()[2])
870 if len(tb) > 2: # no
886 if len(tb) > 2: # no
871 raise
887 raise
872 u.debug(inst, "\n")
888 u.debug(inst, "\n")
873 u.warn("%s: invalid arguments\n" % i[0].__name__)
889 u.warn("%s: invalid arguments\n" % i[0].__name__)
874 help(u, cmd)
890 help(u, cmd)
875 sys.exit(-1)
891 sys.exit(-1)
876
892
@@ -1,34 +1,32 b''
1 #!/bin/bash
1 #!/bin/bash
2
2
3 mkdir copy
3 hg clone http://localhost:20059/ copy
4 cd copy
4 cd copy
5 hg init http://localhost:20059/
6 hg verify
5 hg verify
7 hg co
6 hg co
8 cat foo
7 cat foo
9 hg manifest
8 hg manifest
10
9
11 cat > dumb.py <<EOF
10 cat > dumb.py <<EOF
12 import BaseHTTPServer, SimpleHTTPServer, signal
11 import BaseHTTPServer, SimpleHTTPServer, signal
13
12
14 def run(server_class=BaseHTTPServer.HTTPServer,
13 def run(server_class=BaseHTTPServer.HTTPServer,
15 handler_class=SimpleHTTPServer.SimpleHTTPRequestHandler):
14 handler_class=SimpleHTTPServer.SimpleHTTPRequestHandler):
16 server_address = ('localhost', 20059)
15 server_address = ('localhost', 20059)
17 httpd = server_class(server_address, handler_class)
16 httpd = server_class(server_address, handler_class)
18 httpd.serve_forever()
17 httpd.serve_forever()
19
18
20 signal.signal(signal.SIGTERM, lambda x: sys.exit(0))
19 signal.signal(signal.SIGTERM, lambda x: sys.exit(0))
21 run()
20 run()
22 EOF
21 EOF
23
22
24 python dumb.py 2>/dev/null &
23 python dumb.py 2>/dev/null &
25
24
26 mkdir copy2
25 hg clone http://localhost:20059/foo copy2
27 cd copy2
26 cd copy2
28 hg init http://localhost:20059/foo
29 hg verify
27 hg verify
30 hg co
28 hg co
31 cat foo
29 cat foo
32 hg manifest
30 hg manifest
33
31
34 kill %1
32 kill %1
@@ -1,88 +1,90 b''
1 + hg -q help
1 + hg -q help
2 hg commands:
2 hg commands:
3
3
4 add add the specified files on the next commit
4 add add the specified files on the next commit
5 addremove add all new files, delete all missing files
5 addremove add all new files, delete all missing files
6 annotate show changeset information per file line
6 annotate show changeset information per file line
7 cat output the latest or given revision of a file
7 cat output the latest or given revision of a file
8 clone make a copy of an existing repository
8 commit commit the specified files or all outstanding changes
9 commit commit the specified files or all outstanding changes
9 copy mark a file as copied or renamed for the next commit
10 copy mark a file as copied or renamed for the next commit
10 diff diff working directory (or selected files)
11 diff diff working directory (or selected files)
11 export dump the changeset header and diffs for a revision
12 export dump the changeset header and diffs for a revision
12 forget don't add the specified files on the next commit
13 forget don't add the specified files on the next commit
13 heads show current repository heads
14 heads show current repository heads
14 help show help for a given command or all commands
15 help show help for a given command or all commands
15 history show the changelog history
16 history show the changelog history
16 identify print information about the working copy
17 identify print information about the working copy
17 import import an ordered set of patches
18 import import an ordered set of patches
18 init create a new repository or copy an existing one
19 init create a new repository or (deprecated, use clone) copy an existing one
19 log show the revision history of a single file
20 log show the revision history of a single file
20 manifest output the latest or given revision of the project manifest
21 manifest output the latest or given revision of the project manifest
21 parents show the parents of the current working dir
22 parents show the parents of the current working dir
22 pull pull changes from the specified source
23 pull pull changes from the specified source
23 push push changes to the specified destination
24 push push changes to the specified destination
24 rawcommit raw commit interface
25 rawcommit raw commit interface
25 recover roll back an interrupted transaction
26 recover roll back an interrupted transaction
26 remove remove the specified files on the next commit
27 remove remove the specified files on the next commit
27 root print the root (top) of the current working dir
28 root print the root (top) of the current working dir
28 serve export the repository via HTTP
29 serve export the repository via HTTP
29 status show changed files in the working directory
30 status show changed files in the working directory
30 tag add a tag for the current tip or a given revision
31 tag add a tag for the current tip or a given revision
31 tags list repository tags
32 tags list repository tags
32 tip show the tip revision
33 tip show the tip revision
33 undo undo the last transaction
34 undo undo the last transaction
34 update update or merge working directory
35 update update or merge working directory
35 verify verify the integrity of the repository
36 verify verify the integrity of the repository
36 version output version and copyright information
37 version output version and copyright information
37 + hg add -h
38 + hg add -h
38 hg add: option -h not recognized
39 hg add: option -h not recognized
39 hg add [files]
40 hg add [files]
40
41
41 add the specified files on the next commit
42 add the specified files on the next commit
42 + hg help diff
43 + hg help diff
43 hg diff [-r A] [-r B] [files]
44 hg diff [-r A] [-r B] [files]
44
45
45 -r --rev
46 -r --rev
46 revision
47 revision
47
48
48 diff working directory (or selected files)
49 diff working directory (or selected files)
49 + hg help foo
50 + hg help foo
50 hg: unknown command foo
51 hg: unknown command foo
51 + hg -q commands
52 + hg -q commands
52 hg: unknown command 'commands'
53 hg: unknown command 'commands'
53 hg commands:
54 hg commands:
54
55
55 add add the specified files on the next commit
56 add add the specified files on the next commit
56 addremove add all new files, delete all missing files
57 addremove add all new files, delete all missing files
57 annotate show changeset information per file line
58 annotate show changeset information per file line
58 cat output the latest or given revision of a file
59 cat output the latest or given revision of a file
60 clone make a copy of an existing repository
59 commit commit the specified files or all outstanding changes
61 commit commit the specified files or all outstanding changes
60 copy mark a file as copied or renamed for the next commit
62 copy mark a file as copied or renamed for the next commit
61 diff diff working directory (or selected files)
63 diff diff working directory (or selected files)
62 export dump the changeset header and diffs for a revision
64 export dump the changeset header and diffs for a revision
63 forget don't add the specified files on the next commit
65 forget don't add the specified files on the next commit
64 heads show current repository heads
66 heads show current repository heads
65 help show help for a given command or all commands
67 help show help for a given command or all commands
66 history show the changelog history
68 history show the changelog history
67 identify print information about the working copy
69 identify print information about the working copy
68 import import an ordered set of patches
70 import import an ordered set of patches
69 init create a new repository or copy an existing one
71 init create a new repository or (deprecated, use clone) copy an existing one
70 log show the revision history of a single file
72 log show the revision history of a single file
71 manifest output the latest or given revision of the project manifest
73 manifest output the latest or given revision of the project manifest
72 parents show the parents of the current working dir
74 parents show the parents of the current working dir
73 pull pull changes from the specified source
75 pull pull changes from the specified source
74 push push changes to the specified destination
76 push push changes to the specified destination
75 rawcommit raw commit interface
77 rawcommit raw commit interface
76 recover roll back an interrupted transaction
78 recover roll back an interrupted transaction
77 remove remove the specified files on the next commit
79 remove remove the specified files on the next commit
78 root print the root (top) of the current working dir
80 root print the root (top) of the current working dir
79 serve export the repository via HTTP
81 serve export the repository via HTTP
80 status show changed files in the working directory
82 status show changed files in the working directory
81 tag add a tag for the current tip or a given revision
83 tag add a tag for the current tip or a given revision
82 tags list repository tags
84 tags list repository tags
83 tip show the tip revision
85 tip show the tip revision
84 undo undo the last transaction
86 undo undo the last transaction
85 update update or merge working directory
87 update update or merge working directory
86 verify verify the integrity of the repository
88 verify verify the integrity of the repository
87 version output version and copyright information
89 version output version and copyright information
88 + exit 0
90 + exit 0
@@ -1,21 +1,20 b''
1 #!/bin/bash
1 #!/bin/bash
2
2
3 mkdir test
3 mkdir test
4 cd test
4 cd test
5 echo foo>foo
5 echo foo>foo
6 hg init
6 hg init
7 hg addremove
7 hg addremove
8 hg commit -t "1"
8 hg commit -t "1"
9 hg verify
9 hg verify
10 hg serve -p 20059 2>/dev/null &
10 hg serve -p 20059 2>/dev/null &
11 cd ..
11 cd ..
12
12
13 mkdir copy
13 hg clone http://localhost:20059/ copy
14 cd copy
14 cd copy
15 hg init http://localhost:20059/
16 hg verify
15 hg verify
17 hg co
16 hg co
18 cat foo
17 cat foo
19 hg manifest
18 hg manifest
20
19
21 kill %hg
20 kill %hg
@@ -1,26 +1,24 b''
1 #!/bin/bash
1 #!/bin/bash
2
2
3 set -ex
3 set -ex
4
4
5 mkdir test
5 mkdir test
6 cd test
6 cd test
7 echo foo>foo
7 echo foo>foo
8 hg init
8 hg init
9 hg addremove
9 hg addremove
10 hg commit -t "1"
10 hg commit -t "1"
11 hg verify
11 hg verify
12 cd ..
13
12
14 mkdir branch
13 hg clone . ../branch
15 cd branch
14 cd ../branch
16 hg init ../test
17 hg co
15 hg co
18 echo bar>>foo
16 echo bar>>foo
19 hg commit -t "2"
17 hg commit -t "2"
20
18
21 cd ../test
19 cd ../test
22 hg pull ../branch
20 hg pull ../branch
23 hg verify
21 hg verify
24 hg co
22 hg co
25 cat foo
23 cat foo
26 hg manifest No newline at end of file
24 hg manifest
@@ -1,40 +1,38 b''
1 + mkdir test
1 + mkdir test
2 + cd test
2 + cd test
3 + echo foo
3 + echo foo
4 + hg init
4 + hg init
5 + hg addremove
5 + hg addremove
6 + hg commit -t 1
6 + hg commit -t 1
7 + hg verify
7 + hg verify
8 checking changesets
8 checking changesets
9 checking manifests
9 checking manifests
10 crosschecking files in changesets and manifests
10 crosschecking files in changesets and manifests
11 checking files
11 checking files
12 1 files, 1 changesets, 1 total revisions
12 1 files, 1 changesets, 1 total revisions
13 + cd ..
13 + hg clone . ../branch
14 + mkdir branch
14 + cd ../branch
15 + cd branch
16 + hg init ../test
17 + hg co
15 + hg co
18 + echo bar
16 + echo bar
19 + hg commit -t 2
17 + hg commit -t 2
20 + cd ../test
18 + cd ../test
21 + hg pull ../branch
19 + hg pull ../branch
22 pulling from ../branch
20 pulling from ../branch
23 searching for changes
21 searching for changes
24 adding changesets
22 adding changesets
25 adding manifests
23 adding manifests
26 adding file revisions
24 adding file revisions
27 modified 1 files, added 1 changesets and 1 new revisions
25 modified 1 files, added 1 changesets and 1 new revisions
28 (run 'hg update' to get a working copy)
26 (run 'hg update' to get a working copy)
29 + hg verify
27 + hg verify
30 checking changesets
28 checking changesets
31 checking manifests
29 checking manifests
32 crosschecking files in changesets and manifests
30 crosschecking files in changesets and manifests
33 checking files
31 checking files
34 1 files, 2 changesets, 2 total revisions
32 1 files, 2 changesets, 2 total revisions
35 + hg co
33 + hg co
36 + cat foo
34 + cat foo
37 foo
35 foo
38 bar
36 bar
39 + hg manifest
37 + hg manifest
40 6f4310b00b9a147241b071a60c28a650827fb03d 644 foo
38 6f4310b00b9a147241b071a60c28a650827fb03d 644 foo
@@ -1,47 +1,47 b''
1 + mkdir t
1 + mkdir t
2 + cd t
2 + cd t
3 + hg init
3 + hg init
4 + hg id
4 + hg id
5 unknown
5 unknown
6 + echo a
6 + echo a
7 + hg add a
7 + hg add a
8 + hg commit -t test -u test -d '0 0'
8 + hg commit -t test -u test -d '0 0'
9 + hg co
9 + hg co
10 + hg identify
10 + hg identify
11 acb14030fe0a tip
11 acb14030fe0a tip
12 ++ hg -q tip
12 ++ hg -q tip
13 ++ cut -d : -f 2
13 ++ cut -d : -f 2
14 + T=acb14030fe0a21b60322c440ad2d20cf7685a376
14 + T=acb14030fe0a21b60322c440ad2d20cf7685a376
15 + echo 'acb14030fe0a21b60322c440ad2d20cf7685a376 first'
15 + echo 'acb14030fe0a21b60322c440ad2d20cf7685a376 first'
16 + cat .hgtags
16 + cat .hgtags
17 acb14030fe0a21b60322c440ad2d20cf7685a376 first
17 acb14030fe0a21b60322c440ad2d20cf7685a376 first
18 + hg add .hgtags
18 + hg add .hgtags
19 + hg commit -t 'add tags' -u test -d '0 0'
19 + hg commit -t 'add tags' -u test -d '0 0'
20 + hg tags
20 + hg tags
21 tip 1:b9154636be938d3d431e75a7c906504a079bfe07
21 tip 1:b9154636be938d3d431e75a7c906504a079bfe07
22 first 0:acb14030fe0a21b60322c440ad2d20cf7685a376
22 first 0:acb14030fe0a21b60322c440ad2d20cf7685a376
23 + hg identify
23 + hg identify
24 b9154636be93 tip
24 b9154636be93 tip
25 + echo bb
25 + echo bb
26 + hg status
26 + hg status
27 C a
27 C a
28 + hg identify
28 + hg identify
29 b9154636be93+ tip
29 b9154636be93+ tip
30 + hg co first
30 + hg co first
31 + hg id
31 + hg id
32 acb14030fe0a+ first
32 acb14030fe0a+ first
33 + hg -v id
33 + hg -v id
34 acb14030fe0a21b60322c440ad2d20cf7685a376+ first
34 acb14030fe0a21b60322c440ad2d20cf7685a376+ first
35 + hg status
35 + hg status
36 C a
36 C a
37 + echo 1
37 + echo 1
38 + hg add b
38 + hg add b
39 + hg commit -t branch -u test -d '0 0'
39 + hg commit -t branch -u test -d '0 0'
40 + hg id
40 + hg id
41 c8edf04160c7 tip
41 c8edf04160c7 tip
42 + hg co -m 1
42 + hg co -m 1
43 + hg id
43 + hg id
44 c8edf04160c7+b9154636be93+ tip
44 c8edf04160c7+b9154636be93+ tip
45 + hg status
45 + hg status
46 C .hgtags
46 C a
47 C a
47 C .hgtags
@@ -1,37 +1,35 b''
1 #!/bin/bash
1 #!/bin/bash
2
2
3 export HGMERGE=true
3 export HGMERGE=true
4
4
5 set -ex
5 set -ex
6 mkdir r1
6 mkdir r1
7 cd r1
7 cd r1
8 hg init
8 hg init
9 echo a > a
9 echo a > a
10 hg addremove
10 hg addremove
11 hg commit -t "1" -u test -d "0 0"
11 hg commit -t "1" -u test -d "0 0"
12
12
13 cd ..
13 hg clone . ../r2
14 mkdir r2
14 cd ../r2
15 cd r2
16 hg init ../r1
17 hg up
15 hg up
18 echo abc > a
16 echo abc > a
19 hg diff > ../d
17 hg diff > ../d
20 sed "s/\(\(---\|+++\).*\)\t.*/\1/" < ../d
18 sed "s/\(\(---\|+++\).*\)\t.*/\1/" < ../d
21
19
22 cd ../r1
20 cd ../r1
23 echo b > b
21 echo b > b
24 echo a2 > a
22 echo a2 > a
25 hg addremove
23 hg addremove
26 hg commit -t "2" -u test -d "0 0"
24 hg commit -t "2" -u test -d "0 0"
27
25
28 cd ../r2
26 cd ../r2
29 hg -q pull ../r1
27 hg -q pull ../r1
30 hg status
28 hg status
31 hg -d up
29 hg -d up
32 hg -d up -m
30 hg -d up -m
33 hg parents
31 hg parents
34 hg -v history
32 hg -v history
35 hg diff > ../d
33 hg diff > ../d
36 sed "s/\(\(---\|+++\).*\)\t.*/\1/" < ../d
34 sed "s/\(\(---\|+++\).*\)\t.*/\1/" < ../d
37
35
@@ -1,74 +1,72 b''
1 + mkdir r1
1 + mkdir r1
2 + cd r1
2 + cd r1
3 + hg init
3 + hg init
4 + echo a
4 + echo a
5 + hg addremove
5 + hg addremove
6 + hg commit -t 1 -u test -d '0 0'
6 + hg commit -t 1 -u test -d '0 0'
7 + cd ..
7 + hg clone . ../r2
8 + mkdir r2
8 + cd ../r2
9 + cd r2
10 + hg init ../r1
11 + hg up
9 + hg up
12 + echo abc
10 + echo abc
13 + hg diff
11 + hg diff
14 + sed 's/\(\(---\|+++\).*\)\t.*/\1/'
12 + sed 's/\(\(---\|+++\).*\)\t.*/\1/'
15 diff -r c19d34741b0a a
13 diff -r c19d34741b0a a
16 --- a/a
14 --- a/a
17 +++ b/a
15 +++ b/a
18 @@ -1,1 +1,1 @@
16 @@ -1,1 +1,1 @@
19 -a
17 -a
20 +abc
18 +abc
21 + cd ../r1
19 + cd ../r1
22 + echo b
20 + echo b
23 + echo a2
21 + echo a2
24 + hg addremove
22 + hg addremove
25 + hg commit -t 2 -u test -d '0 0'
23 + hg commit -t 2 -u test -d '0 0'
26 + cd ../r2
24 + cd ../r2
27 + hg -q pull ../r1
25 + hg -q pull ../r1
28 + hg status
26 + hg status
29 C a
27 C a
30 + hg -d up
28 + hg -d up
31 resolving manifests
29 resolving manifests
32 ancestor a0c8bcbbb45c local a0c8bcbbb45c remote 1165e8bd193e
30 ancestor a0c8bcbbb45c local a0c8bcbbb45c remote 1165e8bd193e
33 a versions differ, resolve
31 a versions differ, resolve
34 remote created b
32 remote created b
35 getting b
33 getting b
36 merging a
34 merging a
37 resolving a
35 resolving a
38 file a: other d730145abbf9 ancestor b789fdd96dc2
36 file a: other d730145abbf9 ancestor b789fdd96dc2
39 + hg -d up -m
37 + hg -d up -m
40 resolving manifests
38 resolving manifests
41 ancestor 1165e8bd193e local 1165e8bd193e remote 1165e8bd193e
39 ancestor 1165e8bd193e local 1165e8bd193e remote 1165e8bd193e
42 + hg parents
40 + hg parents
43 changeset: 1:1e71731e6fbb5b35fae293120dea6964371c13c6
41 changeset: 1:1e71731e6fbb5b35fae293120dea6964371c13c6
44 tag: tip
42 tag: tip
45 user: test
43 user: test
46 date: Thu Jan 1 00:00:00 1970
44 date: Thu Jan 1 00:00:00 1970
47 summary: 2
45 summary: 2
48
46
49 + hg -v history
47 + hg -v history
50 changeset: 1:1e71731e6fbb5b35fae293120dea6964371c13c6
48 changeset: 1:1e71731e6fbb5b35fae293120dea6964371c13c6
51 tag: tip
49 tag: tip
52 manifest: 1:1165e8bd193e17ad7d321d846fcf27ff3f412758
50 manifest: 1:1165e8bd193e17ad7d321d846fcf27ff3f412758
53 user: test
51 user: test
54 date: Thu Jan 1 00:00:00 1970
52 date: Thu Jan 1 00:00:00 1970
55 files: a b
53 files: a b
56 description:
54 description:
57 2
55 2
58
56
59 changeset: 0:c19d34741b0a4ced8e4ba74bb834597d5193851e
57 changeset: 0:c19d34741b0a4ced8e4ba74bb834597d5193851e
60 manifest: 0:a0c8bcbbb45c63b90b70ad007bf38961f64f2af0
58 manifest: 0:a0c8bcbbb45c63b90b70ad007bf38961f64f2af0
61 user: test
59 user: test
62 date: Thu Jan 1 00:00:00 1970
60 date: Thu Jan 1 00:00:00 1970
63 files: a
61 files: a
64 description:
62 description:
65 1
63 1
66
64
67 + hg diff
65 + hg diff
68 + sed 's/\(\(---\|+++\).*\)\t.*/\1/'
66 + sed 's/\(\(---\|+++\).*\)\t.*/\1/'
69 diff -r 1e71731e6fbb a
67 diff -r 1e71731e6fbb a
70 --- a/a
68 --- a/a
71 +++ b/a
69 +++ b/a
72 @@ -1,1 +1,1 @@
70 @@ -1,1 +1,1 @@
73 -a2
71 -a2
74 +abc
72 +abc
General Comments 0
You need to be logged in to leave comments. Login now