##// END OF EJS Templates
locate: exit(1) if we didn't print any file
Alexis S. L. Carvalho -
r4196:1c69c73d default
parent child Browse files
Show More
@@ -1,3343 +1,3347 b''
1 1 # commands.py - command processing for mercurial
2 2 #
3 3 # Copyright 2005, 2006 Matt Mackall <mpm@selenic.com>
4 4 #
5 5 # This software may be used and distributed according to the terms
6 6 # of the GNU General Public License, incorporated herein by reference.
7 7
8 8 from demandload import demandload
9 9 from node import *
10 10 from i18n import gettext as _
11 11 demandload(globals(), "bisect os re sys signal imp urllib pdb shlex stat")
12 12 demandload(globals(), "fancyopts ui hg util lock revlog bundlerepo")
13 13 demandload(globals(), "difflib patch time help mdiff tempfile")
14 14 demandload(globals(), "traceback errno version atexit socket")
15 15 demandload(globals(), "archival changegroup cmdutil hgweb.server sshserver")
16 16
17 17 class UnknownCommand(Exception):
18 18 """Exception raised if command is not in the command table."""
19 19 class AmbiguousCommand(Exception):
20 20 """Exception raised if command shortcut matches more than one command."""
21 21
22 22 def bail_if_changed(repo):
23 23 modified, added, removed, deleted = repo.status()[:4]
24 24 if modified or added or removed or deleted:
25 25 raise util.Abort(_("outstanding uncommitted changes"))
26 26
27 27 def logmessage(opts):
28 28 """ get the log message according to -m and -l option """
29 29 message = opts['message']
30 30 logfile = opts['logfile']
31 31
32 32 if message and logfile:
33 33 raise util.Abort(_('options --message and --logfile are mutually '
34 34 'exclusive'))
35 35 if not message and logfile:
36 36 try:
37 37 if logfile == '-':
38 38 message = sys.stdin.read()
39 39 else:
40 40 message = open(logfile).read()
41 41 except IOError, inst:
42 42 raise util.Abort(_("can't read commit message '%s': %s") %
43 43 (logfile, inst.strerror))
44 44 return message
45 45
46 46 def setremoteconfig(ui, opts):
47 47 "copy remote options to ui tree"
48 48 if opts.get('ssh'):
49 49 ui.setconfig("ui", "ssh", opts['ssh'])
50 50 if opts.get('remotecmd'):
51 51 ui.setconfig("ui", "remotecmd", opts['remotecmd'])
52 52
53 53 # Commands start here, listed alphabetically
54 54
55 55 def add(ui, repo, *pats, **opts):
56 56 """add the specified files on the next commit
57 57
58 58 Schedule files to be version controlled and added to the repository.
59 59
60 60 The files will be added to the repository at the next commit. To
61 61 undo an add before that, see hg revert.
62 62
63 63 If no names are given, add all files in the repository.
64 64 """
65 65
66 66 names = []
67 67 for src, abs, rel, exact in cmdutil.walk(repo, pats, opts):
68 68 if exact:
69 69 if ui.verbose:
70 70 ui.status(_('adding %s\n') % rel)
71 71 names.append(abs)
72 72 elif repo.dirstate.state(abs) == '?':
73 73 ui.status(_('adding %s\n') % rel)
74 74 names.append(abs)
75 75 if not opts.get('dry_run'):
76 76 repo.add(names)
77 77
78 78 def addremove(ui, repo, *pats, **opts):
79 79 """add all new files, delete all missing files
80 80
81 81 Add all new files and remove all missing files from the repository.
82 82
83 83 New files are ignored if they match any of the patterns in .hgignore. As
84 84 with add, these changes take effect at the next commit.
85 85
86 86 Use the -s option to detect renamed files. With a parameter > 0,
87 87 this compares every removed file with every added file and records
88 88 those similar enough as renames. This option takes a percentage
89 89 between 0 (disabled) and 100 (files must be identical) as its
90 90 parameter. Detecting renamed files this way can be expensive.
91 91 """
92 92 sim = float(opts.get('similarity') or 0)
93 93 if sim < 0 or sim > 100:
94 94 raise util.Abort(_('similarity must be between 0 and 100'))
95 95 return cmdutil.addremove(repo, pats, opts, similarity=sim/100.)
96 96
97 97 def annotate(ui, repo, *pats, **opts):
98 98 """show changeset information per file line
99 99
100 100 List changes in files, showing the revision id responsible for each line
101 101
102 102 This command is useful to discover who did a change or when a change took
103 103 place.
104 104
105 105 Without the -a option, annotate will avoid processing files it
106 106 detects as binary. With -a, annotate will generate an annotation
107 107 anyway, probably with undesirable results.
108 108 """
109 109 getdate = util.cachefunc(lambda x: util.datestr(x.date()))
110 110
111 111 if not pats:
112 112 raise util.Abort(_('at least one file name or pattern required'))
113 113
114 114 opmap = [['user', lambda x: ui.shortuser(x.user())],
115 115 ['number', lambda x: str(x.rev())],
116 116 ['changeset', lambda x: short(x.node())],
117 117 ['date', getdate], ['follow', lambda x: x.path()]]
118 118 if (not opts['user'] and not opts['changeset'] and not opts['date']
119 119 and not opts['follow']):
120 120 opts['number'] = 1
121 121
122 122 ctx = repo.changectx(opts['rev'])
123 123
124 124 for src, abs, rel, exact in cmdutil.walk(repo, pats, opts,
125 125 node=ctx.node()):
126 126 fctx = ctx.filectx(abs)
127 127 if not opts['text'] and util.binary(fctx.data()):
128 128 ui.write(_("%s: binary file\n") % ((pats and rel) or abs))
129 129 continue
130 130
131 131 lines = fctx.annotate(follow=opts.get('follow'))
132 132 pieces = []
133 133
134 134 for o, f in opmap:
135 135 if opts[o]:
136 136 l = [f(n) for n, dummy in lines]
137 137 if l:
138 138 m = max(map(len, l))
139 139 pieces.append(["%*s" % (m, x) for x in l])
140 140
141 141 if pieces:
142 142 for p, l in zip(zip(*pieces), lines):
143 143 ui.write("%s: %s" % (" ".join(p), l[1]))
144 144
145 145 def archive(ui, repo, dest, **opts):
146 146 '''create unversioned archive of a repository revision
147 147
148 148 By default, the revision used is the parent of the working
149 149 directory; use "-r" to specify a different revision.
150 150
151 151 To specify the type of archive to create, use "-t". Valid
152 152 types are:
153 153
154 154 "files" (default): a directory full of files
155 155 "tar": tar archive, uncompressed
156 156 "tbz2": tar archive, compressed using bzip2
157 157 "tgz": tar archive, compressed using gzip
158 158 "uzip": zip archive, uncompressed
159 159 "zip": zip archive, compressed using deflate
160 160
161 161 The exact name of the destination archive or directory is given
162 162 using a format string; see "hg help export" for details.
163 163
164 164 Each member added to an archive file has a directory prefix
165 165 prepended. Use "-p" to specify a format string for the prefix.
166 166 The default is the basename of the archive, with suffixes removed.
167 167 '''
168 168
169 169 node = repo.changectx(opts['rev']).node()
170 170 dest = cmdutil.make_filename(repo, dest, node)
171 171 if os.path.realpath(dest) == repo.root:
172 172 raise util.Abort(_('repository root cannot be destination'))
173 173 dummy, matchfn, dummy = cmdutil.matchpats(repo, [], opts)
174 174 kind = opts.get('type') or 'files'
175 175 prefix = opts['prefix']
176 176 if dest == '-':
177 177 if kind == 'files':
178 178 raise util.Abort(_('cannot archive plain files to stdout'))
179 179 dest = sys.stdout
180 180 if not prefix: prefix = os.path.basename(repo.root) + '-%h'
181 181 prefix = cmdutil.make_filename(repo, prefix, node)
182 182 archival.archive(repo, dest, node, kind, not opts['no_decode'],
183 183 matchfn, prefix)
184 184
185 185 def backout(ui, repo, rev, **opts):
186 186 '''reverse effect of earlier changeset
187 187
188 188 Commit the backed out changes as a new changeset. The new
189 189 changeset is a child of the backed out changeset.
190 190
191 191 If you back out a changeset other than the tip, a new head is
192 192 created. This head is the parent of the working directory. If
193 193 you back out an old changeset, your working directory will appear
194 194 old after the backout. You should merge the backout changeset
195 195 with another head.
196 196
197 197 The --merge option remembers the parent of the working directory
198 198 before starting the backout, then merges the new head with that
199 199 changeset afterwards. This saves you from doing the merge by
200 200 hand. The result of this merge is not committed, as for a normal
201 201 merge.'''
202 202
203 203 bail_if_changed(repo)
204 204 op1, op2 = repo.dirstate.parents()
205 205 if op2 != nullid:
206 206 raise util.Abort(_('outstanding uncommitted merge'))
207 207 node = repo.lookup(rev)
208 208 p1, p2 = repo.changelog.parents(node)
209 209 if p1 == nullid:
210 210 raise util.Abort(_('cannot back out a change with no parents'))
211 211 if p2 != nullid:
212 212 if not opts['parent']:
213 213 raise util.Abort(_('cannot back out a merge changeset without '
214 214 '--parent'))
215 215 p = repo.lookup(opts['parent'])
216 216 if p not in (p1, p2):
217 217 raise util.Abort(_('%s is not a parent of %s') %
218 218 (short(p), short(node)))
219 219 parent = p
220 220 else:
221 221 if opts['parent']:
222 222 raise util.Abort(_('cannot use --parent on non-merge changeset'))
223 223 parent = p1
224 224 hg.clean(repo, node, show_stats=False)
225 225 revert_opts = opts.copy()
226 226 revert_opts['date'] = None
227 227 revert_opts['all'] = True
228 228 revert_opts['rev'] = hex(parent)
229 229 revert(ui, repo, **revert_opts)
230 230 commit_opts = opts.copy()
231 231 commit_opts['addremove'] = False
232 232 if not commit_opts['message'] and not commit_opts['logfile']:
233 233 commit_opts['message'] = _("Backed out changeset %s") % (hex(node))
234 234 commit_opts['force_editor'] = True
235 235 commit(ui, repo, **commit_opts)
236 236 def nice(node):
237 237 return '%d:%s' % (repo.changelog.rev(node), short(node))
238 238 ui.status(_('changeset %s backs out changeset %s\n') %
239 239 (nice(repo.changelog.tip()), nice(node)))
240 240 if op1 != node:
241 241 if opts['merge']:
242 242 ui.status(_('merging with changeset %s\n') % nice(op1))
243 243 n = _lookup(repo, hex(op1))
244 244 hg.merge(repo, n)
245 245 else:
246 246 ui.status(_('the backout changeset is a new head - '
247 247 'do not forget to merge\n'))
248 248 ui.status(_('(use "backout --merge" '
249 249 'if you want to auto-merge)\n'))
250 250
251 251 def branch(ui, repo, label=None):
252 252 """set or show the current branch name
253 253
254 254 With <name>, set the current branch name. Otherwise, show the
255 255 current branch name.
256 256 """
257 257
258 258 if label is not None:
259 259 repo.opener("branch", "w").write(util.fromlocal(label) + '\n')
260 260 else:
261 261 b = util.tolocal(repo.workingctx().branch())
262 262 if b:
263 263 ui.write("%s\n" % b)
264 264
265 265 def branches(ui, repo):
266 266 """list repository named branches
267 267
268 268 List the repository's named branches.
269 269 """
270 270 b = repo.branchtags()
271 271 l = [(-repo.changelog.rev(n), n, t) for t, n in b.items()]
272 272 l.sort()
273 273 for r, n, t in l:
274 274 hexfunc = ui.debugflag and hex or short
275 275 if ui.quiet:
276 276 ui.write("%s\n" % t)
277 277 else:
278 278 spaces = " " * (30 - util.locallen(t))
279 279 ui.write("%s%s %s:%s\n" % (t, spaces, -r, hexfunc(n)))
280 280
281 281 def bundle(ui, repo, fname, dest=None, **opts):
282 282 """create a changegroup file
283 283
284 284 Generate a compressed changegroup file collecting changesets not
285 285 found in the other repository.
286 286
287 287 If no destination repository is specified the destination is assumed
288 288 to have all the nodes specified by one or more --base parameters.
289 289
290 290 The bundle file can then be transferred using conventional means and
291 291 applied to another repository with the unbundle or pull command.
292 292 This is useful when direct push and pull are not available or when
293 293 exporting an entire repository is undesirable.
294 294
295 295 Applying bundles preserves all changeset contents including
296 296 permissions, copy/rename information, and revision history.
297 297 """
298 298 revs = opts.get('rev') or None
299 299 if revs:
300 300 revs = [repo.lookup(rev) for rev in revs]
301 301 base = opts.get('base')
302 302 if base:
303 303 if dest:
304 304 raise util.Abort(_("--base is incompatible with specifiying "
305 305 "a destination"))
306 306 base = [repo.lookup(rev) for rev in base]
307 307 # create the right base
308 308 # XXX: nodesbetween / changegroup* should be "fixed" instead
309 309 o = []
310 310 has = {nullid: None}
311 311 for n in base:
312 312 has.update(repo.changelog.reachable(n))
313 313 if revs:
314 314 visit = list(revs)
315 315 else:
316 316 visit = repo.changelog.heads()
317 317 seen = {}
318 318 while visit:
319 319 n = visit.pop(0)
320 320 parents = [p for p in repo.changelog.parents(n) if p not in has]
321 321 if len(parents) == 0:
322 322 o.insert(0, n)
323 323 else:
324 324 for p in parents:
325 325 if p not in seen:
326 326 seen[p] = 1
327 327 visit.append(p)
328 328 else:
329 329 setremoteconfig(ui, opts)
330 330 dest = ui.expandpath(dest or 'default-push', dest or 'default')
331 331 other = hg.repository(ui, dest)
332 332 o = repo.findoutgoing(other, force=opts['force'])
333 333
334 334 if revs:
335 335 cg = repo.changegroupsubset(o, revs, 'bundle')
336 336 else:
337 337 cg = repo.changegroup(o, 'bundle')
338 338 changegroup.writebundle(cg, fname, "HG10BZ")
339 339
340 340 def cat(ui, repo, file1, *pats, **opts):
341 341 """output the current or given revision of files
342 342
343 343 Print the specified files as they were at the given revision.
344 344 If no revision is given, the parent of the working directory is used,
345 345 or tip if no revision is checked out.
346 346
347 347 Output may be to a file, in which case the name of the file is
348 348 given using a format string. The formatting rules are the same as
349 349 for the export command, with the following additions:
350 350
351 351 %s basename of file being printed
352 352 %d dirname of file being printed, or '.' if in repo root
353 353 %p root-relative path name of file being printed
354 354 """
355 355 ctx = repo.changectx(opts['rev'])
356 356 for src, abs, rel, exact in cmdutil.walk(repo, (file1,) + pats, opts,
357 357 ctx.node()):
358 358 fp = cmdutil.make_file(repo, opts['output'], ctx.node(), pathname=abs)
359 359 fp.write(ctx.filectx(abs).data())
360 360
361 361 def clone(ui, source, dest=None, **opts):
362 362 """make a copy of an existing repository
363 363
364 364 Create a copy of an existing repository in a new directory.
365 365
366 366 If no destination directory name is specified, it defaults to the
367 367 basename of the source.
368 368
369 369 The location of the source is added to the new repository's
370 370 .hg/hgrc file, as the default to be used for future pulls.
371 371
372 372 For efficiency, hardlinks are used for cloning whenever the source
373 373 and destination are on the same filesystem (note this applies only
374 374 to the repository data, not to the checked out files). Some
375 375 filesystems, such as AFS, implement hardlinking incorrectly, but
376 376 do not report errors. In these cases, use the --pull option to
377 377 avoid hardlinking.
378 378
379 379 You can safely clone repositories and checked out files using full
380 380 hardlinks with
381 381
382 382 $ cp -al REPO REPOCLONE
383 383
384 384 which is the fastest way to clone. However, the operation is not
385 385 atomic (making sure REPO is not modified during the operation is
386 386 up to you) and you have to make sure your editor breaks hardlinks
387 387 (Emacs and most Linux Kernel tools do so).
388 388
389 389 If you use the -r option to clone up to a specific revision, no
390 390 subsequent revisions will be present in the cloned repository.
391 391 This option implies --pull, even on local repositories.
392 392
393 393 See pull for valid source format details.
394 394
395 395 It is possible to specify an ssh:// URL as the destination, but no
396 396 .hg/hgrc and working directory will be created on the remote side.
397 397 Look at the help text for the pull command for important details
398 398 about ssh:// URLs.
399 399 """
400 400 setremoteconfig(ui, opts)
401 401 hg.clone(ui, ui.expandpath(source), dest,
402 402 pull=opts['pull'],
403 403 stream=opts['uncompressed'],
404 404 rev=opts['rev'],
405 405 update=not opts['noupdate'])
406 406
407 407 def commit(ui, repo, *pats, **opts):
408 408 """commit the specified files or all outstanding changes
409 409
410 410 Commit changes to the given files into the repository.
411 411
412 412 If a list of files is omitted, all changes reported by "hg status"
413 413 will be committed.
414 414
415 415 If no commit message is specified, the editor configured in your hgrc
416 416 or in the EDITOR environment variable is started to enter a message.
417 417 """
418 418 message = logmessage(opts)
419 419
420 420 if opts['addremove']:
421 421 cmdutil.addremove(repo, pats, opts)
422 422 fns, match, anypats = cmdutil.matchpats(repo, pats, opts)
423 423 if pats:
424 424 status = repo.status(files=fns, match=match)
425 425 modified, added, removed, deleted, unknown = status[:5]
426 426 files = modified + added + removed
427 427 slist = None
428 428 for f in fns:
429 429 if f not in files:
430 430 rf = repo.wjoin(f)
431 431 if f in unknown:
432 432 raise util.Abort(_("file %s not tracked!") % rf)
433 433 try:
434 434 mode = os.lstat(rf)[stat.ST_MODE]
435 435 except OSError:
436 436 raise util.Abort(_("file %s not found!") % rf)
437 437 if stat.S_ISDIR(mode):
438 438 name = f + '/'
439 439 if slist is None:
440 440 slist = list(files)
441 441 slist.sort()
442 442 i = bisect.bisect(slist, name)
443 443 if i >= len(slist) or not slist[i].startswith(name):
444 444 raise util.Abort(_("no match under directory %s!")
445 445 % rf)
446 446 elif not stat.S_ISREG(mode):
447 447 raise util.Abort(_("can't commit %s: "
448 448 "unsupported file type!") % rf)
449 449 else:
450 450 files = []
451 451 try:
452 452 repo.commit(files, message, opts['user'], opts['date'], match,
453 453 force_editor=opts.get('force_editor'))
454 454 except ValueError, inst:
455 455 raise util.Abort(str(inst))
456 456
457 457 def docopy(ui, repo, pats, opts, wlock):
458 458 # called with the repo lock held
459 459 #
460 460 # hgsep => pathname that uses "/" to separate directories
461 461 # ossep => pathname that uses os.sep to separate directories
462 462 cwd = repo.getcwd()
463 463 errors = 0
464 464 copied = []
465 465 targets = {}
466 466
467 467 # abs: hgsep
468 468 # rel: ossep
469 469 # return: hgsep
470 470 def okaytocopy(abs, rel, exact):
471 471 reasons = {'?': _('is not managed'),
472 472 'a': _('has been marked for add'),
473 473 'r': _('has been marked for remove')}
474 474 state = repo.dirstate.state(abs)
475 475 reason = reasons.get(state)
476 476 if reason:
477 477 if state == 'a':
478 478 origsrc = repo.dirstate.copied(abs)
479 479 if origsrc is not None:
480 480 return origsrc
481 481 if exact:
482 482 ui.warn(_('%s: not copying - file %s\n') % (rel, reason))
483 483 else:
484 484 return abs
485 485
486 486 # origsrc: hgsep
487 487 # abssrc: hgsep
488 488 # relsrc: ossep
489 489 # target: ossep
490 490 def copy(origsrc, abssrc, relsrc, target, exact):
491 491 abstarget = util.canonpath(repo.root, cwd, target)
492 492 reltarget = util.pathto(cwd, abstarget)
493 493 prevsrc = targets.get(abstarget)
494 494 if prevsrc is not None:
495 495 ui.warn(_('%s: not overwriting - %s collides with %s\n') %
496 496 (reltarget, util.localpath(abssrc),
497 497 util.localpath(prevsrc)))
498 498 return
499 499 if (not opts['after'] and os.path.exists(reltarget) or
500 500 opts['after'] and repo.dirstate.state(abstarget) not in '?r'):
501 501 if not opts['force']:
502 502 ui.warn(_('%s: not overwriting - file exists\n') %
503 503 reltarget)
504 504 return
505 505 if not opts['after'] and not opts.get('dry_run'):
506 506 os.unlink(reltarget)
507 507 if opts['after']:
508 508 if not os.path.exists(reltarget):
509 509 return
510 510 else:
511 511 targetdir = os.path.dirname(reltarget) or '.'
512 512 if not os.path.isdir(targetdir) and not opts.get('dry_run'):
513 513 os.makedirs(targetdir)
514 514 try:
515 515 restore = repo.dirstate.state(abstarget) == 'r'
516 516 if restore and not opts.get('dry_run'):
517 517 repo.undelete([abstarget], wlock)
518 518 try:
519 519 if not opts.get('dry_run'):
520 520 util.copyfile(relsrc, reltarget)
521 521 restore = False
522 522 finally:
523 523 if restore:
524 524 repo.remove([abstarget], wlock)
525 525 except IOError, inst:
526 526 if inst.errno == errno.ENOENT:
527 527 ui.warn(_('%s: deleted in working copy\n') % relsrc)
528 528 else:
529 529 ui.warn(_('%s: cannot copy - %s\n') %
530 530 (relsrc, inst.strerror))
531 531 errors += 1
532 532 return
533 533 if ui.verbose or not exact:
534 534 ui.status(_('copying %s to %s\n') % (relsrc, reltarget))
535 535 targets[abstarget] = abssrc
536 536 if abstarget != origsrc and not opts.get('dry_run'):
537 537 repo.copy(origsrc, abstarget, wlock)
538 538 copied.append((abssrc, relsrc, exact))
539 539
540 540 # pat: ossep
541 541 # dest ossep
542 542 # srcs: list of (hgsep, hgsep, ossep, bool)
543 543 # return: function that takes hgsep and returns ossep
544 544 def targetpathfn(pat, dest, srcs):
545 545 if os.path.isdir(pat):
546 546 abspfx = util.canonpath(repo.root, cwd, pat)
547 547 abspfx = util.localpath(abspfx)
548 548 if destdirexists:
549 549 striplen = len(os.path.split(abspfx)[0])
550 550 else:
551 551 striplen = len(abspfx)
552 552 if striplen:
553 553 striplen += len(os.sep)
554 554 res = lambda p: os.path.join(dest, util.localpath(p)[striplen:])
555 555 elif destdirexists:
556 556 res = lambda p: os.path.join(dest,
557 557 os.path.basename(util.localpath(p)))
558 558 else:
559 559 res = lambda p: dest
560 560 return res
561 561
562 562 # pat: ossep
563 563 # dest ossep
564 564 # srcs: list of (hgsep, hgsep, ossep, bool)
565 565 # return: function that takes hgsep and returns ossep
566 566 def targetpathafterfn(pat, dest, srcs):
567 567 if util.patkind(pat, None)[0]:
568 568 # a mercurial pattern
569 569 res = lambda p: os.path.join(dest,
570 570 os.path.basename(util.localpath(p)))
571 571 else:
572 572 abspfx = util.canonpath(repo.root, cwd, pat)
573 573 if len(abspfx) < len(srcs[0][0]):
574 574 # A directory. Either the target path contains the last
575 575 # component of the source path or it does not.
576 576 def evalpath(striplen):
577 577 score = 0
578 578 for s in srcs:
579 579 t = os.path.join(dest, util.localpath(s[0])[striplen:])
580 580 if os.path.exists(t):
581 581 score += 1
582 582 return score
583 583
584 584 abspfx = util.localpath(abspfx)
585 585 striplen = len(abspfx)
586 586 if striplen:
587 587 striplen += len(os.sep)
588 588 if os.path.isdir(os.path.join(dest, os.path.split(abspfx)[1])):
589 589 score = evalpath(striplen)
590 590 striplen1 = len(os.path.split(abspfx)[0])
591 591 if striplen1:
592 592 striplen1 += len(os.sep)
593 593 if evalpath(striplen1) > score:
594 594 striplen = striplen1
595 595 res = lambda p: os.path.join(dest,
596 596 util.localpath(p)[striplen:])
597 597 else:
598 598 # a file
599 599 if destdirexists:
600 600 res = lambda p: os.path.join(dest,
601 601 os.path.basename(util.localpath(p)))
602 602 else:
603 603 res = lambda p: dest
604 604 return res
605 605
606 606
607 607 pats = util.expand_glob(pats)
608 608 if not pats:
609 609 raise util.Abort(_('no source or destination specified'))
610 610 if len(pats) == 1:
611 611 raise util.Abort(_('no destination specified'))
612 612 dest = pats.pop()
613 613 destdirexists = os.path.isdir(dest)
614 614 if (len(pats) > 1 or util.patkind(pats[0], None)[0]) and not destdirexists:
615 615 raise util.Abort(_('with multiple sources, destination must be an '
616 616 'existing directory'))
617 617 if opts['after']:
618 618 tfn = targetpathafterfn
619 619 else:
620 620 tfn = targetpathfn
621 621 copylist = []
622 622 for pat in pats:
623 623 srcs = []
624 624 for tag, abssrc, relsrc, exact in cmdutil.walk(repo, [pat], opts,
625 625 globbed=True):
626 626 origsrc = okaytocopy(abssrc, relsrc, exact)
627 627 if origsrc:
628 628 srcs.append((origsrc, abssrc, relsrc, exact))
629 629 if not srcs:
630 630 continue
631 631 copylist.append((tfn(pat, dest, srcs), srcs))
632 632 if not copylist:
633 633 raise util.Abort(_('no files to copy'))
634 634
635 635 for targetpath, srcs in copylist:
636 636 for origsrc, abssrc, relsrc, exact in srcs:
637 637 copy(origsrc, abssrc, relsrc, targetpath(abssrc), exact)
638 638
639 639 if errors:
640 640 ui.warn(_('(consider using --after)\n'))
641 641 return errors, copied
642 642
643 643 def copy(ui, repo, *pats, **opts):
644 644 """mark files as copied for the next commit
645 645
646 646 Mark dest as having copies of source files. If dest is a
647 647 directory, copies are put in that directory. If dest is a file,
648 648 there can only be one source.
649 649
650 650 By default, this command copies the contents of files as they
651 651 stand in the working directory. If invoked with --after, the
652 652 operation is recorded, but no copying is performed.
653 653
654 654 This command takes effect in the next commit. To undo a copy
655 655 before that, see hg revert.
656 656 """
657 657 wlock = repo.wlock(0)
658 658 errs, copied = docopy(ui, repo, pats, opts, wlock)
659 659 return errs
660 660
661 661 def debugancestor(ui, index, rev1, rev2):
662 662 """find the ancestor revision of two revisions in a given index"""
663 663 r = revlog.revlog(util.opener(os.getcwd(), audit=False), index, "", 0)
664 664 a = r.ancestor(r.lookup(rev1), r.lookup(rev2))
665 665 ui.write("%d:%s\n" % (r.rev(a), hex(a)))
666 666
667 667 def debugcomplete(ui, cmd='', **opts):
668 668 """returns the completion list associated with the given command"""
669 669
670 670 if opts['options']:
671 671 options = []
672 672 otables = [globalopts]
673 673 if cmd:
674 674 aliases, entry = findcmd(ui, cmd)
675 675 otables.append(entry[1])
676 676 for t in otables:
677 677 for o in t:
678 678 if o[0]:
679 679 options.append('-%s' % o[0])
680 680 options.append('--%s' % o[1])
681 681 ui.write("%s\n" % "\n".join(options))
682 682 return
683 683
684 684 clist = findpossible(ui, cmd).keys()
685 685 clist.sort()
686 686 ui.write("%s\n" % "\n".join(clist))
687 687
688 688 def debugrebuildstate(ui, repo, rev=None):
689 689 """rebuild the dirstate as it would look like for the given revision"""
690 690 if not rev:
691 691 rev = repo.changelog.tip()
692 692 else:
693 693 rev = repo.lookup(rev)
694 694 change = repo.changelog.read(rev)
695 695 n = change[0]
696 696 files = repo.manifest.read(n)
697 697 wlock = repo.wlock()
698 698 repo.dirstate.rebuild(rev, files)
699 699
700 700 def debugcheckstate(ui, repo):
701 701 """validate the correctness of the current dirstate"""
702 702 parent1, parent2 = repo.dirstate.parents()
703 703 repo.dirstate.read()
704 704 dc = repo.dirstate.map
705 705 keys = dc.keys()
706 706 keys.sort()
707 707 m1n = repo.changelog.read(parent1)[0]
708 708 m2n = repo.changelog.read(parent2)[0]
709 709 m1 = repo.manifest.read(m1n)
710 710 m2 = repo.manifest.read(m2n)
711 711 errors = 0
712 712 for f in dc:
713 713 state = repo.dirstate.state(f)
714 714 if state in "nr" and f not in m1:
715 715 ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state))
716 716 errors += 1
717 717 if state in "a" and f in m1:
718 718 ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state))
719 719 errors += 1
720 720 if state in "m" and f not in m1 and f not in m2:
721 721 ui.warn(_("%s in state %s, but not in either manifest\n") %
722 722 (f, state))
723 723 errors += 1
724 724 for f in m1:
725 725 state = repo.dirstate.state(f)
726 726 if state not in "nrm":
727 727 ui.warn(_("%s in manifest1, but listed as state %s") % (f, state))
728 728 errors += 1
729 729 if errors:
730 730 error = _(".hg/dirstate inconsistent with current parent's manifest")
731 731 raise util.Abort(error)
732 732
733 733 def showconfig(ui, repo, *values, **opts):
734 734 """show combined config settings from all hgrc files
735 735
736 736 With no args, print names and values of all config items.
737 737
738 738 With one arg of the form section.name, print just the value of
739 739 that config item.
740 740
741 741 With multiple args, print names and values of all config items
742 742 with matching section names."""
743 743
744 744 untrusted = bool(opts.get('untrusted'))
745 745 if values:
746 746 if len([v for v in values if '.' in v]) > 1:
747 747 raise util.Abort(_('only one config item permitted'))
748 748 for section, name, value in ui.walkconfig(untrusted=untrusted):
749 749 sectname = section + '.' + name
750 750 if values:
751 751 for v in values:
752 752 if v == section:
753 753 ui.write('%s=%s\n' % (sectname, value))
754 754 elif v == sectname:
755 755 ui.write(value, '\n')
756 756 else:
757 757 ui.write('%s=%s\n' % (sectname, value))
758 758
759 759 def debugsetparents(ui, repo, rev1, rev2=None):
760 760 """manually set the parents of the current working directory
761 761
762 762 This is useful for writing repository conversion tools, but should
763 763 be used with care.
764 764 """
765 765
766 766 if not rev2:
767 767 rev2 = hex(nullid)
768 768
769 769 repo.dirstate.setparents(repo.lookup(rev1), repo.lookup(rev2))
770 770
771 771 def debugstate(ui, repo):
772 772 """show the contents of the current dirstate"""
773 773 repo.dirstate.read()
774 774 dc = repo.dirstate.map
775 775 keys = dc.keys()
776 776 keys.sort()
777 777 for file_ in keys:
778 778 if dc[file_][3] == -1:
779 779 # Pad or slice to locale representation
780 780 locale_len = len(time.strftime("%x %X", time.localtime(0)))
781 781 timestr = 'unset'
782 782 timestr = timestr[:locale_len] + ' '*(locale_len - len(timestr))
783 783 else:
784 784 timestr = time.strftime("%x %X", time.localtime(dc[file_][3]))
785 785 ui.write("%c %3o %10d %s %s\n"
786 786 % (dc[file_][0], dc[file_][1] & 0777, dc[file_][2],
787 787 timestr, file_))
788 788 for f in repo.dirstate.copies():
789 789 ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f))
790 790
791 791 def debugdata(ui, file_, rev):
792 792 """dump the contents of an data file revision"""
793 793 r = revlog.revlog(util.opener(os.getcwd(), audit=False),
794 794 file_[:-2] + ".i", file_, 0)
795 795 try:
796 796 ui.write(r.revision(r.lookup(rev)))
797 797 except KeyError:
798 798 raise util.Abort(_('invalid revision identifier %s') % rev)
799 799
800 800 def debugdate(ui, date, range=None, **opts):
801 801 """parse and display a date"""
802 802 if opts["extended"]:
803 803 d = util.parsedate(date, util.extendeddateformats)
804 804 else:
805 805 d = util.parsedate(date)
806 806 ui.write("internal: %s %s\n" % d)
807 807 ui.write("standard: %s\n" % util.datestr(d))
808 808 if range:
809 809 m = util.matchdate(range)
810 810 ui.write("match: %s\n" % m(d[0]))
811 811
812 812 def debugindex(ui, file_):
813 813 """dump the contents of an index file"""
814 814 r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_, "", 0)
815 815 ui.write(" rev offset length base linkrev" +
816 816 " nodeid p1 p2\n")
817 817 for i in xrange(r.count()):
818 818 node = r.node(i)
819 819 pp = r.parents(node)
820 820 ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % (
821 821 i, r.start(i), r.length(i), r.base(i), r.linkrev(node),
822 822 short(node), short(pp[0]), short(pp[1])))
823 823
824 824 def debugindexdot(ui, file_):
825 825 """dump an index DAG as a .dot file"""
826 826 r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_, "", 0)
827 827 ui.write("digraph G {\n")
828 828 for i in xrange(r.count()):
829 829 node = r.node(i)
830 830 pp = r.parents(node)
831 831 ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i))
832 832 if pp[1] != nullid:
833 833 ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i))
834 834 ui.write("}\n")
835 835
836 836 def debuginstall(ui):
837 837 '''test Mercurial installation'''
838 838
839 839 def writetemp(contents):
840 840 (fd, name) = tempfile.mkstemp()
841 841 f = os.fdopen(fd, "wb")
842 842 f.write(contents)
843 843 f.close()
844 844 return name
845 845
846 846 problems = 0
847 847
848 848 # encoding
849 849 ui.status(_("Checking encoding (%s)...\n") % util._encoding)
850 850 try:
851 851 util.fromlocal("test")
852 852 except util.Abort, inst:
853 853 ui.write(" %s\n" % inst)
854 854 ui.write(_(" (check that your locale is properly set)\n"))
855 855 problems += 1
856 856
857 857 # compiled modules
858 858 ui.status(_("Checking extensions...\n"))
859 859 try:
860 860 import bdiff, mpatch, base85
861 861 except Exception, inst:
862 862 ui.write(" %s\n" % inst)
863 863 ui.write(_(" One or more extensions could not be found"))
864 864 ui.write(_(" (check that you compiled the extensions)\n"))
865 865 problems += 1
866 866
867 867 # templates
868 868 ui.status(_("Checking templates...\n"))
869 869 try:
870 870 import templater
871 871 t = templater.templater(templater.templatepath("map-cmdline.default"))
872 872 except Exception, inst:
873 873 ui.write(" %s\n" % inst)
874 874 ui.write(_(" (templates seem to have been installed incorrectly)\n"))
875 875 problems += 1
876 876
877 877 # patch
878 878 ui.status(_("Checking patch...\n"))
879 879 path = os.environ.get('PATH', '')
880 880 patcher = util.find_in_path('gpatch', path,
881 881 util.find_in_path('patch', path, None))
882 882 if not patcher:
883 883 ui.write(_(" Can't find patch or gpatch in PATH\n"))
884 884 ui.write(_(" (specify a patch utility in your .hgrc file)\n"))
885 885 problems += 1
886 886 else:
887 887 # actually attempt a patch here
888 888 a = "1\n2\n3\n4\n"
889 889 b = "1\n2\n3\ninsert\n4\n"
890 890 d = mdiff.unidiff(a, None, b, None, "a")
891 891 fa = writetemp(a)
892 892 fd = writetemp(d)
893 893 fp = os.popen('%s %s %s' % (patcher, fa, fd))
894 894 files = []
895 895 output = ""
896 896 for line in fp:
897 897 output += line
898 898 if line.startswith('patching file '):
899 899 pf = util.parse_patch_output(line.rstrip())
900 900 files.append(pf)
901 901 if files != [fa]:
902 902 ui.write(_(" unexpected patch output!"))
903 903 ui.write(_(" (you may have an incompatible version of patch)\n"))
904 904 ui.write(output)
905 905 problems += 1
906 906 a = file(fa).read()
907 907 if a != b:
908 908 ui.write(_(" patch test failed!"))
909 909 ui.write(_(" (you may have an incompatible version of patch)\n"))
910 910 problems += 1
911 911 os.unlink(fa)
912 912 os.unlink(fd)
913 913
914 914 # merge helper
915 915 ui.status(_("Checking merge helper...\n"))
916 916 cmd = (os.environ.get("HGMERGE") or ui.config("ui", "merge")
917 917 or "hgmerge")
918 918 cmdpath = util.find_in_path(cmd, path)
919 919 if not cmdpath:
920 920 cmdpath = util.find_in_path(cmd.split()[0], path)
921 921 if not cmdpath:
922 922 if cmd == 'hgmerge':
923 923 ui.write(_(" No merge helper set and can't find default"
924 924 " hgmerge script in PATH\n"))
925 925 ui.write(_(" (specify a merge helper in your .hgrc file)\n"))
926 926 else:
927 927 ui.write(_(" Can't find merge helper '%s' in PATH\n") % cmd)
928 928 ui.write(_(" (specify a merge helper in your .hgrc file)\n"))
929 929 problems += 1
930 930 else:
931 931 # actually attempt a patch here
932 932 fa = writetemp("1\n2\n3\n4\n")
933 933 fl = writetemp("1\n2\n3\ninsert\n4\n")
934 934 fr = writetemp("begin\n1\n2\n3\n4\n")
935 935 r = os.system('%s %s %s %s' % (cmd, fl, fa, fr))
936 936 if r:
937 937 ui.write(_(" got unexpected merge error %d!") % r)
938 938 problems += 1
939 939 m = file(fl).read()
940 940 if m != "begin\n1\n2\n3\ninsert\n4\n":
941 941 ui.write(_(" got unexpected merge results!") % r)
942 942 ui.write(_(" (your merge helper may have the"
943 943 " wrong argument order)\n"))
944 944 ui.write(m)
945 945 os.unlink(fa)
946 946 os.unlink(fl)
947 947 os.unlink(fr)
948 948
949 949 # editor
950 950 ui.status(_("Checking commit editor...\n"))
951 951 editor = (os.environ.get("HGEDITOR") or
952 952 ui.config("ui", "editor") or
953 953 os.environ.get("EDITOR", "vi"))
954 954 cmdpath = util.find_in_path(editor, path)
955 955 if not cmdpath:
956 956 cmdpath = util.find_in_path(editor.split()[0], path)
957 957 if not cmdpath:
958 958 if editor == 'vi':
959 959 ui.write(_(" No commit editor set and can't find vi in PATH\n"))
960 960 ui.write(_(" (specify a commit editor in your .hgrc file)\n"))
961 961 else:
962 962 ui.write(_(" Can't find editor '%s' in PATH\n") % editor)
963 963 ui.write(_(" (specify a commit editor in your .hgrc file)\n"))
964 964 problems += 1
965 965
966 966 # check username
967 967 ui.status(_("Checking username...\n"))
968 968 user = os.environ.get("HGUSER")
969 969 if user is None:
970 970 user = ui.config("ui", "username")
971 971 if user is None:
972 972 user = os.environ.get("EMAIL")
973 973 if not user:
974 974 ui.warn(" ")
975 975 ui.username()
976 976 ui.write(_(" (specify a username in your .hgrc file)\n"))
977 977
978 978 if not problems:
979 979 ui.status(_("No problems detected\n"))
980 980 else:
981 981 ui.write(_("%s problems detected,"
982 982 " please check your install!\n") % problems)
983 983
984 984 return problems
985 985
986 986 def debugrename(ui, repo, file1, *pats, **opts):
987 987 """dump rename information"""
988 988
989 989 ctx = repo.changectx(opts.get('rev', 'tip'))
990 990 for src, abs, rel, exact in cmdutil.walk(repo, (file1,) + pats, opts,
991 991 ctx.node()):
992 992 m = ctx.filectx(abs).renamed()
993 993 if m:
994 994 ui.write(_("%s renamed from %s:%s\n") % (rel, m[0], hex(m[1])))
995 995 else:
996 996 ui.write(_("%s not renamed\n") % rel)
997 997
998 998 def debugwalk(ui, repo, *pats, **opts):
999 999 """show how files match on given patterns"""
1000 1000 items = list(cmdutil.walk(repo, pats, opts))
1001 1001 if not items:
1002 1002 return
1003 1003 fmt = '%%s %%-%ds %%-%ds %%s' % (
1004 1004 max([len(abs) for (src, abs, rel, exact) in items]),
1005 1005 max([len(rel) for (src, abs, rel, exact) in items]))
1006 1006 for src, abs, rel, exact in items:
1007 1007 line = fmt % (src, abs, rel, exact and 'exact' or '')
1008 1008 ui.write("%s\n" % line.rstrip())
1009 1009
1010 1010 def diff(ui, repo, *pats, **opts):
1011 1011 """diff repository (or selected files)
1012 1012
1013 1013 Show differences between revisions for the specified files.
1014 1014
1015 1015 Differences between files are shown using the unified diff format.
1016 1016
1017 1017 NOTE: diff may generate unexpected results for merges, as it will
1018 1018 default to comparing against the working directory's first parent
1019 1019 changeset if no revisions are specified.
1020 1020
1021 1021 When two revision arguments are given, then changes are shown
1022 1022 between those revisions. If only one revision is specified then
1023 1023 that revision is compared to the working directory, and, when no
1024 1024 revisions are specified, the working directory files are compared
1025 1025 to its parent.
1026 1026
1027 1027 Without the -a option, diff will avoid generating diffs of files
1028 1028 it detects as binary. With -a, diff will generate a diff anyway,
1029 1029 probably with undesirable results.
1030 1030 """
1031 1031 node1, node2 = cmdutil.revpair(repo, opts['rev'])
1032 1032
1033 1033 fns, matchfn, anypats = cmdutil.matchpats(repo, pats, opts)
1034 1034
1035 1035 patch.diff(repo, node1, node2, fns, match=matchfn,
1036 1036 opts=patch.diffopts(ui, opts))
1037 1037
1038 1038 def export(ui, repo, *changesets, **opts):
1039 1039 """dump the header and diffs for one or more changesets
1040 1040
1041 1041 Print the changeset header and diffs for one or more revisions.
1042 1042
1043 1043 The information shown in the changeset header is: author,
1044 1044 changeset hash, parent(s) and commit comment.
1045 1045
1046 1046 NOTE: export may generate unexpected diff output for merge changesets,
1047 1047 as it will compare the merge changeset against its first parent only.
1048 1048
1049 1049 Output may be to a file, in which case the name of the file is
1050 1050 given using a format string. The formatting rules are as follows:
1051 1051
1052 1052 %% literal "%" character
1053 1053 %H changeset hash (40 bytes of hexadecimal)
1054 1054 %N number of patches being generated
1055 1055 %R changeset revision number
1056 1056 %b basename of the exporting repository
1057 1057 %h short-form changeset hash (12 bytes of hexadecimal)
1058 1058 %n zero-padded sequence number, starting at 1
1059 1059 %r zero-padded changeset revision number
1060 1060
1061 1061 Without the -a option, export will avoid generating diffs of files
1062 1062 it detects as binary. With -a, export will generate a diff anyway,
1063 1063 probably with undesirable results.
1064 1064
1065 1065 With the --switch-parent option, the diff will be against the second
1066 1066 parent. It can be useful to review a merge.
1067 1067 """
1068 1068 if not changesets:
1069 1069 raise util.Abort(_("export requires at least one changeset"))
1070 1070 revs = cmdutil.revrange(repo, changesets)
1071 1071 if len(revs) > 1:
1072 1072 ui.note(_('exporting patches:\n'))
1073 1073 else:
1074 1074 ui.note(_('exporting patch:\n'))
1075 1075 patch.export(repo, revs, template=opts['output'],
1076 1076 switch_parent=opts['switch_parent'],
1077 1077 opts=patch.diffopts(ui, opts))
1078 1078
1079 1079 def grep(ui, repo, pattern, *pats, **opts):
1080 1080 """search for a pattern in specified files and revisions
1081 1081
1082 1082 Search revisions of files for a regular expression.
1083 1083
1084 1084 This command behaves differently than Unix grep. It only accepts
1085 1085 Python/Perl regexps. It searches repository history, not the
1086 1086 working directory. It always prints the revision number in which
1087 1087 a match appears.
1088 1088
1089 1089 By default, grep only prints output for the first revision of a
1090 1090 file in which it finds a match. To get it to print every revision
1091 1091 that contains a change in match status ("-" for a match that
1092 1092 becomes a non-match, or "+" for a non-match that becomes a match),
1093 1093 use the --all flag.
1094 1094 """
1095 1095 reflags = 0
1096 1096 if opts['ignore_case']:
1097 1097 reflags |= re.I
1098 1098 regexp = re.compile(pattern, reflags)
1099 1099 sep, eol = ':', '\n'
1100 1100 if opts['print0']:
1101 1101 sep = eol = '\0'
1102 1102
1103 1103 fcache = {}
1104 1104 def getfile(fn):
1105 1105 if fn not in fcache:
1106 1106 fcache[fn] = repo.file(fn)
1107 1107 return fcache[fn]
1108 1108
1109 1109 def matchlines(body):
1110 1110 begin = 0
1111 1111 linenum = 0
1112 1112 while True:
1113 1113 match = regexp.search(body, begin)
1114 1114 if not match:
1115 1115 break
1116 1116 mstart, mend = match.span()
1117 1117 linenum += body.count('\n', begin, mstart) + 1
1118 1118 lstart = body.rfind('\n', begin, mstart) + 1 or begin
1119 1119 lend = body.find('\n', mend)
1120 1120 yield linenum, mstart - lstart, mend - lstart, body[lstart:lend]
1121 1121 begin = lend + 1
1122 1122
1123 1123 class linestate(object):
1124 1124 def __init__(self, line, linenum, colstart, colend):
1125 1125 self.line = line
1126 1126 self.linenum = linenum
1127 1127 self.colstart = colstart
1128 1128 self.colend = colend
1129 1129
1130 1130 def __eq__(self, other):
1131 1131 return self.line == other.line
1132 1132
1133 1133 matches = {}
1134 1134 copies = {}
1135 1135 def grepbody(fn, rev, body):
1136 1136 matches[rev].setdefault(fn, [])
1137 1137 m = matches[rev][fn]
1138 1138 for lnum, cstart, cend, line in matchlines(body):
1139 1139 s = linestate(line, lnum, cstart, cend)
1140 1140 m.append(s)
1141 1141
1142 1142 def difflinestates(a, b):
1143 1143 sm = difflib.SequenceMatcher(None, a, b)
1144 1144 for tag, alo, ahi, blo, bhi in sm.get_opcodes():
1145 1145 if tag == 'insert':
1146 1146 for i in xrange(blo, bhi):
1147 1147 yield ('+', b[i])
1148 1148 elif tag == 'delete':
1149 1149 for i in xrange(alo, ahi):
1150 1150 yield ('-', a[i])
1151 1151 elif tag == 'replace':
1152 1152 for i in xrange(alo, ahi):
1153 1153 yield ('-', a[i])
1154 1154 for i in xrange(blo, bhi):
1155 1155 yield ('+', b[i])
1156 1156
1157 1157 prev = {}
1158 1158 def display(fn, rev, states, prevstates):
1159 1159 counts = {'-': 0, '+': 0}
1160 1160 filerevmatches = {}
1161 1161 if incrementing or not opts['all']:
1162 1162 a, b, r = prevstates, states, rev
1163 1163 else:
1164 1164 a, b, r = states, prevstates, prev.get(fn, -1)
1165 1165 for change, l in difflinestates(a, b):
1166 1166 cols = [fn, str(r)]
1167 1167 if opts['line_number']:
1168 1168 cols.append(str(l.linenum))
1169 1169 if opts['all']:
1170 1170 cols.append(change)
1171 1171 if opts['user']:
1172 1172 cols.append(ui.shortuser(get(r)[1]))
1173 1173 if opts['files_with_matches']:
1174 1174 c = (fn, r)
1175 1175 if c in filerevmatches:
1176 1176 continue
1177 1177 filerevmatches[c] = 1
1178 1178 else:
1179 1179 cols.append(l.line)
1180 1180 ui.write(sep.join(cols), eol)
1181 1181 counts[change] += 1
1182 1182 return counts['+'], counts['-']
1183 1183
1184 1184 fstate = {}
1185 1185 skip = {}
1186 1186 get = util.cachefunc(lambda r: repo.changectx(r).changeset())
1187 1187 changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts)
1188 1188 count = 0
1189 1189 incrementing = False
1190 1190 follow = opts.get('follow')
1191 1191 for st, rev, fns in changeiter:
1192 1192 if st == 'window':
1193 1193 incrementing = rev
1194 1194 matches.clear()
1195 1195 elif st == 'add':
1196 1196 mf = repo.changectx(rev).manifest()
1197 1197 matches[rev] = {}
1198 1198 for fn in fns:
1199 1199 if fn in skip:
1200 1200 continue
1201 1201 fstate.setdefault(fn, {})
1202 1202 try:
1203 1203 grepbody(fn, rev, getfile(fn).read(mf[fn]))
1204 1204 if follow:
1205 1205 copied = getfile(fn).renamed(mf[fn])
1206 1206 if copied:
1207 1207 copies.setdefault(rev, {})[fn] = copied[0]
1208 1208 except KeyError:
1209 1209 pass
1210 1210 elif st == 'iter':
1211 1211 states = matches[rev].items()
1212 1212 states.sort()
1213 1213 for fn, m in states:
1214 1214 copy = copies.get(rev, {}).get(fn)
1215 1215 if fn in skip:
1216 1216 if copy:
1217 1217 skip[copy] = True
1218 1218 continue
1219 1219 if incrementing or not opts['all'] or fstate[fn]:
1220 1220 pos, neg = display(fn, rev, m, fstate[fn])
1221 1221 count += pos + neg
1222 1222 if pos and not opts['all']:
1223 1223 skip[fn] = True
1224 1224 if copy:
1225 1225 skip[copy] = True
1226 1226 fstate[fn] = m
1227 1227 if copy:
1228 1228 fstate[copy] = m
1229 1229 prev[fn] = rev
1230 1230
1231 1231 if not incrementing:
1232 1232 fstate = fstate.items()
1233 1233 fstate.sort()
1234 1234 for fn, state in fstate:
1235 1235 if fn in skip:
1236 1236 continue
1237 1237 if fn not in copies.get(prev[fn], {}):
1238 1238 display(fn, rev, {}, state)
1239 1239 return (count == 0 and 1) or 0
1240 1240
1241 1241 def heads(ui, repo, **opts):
1242 1242 """show current repository heads
1243 1243
1244 1244 Show all repository head changesets.
1245 1245
1246 1246 Repository "heads" are changesets that don't have children
1247 1247 changesets. They are where development generally takes place and
1248 1248 are the usual targets for update and merge operations.
1249 1249 """
1250 1250 if opts['rev']:
1251 1251 heads = repo.heads(repo.lookup(opts['rev']))
1252 1252 else:
1253 1253 heads = repo.heads()
1254 1254 displayer = cmdutil.show_changeset(ui, repo, opts)
1255 1255 for n in heads:
1256 1256 displayer.show(changenode=n)
1257 1257
1258 1258 def help_(ui, name=None, with_version=False):
1259 1259 """show help for a command, extension, or list of commands
1260 1260
1261 1261 With no arguments, print a list of commands and short help.
1262 1262
1263 1263 Given a command name, print help for that command.
1264 1264
1265 1265 Given an extension name, print help for that extension, and the
1266 1266 commands it provides."""
1267 1267 option_lists = []
1268 1268
1269 1269 def helpcmd(name):
1270 1270 if with_version:
1271 1271 version_(ui)
1272 1272 ui.write('\n')
1273 1273 aliases, i = findcmd(ui, name)
1274 1274 # synopsis
1275 1275 ui.write("%s\n\n" % i[2])
1276 1276
1277 1277 # description
1278 1278 doc = i[0].__doc__
1279 1279 if not doc:
1280 1280 doc = _("(No help text available)")
1281 1281 if ui.quiet:
1282 1282 doc = doc.splitlines(0)[0]
1283 1283 ui.write("%s\n" % doc.rstrip())
1284 1284
1285 1285 if not ui.quiet:
1286 1286 # aliases
1287 1287 if len(aliases) > 1:
1288 1288 ui.write(_("\naliases: %s\n") % ', '.join(aliases[1:]))
1289 1289
1290 1290 # options
1291 1291 if i[1]:
1292 1292 option_lists.append(("options", i[1]))
1293 1293
1294 1294 def helplist(select=None):
1295 1295 h = {}
1296 1296 cmds = {}
1297 1297 for c, e in table.items():
1298 1298 f = c.split("|", 1)[0]
1299 1299 if select and not select(f):
1300 1300 continue
1301 1301 if name == "shortlist" and not f.startswith("^"):
1302 1302 continue
1303 1303 f = f.lstrip("^")
1304 1304 if not ui.debugflag and f.startswith("debug"):
1305 1305 continue
1306 1306 doc = e[0].__doc__
1307 1307 if not doc:
1308 1308 doc = _("(No help text available)")
1309 1309 h[f] = doc.splitlines(0)[0].rstrip()
1310 1310 cmds[f] = c.lstrip("^")
1311 1311
1312 1312 fns = h.keys()
1313 1313 fns.sort()
1314 1314 m = max(map(len, fns))
1315 1315 for f in fns:
1316 1316 if ui.verbose:
1317 1317 commands = cmds[f].replace("|",", ")
1318 1318 ui.write(" %s:\n %s\n"%(commands, h[f]))
1319 1319 else:
1320 1320 ui.write(' %-*s %s\n' % (m, f, h[f]))
1321 1321
1322 1322 def helptopic(name):
1323 1323 v = None
1324 1324 for i in help.helptable:
1325 1325 l = i.split('|')
1326 1326 if name in l:
1327 1327 v = i
1328 1328 header = l[-1]
1329 1329 if not v:
1330 1330 raise UnknownCommand(name)
1331 1331
1332 1332 # description
1333 1333 doc = help.helptable[v]
1334 1334 if not doc:
1335 1335 doc = _("(No help text available)")
1336 1336 if callable(doc):
1337 1337 doc = doc()
1338 1338
1339 1339 ui.write("%s\n" % header)
1340 1340 ui.write("%s\n" % doc.rstrip())
1341 1341
1342 1342 def helpext(name):
1343 1343 try:
1344 1344 mod = findext(name)
1345 1345 except KeyError:
1346 1346 raise UnknownCommand(name)
1347 1347
1348 1348 doc = (mod.__doc__ or _('No help text available')).splitlines(0)
1349 1349 ui.write(_('%s extension - %s\n') % (name.split('.')[-1], doc[0]))
1350 1350 for d in doc[1:]:
1351 1351 ui.write(d, '\n')
1352 1352
1353 1353 ui.status('\n')
1354 1354
1355 1355 try:
1356 1356 ct = mod.cmdtable
1357 1357 except AttributeError:
1358 1358 ui.status(_('no commands defined\n'))
1359 1359 return
1360 1360
1361 1361 if ui.verbose:
1362 1362 ui.status(_('list of commands:\n\n'))
1363 1363 else:
1364 1364 ui.status(_('list of commands (use "hg help -v %s" '
1365 1365 'to show aliases and global options):\n\n') % name)
1366 1366
1367 1367 modcmds = dict.fromkeys([c.split('|', 1)[0] for c in ct])
1368 1368 helplist(modcmds.has_key)
1369 1369
1370 1370 if name and name != 'shortlist':
1371 1371 i = None
1372 1372 for f in (helpcmd, helptopic, helpext):
1373 1373 try:
1374 1374 f(name)
1375 1375 i = None
1376 1376 break
1377 1377 except UnknownCommand, inst:
1378 1378 i = inst
1379 1379 if i:
1380 1380 raise i
1381 1381
1382 1382 else:
1383 1383 # program name
1384 1384 if ui.verbose or with_version:
1385 1385 version_(ui)
1386 1386 else:
1387 1387 ui.status(_("Mercurial Distributed SCM\n"))
1388 1388 ui.status('\n')
1389 1389
1390 1390 # list of commands
1391 1391 if name == "shortlist":
1392 1392 ui.status(_('basic commands (use "hg help" '
1393 1393 'for the full list or option "-v" for details):\n\n'))
1394 1394 elif ui.verbose:
1395 1395 ui.status(_('list of commands:\n\n'))
1396 1396 else:
1397 1397 ui.status(_('list of commands (use "hg help -v" '
1398 1398 'to show aliases and global options):\n\n'))
1399 1399
1400 1400 helplist()
1401 1401
1402 1402 # global options
1403 1403 if ui.verbose:
1404 1404 option_lists.append(("global options", globalopts))
1405 1405
1406 1406 # list all option lists
1407 1407 opt_output = []
1408 1408 for title, options in option_lists:
1409 1409 opt_output.append(("\n%s:\n" % title, None))
1410 1410 for shortopt, longopt, default, desc in options:
1411 1411 if "DEPRECATED" in desc and not ui.verbose: continue
1412 1412 opt_output.append(("%2s%s" % (shortopt and "-%s" % shortopt,
1413 1413 longopt and " --%s" % longopt),
1414 1414 "%s%s" % (desc,
1415 1415 default
1416 1416 and _(" (default: %s)") % default
1417 1417 or "")))
1418 1418
1419 1419 if opt_output:
1420 1420 opts_len = max([len(line[0]) for line in opt_output if line[1]])
1421 1421 for first, second in opt_output:
1422 1422 if second:
1423 1423 ui.write(" %-*s %s\n" % (opts_len, first, second))
1424 1424 else:
1425 1425 ui.write("%s\n" % first)
1426 1426
1427 1427 def identify(ui, repo):
1428 1428 """print information about the working copy
1429 1429
1430 1430 Print a short summary of the current state of the repo.
1431 1431
1432 1432 This summary identifies the repository state using one or two parent
1433 1433 hash identifiers, followed by a "+" if there are uncommitted changes
1434 1434 in the working directory, followed by a list of tags for this revision.
1435 1435 """
1436 1436 parents = [p for p in repo.dirstate.parents() if p != nullid]
1437 1437 if not parents:
1438 1438 ui.write(_("unknown\n"))
1439 1439 return
1440 1440
1441 1441 hexfunc = ui.debugflag and hex or short
1442 1442 modified, added, removed, deleted = repo.status()[:4]
1443 1443 output = ["%s%s" %
1444 1444 ('+'.join([hexfunc(parent) for parent in parents]),
1445 1445 (modified or added or removed or deleted) and "+" or "")]
1446 1446
1447 1447 if not ui.quiet:
1448 1448
1449 1449 branch = util.tolocal(repo.workingctx().branch())
1450 1450 if branch:
1451 1451 output.append("(%s)" % branch)
1452 1452
1453 1453 # multiple tags for a single parent separated by '/'
1454 1454 parenttags = ['/'.join(tags)
1455 1455 for tags in map(repo.nodetags, parents) if tags]
1456 1456 # tags for multiple parents separated by ' + '
1457 1457 if parenttags:
1458 1458 output.append(' + '.join(parenttags))
1459 1459
1460 1460 ui.write("%s\n" % ' '.join(output))
1461 1461
1462 1462 def import_(ui, repo, patch1, *patches, **opts):
1463 1463 """import an ordered set of patches
1464 1464
1465 1465 Import a list of patches and commit them individually.
1466 1466
1467 1467 If there are outstanding changes in the working directory, import
1468 1468 will abort unless given the -f flag.
1469 1469
1470 1470 You can import a patch straight from a mail message. Even patches
1471 1471 as attachments work (body part must be type text/plain or
1472 1472 text/x-patch to be used). From and Subject headers of email
1473 1473 message are used as default committer and commit message. All
1474 1474 text/plain body parts before first diff are added to commit
1475 1475 message.
1476 1476
1477 1477 If imported patch was generated by hg export, user and description
1478 1478 from patch override values from message headers and body. Values
1479 1479 given on command line with -m and -u override these.
1480 1480
1481 1481 To read a patch from standard input, use patch name "-".
1482 1482 """
1483 1483 patches = (patch1,) + patches
1484 1484
1485 1485 if not opts['force']:
1486 1486 bail_if_changed(repo)
1487 1487
1488 1488 d = opts["base"]
1489 1489 strip = opts["strip"]
1490 1490
1491 1491 wlock = repo.wlock()
1492 1492 lock = repo.lock()
1493 1493
1494 1494 for p in patches:
1495 1495 pf = os.path.join(d, p)
1496 1496
1497 1497 if pf == '-':
1498 1498 ui.status(_("applying patch from stdin\n"))
1499 1499 tmpname, message, user, date = patch.extract(ui, sys.stdin)
1500 1500 else:
1501 1501 ui.status(_("applying %s\n") % p)
1502 1502 tmpname, message, user, date = patch.extract(ui, file(pf))
1503 1503
1504 1504 if tmpname is None:
1505 1505 raise util.Abort(_('no diffs found'))
1506 1506
1507 1507 try:
1508 1508 cmdline_message = logmessage(opts)
1509 1509 if cmdline_message:
1510 1510 # pickup the cmdline msg
1511 1511 message = cmdline_message
1512 1512 elif message:
1513 1513 # pickup the patch msg
1514 1514 message = message.strip()
1515 1515 else:
1516 1516 # launch the editor
1517 1517 message = None
1518 1518 ui.debug(_('message:\n%s\n') % message)
1519 1519
1520 1520 files = {}
1521 1521 try:
1522 1522 fuzz = patch.patch(tmpname, ui, strip=strip, cwd=repo.root,
1523 1523 files=files)
1524 1524 finally:
1525 1525 files = patch.updatedir(ui, repo, files, wlock=wlock)
1526 1526 repo.commit(files, message, user, date, wlock=wlock, lock=lock)
1527 1527 finally:
1528 1528 os.unlink(tmpname)
1529 1529
1530 1530 def incoming(ui, repo, source="default", **opts):
1531 1531 """show new changesets found in source
1532 1532
1533 1533 Show new changesets found in the specified path/URL or the default
1534 1534 pull location. These are the changesets that would be pulled if a pull
1535 1535 was requested.
1536 1536
1537 1537 For remote repository, using --bundle avoids downloading the changesets
1538 1538 twice if the incoming is followed by a pull.
1539 1539
1540 1540 See pull for valid source format details.
1541 1541 """
1542 1542 source = ui.expandpath(source)
1543 1543 setremoteconfig(ui, opts)
1544 1544
1545 1545 other = hg.repository(ui, source)
1546 1546 incoming = repo.findincoming(other, force=opts["force"])
1547 1547 if not incoming:
1548 1548 ui.status(_("no changes found\n"))
1549 1549 return
1550 1550
1551 1551 cleanup = None
1552 1552 try:
1553 1553 fname = opts["bundle"]
1554 1554 if fname or not other.local():
1555 1555 # create a bundle (uncompressed if other repo is not local)
1556 1556 cg = other.changegroup(incoming, "incoming")
1557 1557 bundletype = other.local() and "HG10BZ" or "HG10UN"
1558 1558 fname = cleanup = changegroup.writebundle(cg, fname, bundletype)
1559 1559 # keep written bundle?
1560 1560 if opts["bundle"]:
1561 1561 cleanup = None
1562 1562 if not other.local():
1563 1563 # use the created uncompressed bundlerepo
1564 1564 other = bundlerepo.bundlerepository(ui, repo.root, fname)
1565 1565
1566 1566 revs = None
1567 1567 if opts['rev']:
1568 1568 revs = [other.lookup(rev) for rev in opts['rev']]
1569 1569 o = other.changelog.nodesbetween(incoming, revs)[0]
1570 1570 if opts['newest_first']:
1571 1571 o.reverse()
1572 1572 displayer = cmdutil.show_changeset(ui, other, opts)
1573 1573 for n in o:
1574 1574 parents = [p for p in other.changelog.parents(n) if p != nullid]
1575 1575 if opts['no_merges'] and len(parents) == 2:
1576 1576 continue
1577 1577 displayer.show(changenode=n)
1578 1578 finally:
1579 1579 if hasattr(other, 'close'):
1580 1580 other.close()
1581 1581 if cleanup:
1582 1582 os.unlink(cleanup)
1583 1583
1584 1584 def init(ui, dest=".", **opts):
1585 1585 """create a new repository in the given directory
1586 1586
1587 1587 Initialize a new repository in the given directory. If the given
1588 1588 directory does not exist, it is created.
1589 1589
1590 1590 If no directory is given, the current directory is used.
1591 1591
1592 1592 It is possible to specify an ssh:// URL as the destination.
1593 1593 Look at the help text for the pull command for important details
1594 1594 about ssh:// URLs.
1595 1595 """
1596 1596 setremoteconfig(ui, opts)
1597 1597 hg.repository(ui, dest, create=1)
1598 1598
1599 1599 def locate(ui, repo, *pats, **opts):
1600 1600 """locate files matching specific patterns
1601 1601
1602 1602 Print all files under Mercurial control whose names match the
1603 1603 given patterns.
1604 1604
1605 1605 This command searches the entire repository by default. To search
1606 1606 just the current directory and its subdirectories, use "--include .".
1607 1607
1608 1608 If no patterns are given to match, this command prints all file
1609 1609 names.
1610 1610
1611 1611 If you want to feed the output of this command into the "xargs"
1612 1612 command, use the "-0" option to both this command and "xargs".
1613 1613 This will avoid the problem of "xargs" treating single filenames
1614 1614 that contain white space as multiple filenames.
1615 1615 """
1616 1616 end = opts['print0'] and '\0' or '\n'
1617 1617 rev = opts['rev']
1618 1618 if rev:
1619 1619 node = repo.lookup(rev)
1620 1620 else:
1621 1621 node = None
1622 1622
1623 ret = 1
1623 1624 for src, abs, rel, exact in cmdutil.walk(repo, pats, opts, node=node,
1624 1625 default='relglob'):
1625 1626 if not node and repo.dirstate.state(abs) == '?':
1626 1627 continue
1627 1628 if opts['fullpath']:
1628 1629 ui.write(os.path.join(repo.root, abs), end)
1629 1630 else:
1630 1631 ui.write(((pats and rel) or abs), end)
1632 ret = 0
1633
1634 return ret
1631 1635
1632 1636 def log(ui, repo, *pats, **opts):
1633 1637 """show revision history of entire repository or files
1634 1638
1635 1639 Print the revision history of the specified files or the entire
1636 1640 project.
1637 1641
1638 1642 File history is shown without following rename or copy history of
1639 1643 files. Use -f/--follow with a file name to follow history across
1640 1644 renames and copies. --follow without a file name will only show
1641 1645 ancestors or descendants of the starting revision. --follow-first
1642 1646 only follows the first parent of merge revisions.
1643 1647
1644 1648 If no revision range is specified, the default is tip:0 unless
1645 1649 --follow is set, in which case the working directory parent is
1646 1650 used as the starting revision.
1647 1651
1648 1652 By default this command outputs: changeset id and hash, tags,
1649 1653 non-trivial parents, user, date and time, and a summary for each
1650 1654 commit. When the -v/--verbose switch is used, the list of changed
1651 1655 files and full commit message is shown.
1652 1656
1653 1657 NOTE: log -p may generate unexpected diff output for merge
1654 1658 changesets, as it will compare the merge changeset against its
1655 1659 first parent only. Also, the files: list will only reflect files
1656 1660 that are different from BOTH parents.
1657 1661
1658 1662 """
1659 1663
1660 1664 get = util.cachefunc(lambda r: repo.changectx(r).changeset())
1661 1665 changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts)
1662 1666
1663 1667 if opts['limit']:
1664 1668 try:
1665 1669 limit = int(opts['limit'])
1666 1670 except ValueError:
1667 1671 raise util.Abort(_('limit must be a positive integer'))
1668 1672 if limit <= 0: raise util.Abort(_('limit must be positive'))
1669 1673 else:
1670 1674 limit = sys.maxint
1671 1675 count = 0
1672 1676
1673 1677 if opts['copies'] and opts['rev']:
1674 1678 endrev = max(cmdutil.revrange(repo, opts['rev'])) + 1
1675 1679 else:
1676 1680 endrev = repo.changelog.count()
1677 1681 rcache = {}
1678 1682 ncache = {}
1679 1683 dcache = []
1680 1684 def getrenamed(fn, rev, man):
1681 1685 '''looks up all renames for a file (up to endrev) the first
1682 1686 time the file is given. It indexes on the changerev and only
1683 1687 parses the manifest if linkrev != changerev.
1684 1688 Returns rename info for fn at changerev rev.'''
1685 1689 if fn not in rcache:
1686 1690 rcache[fn] = {}
1687 1691 ncache[fn] = {}
1688 1692 fl = repo.file(fn)
1689 1693 for i in xrange(fl.count()):
1690 1694 node = fl.node(i)
1691 1695 lr = fl.linkrev(node)
1692 1696 renamed = fl.renamed(node)
1693 1697 rcache[fn][lr] = renamed
1694 1698 if renamed:
1695 1699 ncache[fn][node] = renamed
1696 1700 if lr >= endrev:
1697 1701 break
1698 1702 if rev in rcache[fn]:
1699 1703 return rcache[fn][rev]
1700 1704 mr = repo.manifest.rev(man)
1701 1705 if repo.manifest.parentrevs(mr) != (mr - 1, nullrev):
1702 1706 return ncache[fn].get(repo.manifest.find(man, fn)[0])
1703 1707 if not dcache or dcache[0] != man:
1704 1708 dcache[:] = [man, repo.manifest.readdelta(man)]
1705 1709 if fn in dcache[1]:
1706 1710 return ncache[fn].get(dcache[1][fn])
1707 1711 return None
1708 1712
1709 1713 df = False
1710 1714 if opts["date"]:
1711 1715 df = util.matchdate(opts["date"])
1712 1716
1713 1717
1714 1718 displayer = cmdutil.show_changeset(ui, repo, opts, True, matchfn)
1715 1719 for st, rev, fns in changeiter:
1716 1720 if st == 'add':
1717 1721 changenode = repo.changelog.node(rev)
1718 1722 parents = [p for p in repo.changelog.parentrevs(rev)
1719 1723 if p != nullrev]
1720 1724 if opts['no_merges'] and len(parents) == 2:
1721 1725 continue
1722 1726 if opts['only_merges'] and len(parents) != 2:
1723 1727 continue
1724 1728
1725 1729 if df:
1726 1730 changes = get(rev)
1727 1731 if not df(changes[2][0]):
1728 1732 continue
1729 1733
1730 1734 if opts['keyword']:
1731 1735 changes = get(rev)
1732 1736 miss = 0
1733 1737 for k in [kw.lower() for kw in opts['keyword']]:
1734 1738 if not (k in changes[1].lower() or
1735 1739 k in changes[4].lower() or
1736 1740 k in " ".join(changes[3][:20]).lower()):
1737 1741 miss = 1
1738 1742 break
1739 1743 if miss:
1740 1744 continue
1741 1745
1742 1746 copies = []
1743 1747 if opts.get('copies') and rev:
1744 1748 mf = get(rev)[0]
1745 1749 for fn in get(rev)[3]:
1746 1750 rename = getrenamed(fn, rev, mf)
1747 1751 if rename:
1748 1752 copies.append((fn, rename[0]))
1749 1753 displayer.show(rev, changenode, copies=copies)
1750 1754 elif st == 'iter':
1751 1755 if count == limit: break
1752 1756 if displayer.flush(rev):
1753 1757 count += 1
1754 1758
1755 1759 def manifest(ui, repo, rev=None):
1756 1760 """output the current or given revision of the project manifest
1757 1761
1758 1762 Print a list of version controlled files for the given revision.
1759 1763 If no revision is given, the parent of the working directory is used,
1760 1764 or tip if no revision is checked out.
1761 1765
1762 1766 The manifest is the list of files being version controlled. If no revision
1763 1767 is given then the first parent of the working directory is used.
1764 1768
1765 1769 With -v flag, print file permissions. With --debug flag, print
1766 1770 file revision hashes.
1767 1771 """
1768 1772
1769 1773 m = repo.changectx(rev).manifest()
1770 1774 files = m.keys()
1771 1775 files.sort()
1772 1776
1773 1777 for f in files:
1774 1778 if ui.debugflag:
1775 1779 ui.write("%40s " % hex(m[f]))
1776 1780 if ui.verbose:
1777 1781 ui.write("%3s " % (m.execf(f) and "755" or "644"))
1778 1782 ui.write("%s\n" % f)
1779 1783
1780 1784 def merge(ui, repo, node=None, force=None, branch=None):
1781 1785 """merge working directory with another revision
1782 1786
1783 1787 Merge the contents of the current working directory and the
1784 1788 requested revision. Files that changed between either parent are
1785 1789 marked as changed for the next commit and a commit must be
1786 1790 performed before any further updates are allowed.
1787 1791
1788 1792 If no revision is specified, the working directory's parent is a
1789 1793 head revision, and the repository contains exactly one other head,
1790 1794 the other head is merged with by default. Otherwise, an explicit
1791 1795 revision to merge with must be provided.
1792 1796 """
1793 1797
1794 1798 if node or branch:
1795 1799 node = _lookup(repo, node, branch)
1796 1800 else:
1797 1801 heads = repo.heads()
1798 1802 if len(heads) > 2:
1799 1803 raise util.Abort(_('repo has %d heads - '
1800 1804 'please merge with an explicit rev') %
1801 1805 len(heads))
1802 1806 if len(heads) == 1:
1803 1807 raise util.Abort(_('there is nothing to merge - '
1804 1808 'use "hg update" instead'))
1805 1809 parent = repo.dirstate.parents()[0]
1806 1810 if parent not in heads:
1807 1811 raise util.Abort(_('working dir not at a head rev - '
1808 1812 'use "hg update" or merge with an explicit rev'))
1809 1813 node = parent == heads[0] and heads[-1] or heads[0]
1810 1814 return hg.merge(repo, node, force=force)
1811 1815
1812 1816 def outgoing(ui, repo, dest=None, **opts):
1813 1817 """show changesets not found in destination
1814 1818
1815 1819 Show changesets not found in the specified destination repository or
1816 1820 the default push location. These are the changesets that would be pushed
1817 1821 if a push was requested.
1818 1822
1819 1823 See pull for valid destination format details.
1820 1824 """
1821 1825 dest = ui.expandpath(dest or 'default-push', dest or 'default')
1822 1826 setremoteconfig(ui, opts)
1823 1827 revs = None
1824 1828 if opts['rev']:
1825 1829 revs = [repo.lookup(rev) for rev in opts['rev']]
1826 1830
1827 1831 other = hg.repository(ui, dest)
1828 1832 o = repo.findoutgoing(other, force=opts['force'])
1829 1833 if not o:
1830 1834 ui.status(_("no changes found\n"))
1831 1835 return
1832 1836 o = repo.changelog.nodesbetween(o, revs)[0]
1833 1837 if opts['newest_first']:
1834 1838 o.reverse()
1835 1839 displayer = cmdutil.show_changeset(ui, repo, opts)
1836 1840 for n in o:
1837 1841 parents = [p for p in repo.changelog.parents(n) if p != nullid]
1838 1842 if opts['no_merges'] and len(parents) == 2:
1839 1843 continue
1840 1844 displayer.show(changenode=n)
1841 1845
1842 1846 def parents(ui, repo, file_=None, **opts):
1843 1847 """show the parents of the working dir or revision
1844 1848
1845 1849 Print the working directory's parent revisions.
1846 1850 """
1847 1851 rev = opts.get('rev')
1848 1852 if rev:
1849 1853 if file_:
1850 1854 ctx = repo.filectx(file_, changeid=rev)
1851 1855 else:
1852 1856 ctx = repo.changectx(rev)
1853 1857 p = [cp.node() for cp in ctx.parents()]
1854 1858 else:
1855 1859 p = repo.dirstate.parents()
1856 1860
1857 1861 displayer = cmdutil.show_changeset(ui, repo, opts)
1858 1862 for n in p:
1859 1863 if n != nullid:
1860 1864 displayer.show(changenode=n)
1861 1865
1862 1866 def paths(ui, repo, search=None):
1863 1867 """show definition of symbolic path names
1864 1868
1865 1869 Show definition of symbolic path name NAME. If no name is given, show
1866 1870 definition of available names.
1867 1871
1868 1872 Path names are defined in the [paths] section of /etc/mercurial/hgrc
1869 1873 and $HOME/.hgrc. If run inside a repository, .hg/hgrc is used, too.
1870 1874 """
1871 1875 if search:
1872 1876 for name, path in ui.configitems("paths"):
1873 1877 if name == search:
1874 1878 ui.write("%s\n" % path)
1875 1879 return
1876 1880 ui.warn(_("not found!\n"))
1877 1881 return 1
1878 1882 else:
1879 1883 for name, path in ui.configitems("paths"):
1880 1884 ui.write("%s = %s\n" % (name, path))
1881 1885
1882 1886 def postincoming(ui, repo, modheads, optupdate):
1883 1887 if modheads == 0:
1884 1888 return
1885 1889 if optupdate:
1886 1890 if modheads == 1:
1887 1891 return hg.update(repo, repo.changelog.tip()) # update
1888 1892 else:
1889 1893 ui.status(_("not updating, since new heads added\n"))
1890 1894 if modheads > 1:
1891 1895 ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n"))
1892 1896 else:
1893 1897 ui.status(_("(run 'hg update' to get a working copy)\n"))
1894 1898
1895 1899 def pull(ui, repo, source="default", **opts):
1896 1900 """pull changes from the specified source
1897 1901
1898 1902 Pull changes from a remote repository to a local one.
1899 1903
1900 1904 This finds all changes from the repository at the specified path
1901 1905 or URL and adds them to the local repository. By default, this
1902 1906 does not update the copy of the project in the working directory.
1903 1907
1904 1908 Valid URLs are of the form:
1905 1909
1906 1910 local/filesystem/path (or file://local/filesystem/path)
1907 1911 http://[user@]host[:port]/[path]
1908 1912 https://[user@]host[:port]/[path]
1909 1913 ssh://[user@]host[:port]/[path]
1910 1914 static-http://host[:port]/[path]
1911 1915
1912 1916 Paths in the local filesystem can either point to Mercurial
1913 1917 repositories or to bundle files (as created by 'hg bundle' or
1914 1918 'hg incoming --bundle'). The static-http:// protocol, albeit slow,
1915 1919 allows access to a Mercurial repository where you simply use a web
1916 1920 server to publish the .hg directory as static content.
1917 1921
1918 1922 Some notes about using SSH with Mercurial:
1919 1923 - SSH requires an accessible shell account on the destination machine
1920 1924 and a copy of hg in the remote path or specified with as remotecmd.
1921 1925 - path is relative to the remote user's home directory by default.
1922 1926 Use an extra slash at the start of a path to specify an absolute path:
1923 1927 ssh://example.com//tmp/repository
1924 1928 - Mercurial doesn't use its own compression via SSH; the right thing
1925 1929 to do is to configure it in your ~/.ssh/config, e.g.:
1926 1930 Host *.mylocalnetwork.example.com
1927 1931 Compression no
1928 1932 Host *
1929 1933 Compression yes
1930 1934 Alternatively specify "ssh -C" as your ssh command in your hgrc or
1931 1935 with the --ssh command line option.
1932 1936 """
1933 1937 source = ui.expandpath(source)
1934 1938 setremoteconfig(ui, opts)
1935 1939
1936 1940 other = hg.repository(ui, source)
1937 1941 ui.status(_('pulling from %s\n') % (source))
1938 1942 revs = None
1939 1943 if opts['rev']:
1940 1944 if 'lookup' in other.capabilities:
1941 1945 revs = [other.lookup(rev) for rev in opts['rev']]
1942 1946 else:
1943 1947 error = _("Other repository doesn't support revision lookup, so a rev cannot be specified.")
1944 1948 raise util.Abort(error)
1945 1949 modheads = repo.pull(other, heads=revs, force=opts['force'])
1946 1950 return postincoming(ui, repo, modheads, opts['update'])
1947 1951
1948 1952 def push(ui, repo, dest=None, **opts):
1949 1953 """push changes to the specified destination
1950 1954
1951 1955 Push changes from the local repository to the given destination.
1952 1956
1953 1957 This is the symmetrical operation for pull. It helps to move
1954 1958 changes from the current repository to a different one. If the
1955 1959 destination is local this is identical to a pull in that directory
1956 1960 from the current one.
1957 1961
1958 1962 By default, push will refuse to run if it detects the result would
1959 1963 increase the number of remote heads. This generally indicates the
1960 1964 the client has forgotten to sync and merge before pushing.
1961 1965
1962 1966 Valid URLs are of the form:
1963 1967
1964 1968 local/filesystem/path (or file://local/filesystem/path)
1965 1969 ssh://[user@]host[:port]/[path]
1966 1970 http://[user@]host[:port]/[path]
1967 1971 https://[user@]host[:port]/[path]
1968 1972
1969 1973 Look at the help text for the pull command for important details
1970 1974 about ssh:// URLs.
1971 1975
1972 1976 Pushing to http:// and https:// URLs is only possible, if this
1973 1977 feature is explicitly enabled on the remote Mercurial server.
1974 1978 """
1975 1979 dest = ui.expandpath(dest or 'default-push', dest or 'default')
1976 1980 setremoteconfig(ui, opts)
1977 1981
1978 1982 other = hg.repository(ui, dest)
1979 1983 ui.status('pushing to %s\n' % (dest))
1980 1984 revs = None
1981 1985 if opts['rev']:
1982 1986 revs = [repo.lookup(rev) for rev in opts['rev']]
1983 1987 r = repo.push(other, opts['force'], revs=revs)
1984 1988 return r == 0
1985 1989
1986 1990 def rawcommit(ui, repo, *pats, **opts):
1987 1991 """raw commit interface (DEPRECATED)
1988 1992
1989 1993 (DEPRECATED)
1990 1994 Lowlevel commit, for use in helper scripts.
1991 1995
1992 1996 This command is not intended to be used by normal users, as it is
1993 1997 primarily useful for importing from other SCMs.
1994 1998
1995 1999 This command is now deprecated and will be removed in a future
1996 2000 release, please use debugsetparents and commit instead.
1997 2001 """
1998 2002
1999 2003 ui.warn(_("(the rawcommit command is deprecated)\n"))
2000 2004
2001 2005 message = logmessage(opts)
2002 2006
2003 2007 files, match, anypats = cmdutil.matchpats(repo, pats, opts)
2004 2008 if opts['files']:
2005 2009 files += open(opts['files']).read().splitlines()
2006 2010
2007 2011 parents = [repo.lookup(p) for p in opts['parent']]
2008 2012
2009 2013 try:
2010 2014 repo.rawcommit(files, message, opts['user'], opts['date'], *parents)
2011 2015 except ValueError, inst:
2012 2016 raise util.Abort(str(inst))
2013 2017
2014 2018 def recover(ui, repo):
2015 2019 """roll back an interrupted transaction
2016 2020
2017 2021 Recover from an interrupted commit or pull.
2018 2022
2019 2023 This command tries to fix the repository status after an interrupted
2020 2024 operation. It should only be necessary when Mercurial suggests it.
2021 2025 """
2022 2026 if repo.recover():
2023 2027 return hg.verify(repo)
2024 2028 return 1
2025 2029
2026 2030 def remove(ui, repo, *pats, **opts):
2027 2031 """remove the specified files on the next commit
2028 2032
2029 2033 Schedule the indicated files for removal from the repository.
2030 2034
2031 2035 This only removes files from the current branch, not from the
2032 2036 entire project history. If the files still exist in the working
2033 2037 directory, they will be deleted from it. If invoked with --after,
2034 2038 files that have been manually deleted are marked as removed.
2035 2039
2036 2040 This command schedules the files to be removed at the next commit.
2037 2041 To undo a remove before that, see hg revert.
2038 2042
2039 2043 Modified files and added files are not removed by default. To
2040 2044 remove them, use the -f/--force option.
2041 2045 """
2042 2046 names = []
2043 2047 if not opts['after'] and not pats:
2044 2048 raise util.Abort(_('no files specified'))
2045 2049 files, matchfn, anypats = cmdutil.matchpats(repo, pats, opts)
2046 2050 exact = dict.fromkeys(files)
2047 2051 mardu = map(dict.fromkeys, repo.status(files=files, match=matchfn))[:5]
2048 2052 modified, added, removed, deleted, unknown = mardu
2049 2053 remove, forget = [], []
2050 2054 for src, abs, rel, exact in cmdutil.walk(repo, pats, opts):
2051 2055 reason = None
2052 2056 if abs not in deleted and opts['after']:
2053 2057 reason = _('is still present')
2054 2058 elif abs in modified and not opts['force']:
2055 2059 reason = _('is modified (use -f to force removal)')
2056 2060 elif abs in added:
2057 2061 if opts['force']:
2058 2062 forget.append(abs)
2059 2063 continue
2060 2064 reason = _('has been marked for add (use -f to force removal)')
2061 2065 elif abs in unknown:
2062 2066 reason = _('is not managed')
2063 2067 elif abs in removed:
2064 2068 continue
2065 2069 if reason:
2066 2070 if exact:
2067 2071 ui.warn(_('not removing %s: file %s\n') % (rel, reason))
2068 2072 else:
2069 2073 if ui.verbose or not exact:
2070 2074 ui.status(_('removing %s\n') % rel)
2071 2075 remove.append(abs)
2072 2076 repo.forget(forget)
2073 2077 repo.remove(remove, unlink=not opts['after'])
2074 2078
2075 2079 def rename(ui, repo, *pats, **opts):
2076 2080 """rename files; equivalent of copy + remove
2077 2081
2078 2082 Mark dest as copies of sources; mark sources for deletion. If
2079 2083 dest is a directory, copies are put in that directory. If dest is
2080 2084 a file, there can only be one source.
2081 2085
2082 2086 By default, this command copies the contents of files as they
2083 2087 stand in the working directory. If invoked with --after, the
2084 2088 operation is recorded, but no copying is performed.
2085 2089
2086 2090 This command takes effect in the next commit. To undo a rename
2087 2091 before that, see hg revert.
2088 2092 """
2089 2093 wlock = repo.wlock(0)
2090 2094 errs, copied = docopy(ui, repo, pats, opts, wlock)
2091 2095 names = []
2092 2096 for abs, rel, exact in copied:
2093 2097 if ui.verbose or not exact:
2094 2098 ui.status(_('removing %s\n') % rel)
2095 2099 names.append(abs)
2096 2100 if not opts.get('dry_run'):
2097 2101 repo.remove(names, True, wlock)
2098 2102 return errs
2099 2103
2100 2104 def revert(ui, repo, *pats, **opts):
2101 2105 """revert files or dirs to their states as of some revision
2102 2106
2103 2107 With no revision specified, revert the named files or directories
2104 2108 to the contents they had in the parent of the working directory.
2105 2109 This restores the contents of the affected files to an unmodified
2106 2110 state and unschedules adds, removes, copies, and renames. If the
2107 2111 working directory has two parents, you must explicitly specify the
2108 2112 revision to revert to.
2109 2113
2110 2114 Modified files are saved with a .orig suffix before reverting.
2111 2115 To disable these backups, use --no-backup.
2112 2116
2113 2117 Using the -r option, revert the given files or directories to their
2114 2118 contents as of a specific revision. This can be helpful to "roll
2115 2119 back" some or all of a change that should not have been committed.
2116 2120
2117 2121 Revert modifies the working directory. It does not commit any
2118 2122 changes, or change the parent of the working directory. If you
2119 2123 revert to a revision other than the parent of the working
2120 2124 directory, the reverted files will thus appear modified
2121 2125 afterwards.
2122 2126
2123 2127 If a file has been deleted, it is recreated. If the executable
2124 2128 mode of a file was changed, it is reset.
2125 2129
2126 2130 If names are given, all files matching the names are reverted.
2127 2131
2128 2132 If no arguments are given, no files are reverted.
2129 2133 """
2130 2134
2131 2135 if opts["date"]:
2132 2136 if opts["rev"]:
2133 2137 raise util.Abort(_("you can't specify a revision and a date"))
2134 2138 opts["rev"] = cmdutil.finddate(ui, repo, opts["date"])
2135 2139
2136 2140 if not pats and not opts['all']:
2137 2141 raise util.Abort(_('no files or directories specified; '
2138 2142 'use --all to revert the whole repo'))
2139 2143
2140 2144 parent, p2 = repo.dirstate.parents()
2141 2145 if not opts['rev'] and p2 != nullid:
2142 2146 raise util.Abort(_('uncommitted merge - please provide a '
2143 2147 'specific revision'))
2144 2148 node = repo.changectx(opts['rev']).node()
2145 2149 mf = repo.manifest.read(repo.changelog.read(node)[0])
2146 2150 if node == parent:
2147 2151 pmf = mf
2148 2152 else:
2149 2153 pmf = None
2150 2154
2151 2155 wlock = repo.wlock()
2152 2156
2153 2157 # need all matching names in dirstate and manifest of target rev,
2154 2158 # so have to walk both. do not print errors if files exist in one
2155 2159 # but not other.
2156 2160
2157 2161 names = {}
2158 2162 target_only = {}
2159 2163
2160 2164 # walk dirstate.
2161 2165
2162 2166 for src, abs, rel, exact in cmdutil.walk(repo, pats, opts,
2163 2167 badmatch=mf.has_key):
2164 2168 names[abs] = (rel, exact)
2165 2169 if src == 'b':
2166 2170 target_only[abs] = True
2167 2171
2168 2172 # walk target manifest.
2169 2173
2170 2174 for src, abs, rel, exact in cmdutil.walk(repo, pats, opts, node=node,
2171 2175 badmatch=names.has_key):
2172 2176 if abs in names: continue
2173 2177 names[abs] = (rel, exact)
2174 2178 target_only[abs] = True
2175 2179
2176 2180 changes = repo.status(match=names.has_key, wlock=wlock)[:5]
2177 2181 modified, added, removed, deleted, unknown = map(dict.fromkeys, changes)
2178 2182
2179 2183 revert = ([], _('reverting %s\n'))
2180 2184 add = ([], _('adding %s\n'))
2181 2185 remove = ([], _('removing %s\n'))
2182 2186 forget = ([], _('forgetting %s\n'))
2183 2187 undelete = ([], _('undeleting %s\n'))
2184 2188 update = {}
2185 2189
2186 2190 disptable = (
2187 2191 # dispatch table:
2188 2192 # file state
2189 2193 # action if in target manifest
2190 2194 # action if not in target manifest
2191 2195 # make backup if in target manifest
2192 2196 # make backup if not in target manifest
2193 2197 (modified, revert, remove, True, True),
2194 2198 (added, revert, forget, True, False),
2195 2199 (removed, undelete, None, False, False),
2196 2200 (deleted, revert, remove, False, False),
2197 2201 (unknown, add, None, True, False),
2198 2202 (target_only, add, None, False, False),
2199 2203 )
2200 2204
2201 2205 entries = names.items()
2202 2206 entries.sort()
2203 2207
2204 2208 for abs, (rel, exact) in entries:
2205 2209 mfentry = mf.get(abs)
2206 2210 def handle(xlist, dobackup):
2207 2211 xlist[0].append(abs)
2208 2212 update[abs] = 1
2209 2213 if dobackup and not opts['no_backup'] and os.path.exists(rel):
2210 2214 bakname = "%s.orig" % rel
2211 2215 ui.note(_('saving current version of %s as %s\n') %
2212 2216 (rel, bakname))
2213 2217 if not opts.get('dry_run'):
2214 2218 util.copyfile(rel, bakname)
2215 2219 if ui.verbose or not exact:
2216 2220 ui.status(xlist[1] % rel)
2217 2221 for table, hitlist, misslist, backuphit, backupmiss in disptable:
2218 2222 if abs not in table: continue
2219 2223 # file has changed in dirstate
2220 2224 if mfentry:
2221 2225 handle(hitlist, backuphit)
2222 2226 elif misslist is not None:
2223 2227 handle(misslist, backupmiss)
2224 2228 else:
2225 2229 if exact: ui.warn(_('file not managed: %s\n') % rel)
2226 2230 break
2227 2231 else:
2228 2232 # file has not changed in dirstate
2229 2233 if node == parent:
2230 2234 if exact: ui.warn(_('no changes needed to %s\n') % rel)
2231 2235 continue
2232 2236 if pmf is None:
2233 2237 # only need parent manifest in this unlikely case,
2234 2238 # so do not read by default
2235 2239 pmf = repo.manifest.read(repo.changelog.read(parent)[0])
2236 2240 if abs in pmf:
2237 2241 if mfentry:
2238 2242 # if version of file is same in parent and target
2239 2243 # manifests, do nothing
2240 2244 if pmf[abs] != mfentry:
2241 2245 handle(revert, False)
2242 2246 else:
2243 2247 handle(remove, False)
2244 2248
2245 2249 if not opts.get('dry_run'):
2246 2250 repo.dirstate.forget(forget[0])
2247 2251 r = hg.revert(repo, node, update.has_key, wlock)
2248 2252 repo.dirstate.update(add[0], 'a')
2249 2253 repo.dirstate.update(undelete[0], 'n')
2250 2254 repo.dirstate.update(remove[0], 'r')
2251 2255 return r
2252 2256
2253 2257 def rollback(ui, repo):
2254 2258 """roll back the last transaction in this repository
2255 2259
2256 2260 Roll back the last transaction in this repository, restoring the
2257 2261 project to its state prior to the transaction.
2258 2262
2259 2263 Transactions are used to encapsulate the effects of all commands
2260 2264 that create new changesets or propagate existing changesets into a
2261 2265 repository. For example, the following commands are transactional,
2262 2266 and their effects can be rolled back:
2263 2267
2264 2268 commit
2265 2269 import
2266 2270 pull
2267 2271 push (with this repository as destination)
2268 2272 unbundle
2269 2273
2270 2274 This command should be used with care. There is only one level of
2271 2275 rollback, and there is no way to undo a rollback.
2272 2276
2273 2277 This command is not intended for use on public repositories. Once
2274 2278 changes are visible for pull by other users, rolling a transaction
2275 2279 back locally is ineffective (someone else may already have pulled
2276 2280 the changes). Furthermore, a race is possible with readers of the
2277 2281 repository; for example an in-progress pull from the repository
2278 2282 may fail if a rollback is performed.
2279 2283 """
2280 2284 repo.rollback()
2281 2285
2282 2286 def root(ui, repo):
2283 2287 """print the root (top) of the current working dir
2284 2288
2285 2289 Print the root directory of the current repository.
2286 2290 """
2287 2291 ui.write(repo.root + "\n")
2288 2292
2289 2293 def serve(ui, repo, **opts):
2290 2294 """export the repository via HTTP
2291 2295
2292 2296 Start a local HTTP repository browser and pull server.
2293 2297
2294 2298 By default, the server logs accesses to stdout and errors to
2295 2299 stderr. Use the "-A" and "-E" options to log to files.
2296 2300 """
2297 2301
2298 2302 if opts["stdio"]:
2299 2303 if repo is None:
2300 2304 raise hg.RepoError(_("There is no Mercurial repository here"
2301 2305 " (.hg not found)"))
2302 2306 s = sshserver.sshserver(ui, repo)
2303 2307 s.serve_forever()
2304 2308
2305 2309 parentui = ui.parentui or ui
2306 2310 optlist = ("name templates style address port ipv6"
2307 2311 " accesslog errorlog webdir_conf")
2308 2312 for o in optlist.split():
2309 2313 if opts[o]:
2310 2314 parentui.setconfig("web", o, str(opts[o]))
2311 2315
2312 2316 if repo is None and not ui.config("web", "webdir_conf"):
2313 2317 raise hg.RepoError(_("There is no Mercurial repository here"
2314 2318 " (.hg not found)"))
2315 2319
2316 2320 if opts['daemon'] and not opts['daemon_pipefds']:
2317 2321 rfd, wfd = os.pipe()
2318 2322 args = sys.argv[:]
2319 2323 args.append('--daemon-pipefds=%d,%d' % (rfd, wfd))
2320 2324 pid = os.spawnvp(os.P_NOWAIT | getattr(os, 'P_DETACH', 0),
2321 2325 args[0], args)
2322 2326 os.close(wfd)
2323 2327 os.read(rfd, 1)
2324 2328 os._exit(0)
2325 2329
2326 2330 httpd = hgweb.server.create_server(parentui, repo)
2327 2331
2328 2332 if ui.verbose:
2329 2333 if httpd.port != 80:
2330 2334 ui.status(_('listening at http://%s:%d/\n') %
2331 2335 (httpd.addr, httpd.port))
2332 2336 else:
2333 2337 ui.status(_('listening at http://%s/\n') % httpd.addr)
2334 2338
2335 2339 if opts['pid_file']:
2336 2340 fp = open(opts['pid_file'], 'w')
2337 2341 fp.write(str(os.getpid()) + '\n')
2338 2342 fp.close()
2339 2343
2340 2344 if opts['daemon_pipefds']:
2341 2345 rfd, wfd = [int(x) for x in opts['daemon_pipefds'].split(',')]
2342 2346 os.close(rfd)
2343 2347 os.write(wfd, 'y')
2344 2348 os.close(wfd)
2345 2349 sys.stdout.flush()
2346 2350 sys.stderr.flush()
2347 2351 fd = os.open(util.nulldev, os.O_RDWR)
2348 2352 if fd != 0: os.dup2(fd, 0)
2349 2353 if fd != 1: os.dup2(fd, 1)
2350 2354 if fd != 2: os.dup2(fd, 2)
2351 2355 if fd not in (0, 1, 2): os.close(fd)
2352 2356
2353 2357 httpd.serve_forever()
2354 2358
2355 2359 def status(ui, repo, *pats, **opts):
2356 2360 """show changed files in the working directory
2357 2361
2358 2362 Show status of files in the repository. If names are given, only
2359 2363 files that match are shown. Files that are clean or ignored, are
2360 2364 not listed unless -c (clean), -i (ignored) or -A is given.
2361 2365
2362 2366 NOTE: status may appear to disagree with diff if permissions have
2363 2367 changed or a merge has occurred. The standard diff format does not
2364 2368 report permission changes and diff only reports changes relative
2365 2369 to one merge parent.
2366 2370
2367 2371 If one revision is given, it is used as the base revision.
2368 2372 If two revisions are given, the difference between them is shown.
2369 2373
2370 2374 The codes used to show the status of files are:
2371 2375 M = modified
2372 2376 A = added
2373 2377 R = removed
2374 2378 C = clean
2375 2379 ! = deleted, but still tracked
2376 2380 ? = not tracked
2377 2381 I = ignored (not shown by default)
2378 2382 = the previous added file was copied from here
2379 2383 """
2380 2384
2381 2385 all = opts['all']
2382 2386 node1, node2 = cmdutil.revpair(repo, opts.get('rev'))
2383 2387
2384 2388 files, matchfn, anypats = cmdutil.matchpats(repo, pats, opts)
2385 2389 cwd = (pats and repo.getcwd()) or ''
2386 2390 modified, added, removed, deleted, unknown, ignored, clean = [
2387 2391 n for n in repo.status(node1=node1, node2=node2, files=files,
2388 2392 match=matchfn,
2389 2393 list_ignored=all or opts['ignored'],
2390 2394 list_clean=all or opts['clean'])]
2391 2395
2392 2396 changetypes = (('modified', 'M', modified),
2393 2397 ('added', 'A', added),
2394 2398 ('removed', 'R', removed),
2395 2399 ('deleted', '!', deleted),
2396 2400 ('unknown', '?', unknown),
2397 2401 ('ignored', 'I', ignored))
2398 2402
2399 2403 explicit_changetypes = changetypes + (('clean', 'C', clean),)
2400 2404
2401 2405 end = opts['print0'] and '\0' or '\n'
2402 2406
2403 2407 for opt, char, changes in ([ct for ct in explicit_changetypes
2404 2408 if all or opts[ct[0]]]
2405 2409 or changetypes):
2406 2410 if opts['no_status']:
2407 2411 format = "%%s%s" % end
2408 2412 else:
2409 2413 format = "%s %%s%s" % (char, end)
2410 2414
2411 2415 for f in changes:
2412 2416 ui.write(format % util.pathto(cwd, f))
2413 2417 if ((all or opts.get('copies')) and not opts.get('no_status')):
2414 2418 copied = repo.dirstate.copied(f)
2415 2419 if copied:
2416 2420 ui.write(' %s%s' % (util.pathto(cwd, copied), end))
2417 2421
2418 2422 def tag(ui, repo, name, rev_=None, **opts):
2419 2423 """add a tag for the current or given revision
2420 2424
2421 2425 Name a particular revision using <name>.
2422 2426
2423 2427 Tags are used to name particular revisions of the repository and are
2424 2428 very useful to compare different revision, to go back to significant
2425 2429 earlier versions or to mark branch points as releases, etc.
2426 2430
2427 2431 If no revision is given, the parent of the working directory is used,
2428 2432 or tip if no revision is checked out.
2429 2433
2430 2434 To facilitate version control, distribution, and merging of tags,
2431 2435 they are stored as a file named ".hgtags" which is managed
2432 2436 similarly to other project files and can be hand-edited if
2433 2437 necessary. The file '.hg/localtags' is used for local tags (not
2434 2438 shared among repositories).
2435 2439 """
2436 2440 if name in ['tip', '.', 'null']:
2437 2441 raise util.Abort(_("the name '%s' is reserved") % name)
2438 2442 if rev_ is not None:
2439 2443 ui.warn(_("use of 'hg tag NAME [REV]' is deprecated, "
2440 2444 "please use 'hg tag [-r REV] NAME' instead\n"))
2441 2445 if opts['rev']:
2442 2446 raise util.Abort(_("use only one form to specify the revision"))
2443 2447 if opts['rev']:
2444 2448 rev_ = opts['rev']
2445 2449 if not rev_ and repo.dirstate.parents()[1] != nullid:
2446 2450 raise util.Abort(_('uncommitted merge - please provide a '
2447 2451 'specific revision'))
2448 2452 r = repo.changectx(rev_).node()
2449 2453
2450 2454 message = opts['message']
2451 2455 if not message:
2452 2456 message = _('Added tag %s for changeset %s') % (name, short(r))
2453 2457
2454 2458 repo.tag(name, r, message, opts['local'], opts['user'], opts['date'])
2455 2459
2456 2460 def tags(ui, repo):
2457 2461 """list repository tags
2458 2462
2459 2463 List the repository tags.
2460 2464
2461 2465 This lists both regular and local tags.
2462 2466 """
2463 2467
2464 2468 l = repo.tagslist()
2465 2469 l.reverse()
2466 2470 hexfunc = ui.debugflag and hex or short
2467 2471 for t, n in l:
2468 2472 try:
2469 2473 r = "%5d:%s" % (repo.changelog.rev(n), hexfunc(n))
2470 2474 except KeyError:
2471 2475 r = " ?:?"
2472 2476 if ui.quiet:
2473 2477 ui.write("%s\n" % t)
2474 2478 else:
2475 2479 spaces = " " * (30 - util.locallen(t))
2476 2480 ui.write("%s%s %s\n" % (t, spaces, r))
2477 2481
2478 2482 def tip(ui, repo, **opts):
2479 2483 """show the tip revision
2480 2484
2481 2485 Show the tip revision.
2482 2486 """
2483 2487 cmdutil.show_changeset(ui, repo, opts).show(nullrev+repo.changelog.count())
2484 2488
2485 2489 def unbundle(ui, repo, fname, **opts):
2486 2490 """apply a changegroup file
2487 2491
2488 2492 Apply a compressed changegroup file generated by the bundle
2489 2493 command.
2490 2494 """
2491 2495 if os.path.exists(fname):
2492 2496 f = open(fname, "rb")
2493 2497 else:
2494 2498 f = urllib.urlopen(fname)
2495 2499 gen = changegroup.readbundle(f, fname)
2496 2500 modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname)
2497 2501 return postincoming(ui, repo, modheads, opts['update'])
2498 2502
2499 2503 def update(ui, repo, node=None, clean=False, branch=None, date=None):
2500 2504 """update working directory
2501 2505
2502 2506 Update the working directory to the specified revision.
2503 2507
2504 2508 If there are no outstanding changes in the working directory and
2505 2509 there is a linear relationship between the current version and the
2506 2510 requested version, the result is the requested version.
2507 2511
2508 2512 To merge the working directory with another revision, use the
2509 2513 merge command.
2510 2514
2511 2515 By default, update will refuse to run if doing so would require
2512 2516 discarding local changes.
2513 2517 """
2514 2518 if date:
2515 2519 if node:
2516 2520 raise util.Abort(_("you can't specify a revision and a date"))
2517 2521 node = cmdutil.finddate(ui, repo, date)
2518 2522
2519 2523 node = _lookup(repo, node, branch)
2520 2524 if clean:
2521 2525 return hg.clean(repo, node)
2522 2526 else:
2523 2527 return hg.update(repo, node)
2524 2528
2525 2529 def _lookup(repo, node, branch=None):
2526 2530 if branch:
2527 2531 repo.ui.warn(_("the --branch option is deprecated, "
2528 2532 "please use 'hg branch' instead\n"))
2529 2533 br = repo.branchlookup(branch=branch)
2530 2534 found = []
2531 2535 for x in br:
2532 2536 if branch in br[x]:
2533 2537 found.append(x)
2534 2538 if len(found) > 1:
2535 2539 repo.ui.warn(_("Found multiple heads for %s\n") % branch)
2536 2540 for x in found:
2537 2541 cmdutil.show_changeset(ui, repo, {}).show(changenode=x)
2538 2542 raise util.Abort("")
2539 2543 if len(found) == 1:
2540 2544 node = found[0]
2541 2545 repo.ui.warn(_("Using head %s for branch %s\n")
2542 2546 % (short(node), branch))
2543 2547 else:
2544 2548 raise util.Abort(_("branch %s not found") % branch)
2545 2549 else:
2546 2550 if node:
2547 2551 node = repo.lookup(node)
2548 2552 else:
2549 2553 wc = repo.workingctx()
2550 2554 node = repo.branchtags()[wc.branch()]
2551 2555 return node
2552 2556
2553 2557 def verify(ui, repo):
2554 2558 """verify the integrity of the repository
2555 2559
2556 2560 Verify the integrity of the current repository.
2557 2561
2558 2562 This will perform an extensive check of the repository's
2559 2563 integrity, validating the hashes and checksums of each entry in
2560 2564 the changelog, manifest, and tracked files, as well as the
2561 2565 integrity of their crosslinks and indices.
2562 2566 """
2563 2567 return hg.verify(repo)
2564 2568
2565 2569 def version_(ui):
2566 2570 """output version and copyright information"""
2567 2571 ui.write(_("Mercurial Distributed SCM (version %s)\n")
2568 2572 % version.get_version())
2569 2573 ui.status(_(
2570 2574 "\nCopyright (C) 2005, 2006 Matt Mackall <mpm@selenic.com>\n"
2571 2575 "This is free software; see the source for copying conditions. "
2572 2576 "There is NO\nwarranty; "
2573 2577 "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
2574 2578 ))
2575 2579
2576 2580 # Command options and aliases are listed here, alphabetically
2577 2581
2578 2582 globalopts = [
2579 2583 ('R', 'repository', '',
2580 2584 _('repository root directory or symbolic path name')),
2581 2585 ('', 'cwd', '', _('change working directory')),
2582 2586 ('y', 'noninteractive', None,
2583 2587 _('do not prompt, assume \'yes\' for any required answers')),
2584 2588 ('q', 'quiet', None, _('suppress output')),
2585 2589 ('v', 'verbose', None, _('enable additional output')),
2586 2590 ('', 'config', [], _('set/override config option')),
2587 2591 ('', 'debug', None, _('enable debugging output')),
2588 2592 ('', 'debugger', None, _('start debugger')),
2589 2593 ('', 'encoding', util._encoding, _('set the charset encoding')),
2590 2594 ('', 'encodingmode', util._encodingmode, _('set the charset encoding mode')),
2591 2595 ('', 'lsprof', None, _('print improved command execution profile')),
2592 2596 ('', 'traceback', None, _('print traceback on exception')),
2593 2597 ('', 'time', None, _('time how long the command takes')),
2594 2598 ('', 'profile', None, _('print command execution profile')),
2595 2599 ('', 'version', None, _('output version information and exit')),
2596 2600 ('h', 'help', None, _('display help and exit')),
2597 2601 ]
2598 2602
2599 2603 dryrunopts = [('n', 'dry-run', None,
2600 2604 _('do not perform actions, just print output'))]
2601 2605
2602 2606 remoteopts = [
2603 2607 ('e', 'ssh', '', _('specify ssh command to use')),
2604 2608 ('', 'remotecmd', '', _('specify hg command to run on the remote side')),
2605 2609 ]
2606 2610
2607 2611 walkopts = [
2608 2612 ('I', 'include', [], _('include names matching the given patterns')),
2609 2613 ('X', 'exclude', [], _('exclude names matching the given patterns')),
2610 2614 ]
2611 2615
2612 2616 commitopts = [
2613 2617 ('m', 'message', '', _('use <text> as commit message')),
2614 2618 ('l', 'logfile', '', _('read commit message from <file>')),
2615 2619 ]
2616 2620
2617 2621 table = {
2618 2622 "^add": (add, walkopts + dryrunopts, _('hg add [OPTION]... [FILE]...')),
2619 2623 "addremove":
2620 2624 (addremove,
2621 2625 [('s', 'similarity', '',
2622 2626 _('guess renamed files by similarity (0<=s<=100)')),
2623 2627 ] + walkopts + dryrunopts,
2624 2628 _('hg addremove [OPTION]... [FILE]...')),
2625 2629 "^annotate":
2626 2630 (annotate,
2627 2631 [('r', 'rev', '', _('annotate the specified revision')),
2628 2632 ('f', 'follow', None, _('follow file copies and renames')),
2629 2633 ('a', 'text', None, _('treat all files as text')),
2630 2634 ('u', 'user', None, _('list the author')),
2631 2635 ('d', 'date', None, _('list the date')),
2632 2636 ('n', 'number', None, _('list the revision number (default)')),
2633 2637 ('c', 'changeset', None, _('list the changeset')),
2634 2638 ] + walkopts,
2635 2639 _('hg annotate [-r REV] [-f] [-a] [-u] [-d] [-n] [-c] FILE...')),
2636 2640 "archive":
2637 2641 (archive,
2638 2642 [('', 'no-decode', None, _('do not pass files through decoders')),
2639 2643 ('p', 'prefix', '', _('directory prefix for files in archive')),
2640 2644 ('r', 'rev', '', _('revision to distribute')),
2641 2645 ('t', 'type', '', _('type of distribution to create')),
2642 2646 ] + walkopts,
2643 2647 _('hg archive [OPTION]... DEST')),
2644 2648 "backout":
2645 2649 (backout,
2646 2650 [('', 'merge', None,
2647 2651 _('merge with old dirstate parent after backout')),
2648 2652 ('d', 'date', '', _('record datecode as commit date')),
2649 2653 ('', 'parent', '', _('parent to choose when backing out merge')),
2650 2654 ('u', 'user', '', _('record user as committer')),
2651 2655 ] + walkopts + commitopts,
2652 2656 _('hg backout [OPTION]... REV')),
2653 2657 "branch": (branch, [], _('hg branch [NAME]')),
2654 2658 "branches": (branches, [], _('hg branches')),
2655 2659 "bundle":
2656 2660 (bundle,
2657 2661 [('f', 'force', None,
2658 2662 _('run even when remote repository is unrelated')),
2659 2663 ('r', 'rev', [],
2660 2664 _('a changeset you would like to bundle')),
2661 2665 ('', 'base', [],
2662 2666 _('a base changeset to specify instead of a destination')),
2663 2667 ] + remoteopts,
2664 2668 _('hg bundle [-f] [-r REV]... [--base REV]... FILE [DEST]')),
2665 2669 "cat":
2666 2670 (cat,
2667 2671 [('o', 'output', '', _('print output to file with formatted name')),
2668 2672 ('r', 'rev', '', _('print the given revision')),
2669 2673 ] + walkopts,
2670 2674 _('hg cat [OPTION]... FILE...')),
2671 2675 "^clone":
2672 2676 (clone,
2673 2677 [('U', 'noupdate', None, _('do not update the new working directory')),
2674 2678 ('r', 'rev', [],
2675 2679 _('a changeset you would like to have after cloning')),
2676 2680 ('', 'pull', None, _('use pull protocol to copy metadata')),
2677 2681 ('', 'uncompressed', None,
2678 2682 _('use uncompressed transfer (fast over LAN)')),
2679 2683 ] + remoteopts,
2680 2684 _('hg clone [OPTION]... SOURCE [DEST]')),
2681 2685 "^commit|ci":
2682 2686 (commit,
2683 2687 [('A', 'addremove', None,
2684 2688 _('mark new/missing files as added/removed before committing')),
2685 2689 ('d', 'date', '', _('record datecode as commit date')),
2686 2690 ('u', 'user', '', _('record user as commiter')),
2687 2691 ] + walkopts + commitopts,
2688 2692 _('hg commit [OPTION]... [FILE]...')),
2689 2693 "copy|cp":
2690 2694 (copy,
2691 2695 [('A', 'after', None, _('record a copy that has already occurred')),
2692 2696 ('f', 'force', None,
2693 2697 _('forcibly copy over an existing managed file')),
2694 2698 ] + walkopts + dryrunopts,
2695 2699 _('hg copy [OPTION]... [SOURCE]... DEST')),
2696 2700 "debugancestor": (debugancestor, [], _('debugancestor INDEX REV1 REV2')),
2697 2701 "debugcomplete":
2698 2702 (debugcomplete,
2699 2703 [('o', 'options', None, _('show the command options'))],
2700 2704 _('debugcomplete [-o] CMD')),
2701 2705 "debuginstall": (debuginstall, [], _('debuginstall')),
2702 2706 "debugrebuildstate":
2703 2707 (debugrebuildstate,
2704 2708 [('r', 'rev', '', _('revision to rebuild to'))],
2705 2709 _('debugrebuildstate [-r REV] [REV]')),
2706 2710 "debugcheckstate": (debugcheckstate, [], _('debugcheckstate')),
2707 2711 "debugsetparents": (debugsetparents, [], _('debugsetparents REV1 [REV2]')),
2708 2712 "debugstate": (debugstate, [], _('debugstate')),
2709 2713 "debugdate":
2710 2714 (debugdate,
2711 2715 [('e', 'extended', None, _('try extended date formats'))],
2712 2716 _('debugdate [-e] DATE [RANGE]')),
2713 2717 "debugdata": (debugdata, [], _('debugdata FILE REV')),
2714 2718 "debugindex": (debugindex, [], _('debugindex FILE')),
2715 2719 "debugindexdot": (debugindexdot, [], _('debugindexdot FILE')),
2716 2720 "debugrename": (debugrename, [], _('debugrename FILE [REV]')),
2717 2721 "debugwalk": (debugwalk, walkopts, _('debugwalk [OPTION]... [FILE]...')),
2718 2722 "^diff":
2719 2723 (diff,
2720 2724 [('r', 'rev', [], _('revision')),
2721 2725 ('a', 'text', None, _('treat all files as text')),
2722 2726 ('p', 'show-function', None,
2723 2727 _('show which function each change is in')),
2724 2728 ('g', 'git', None, _('use git extended diff format')),
2725 2729 ('', 'nodates', None, _("don't include dates in diff headers")),
2726 2730 ('w', 'ignore-all-space', None,
2727 2731 _('ignore white space when comparing lines')),
2728 2732 ('b', 'ignore-space-change', None,
2729 2733 _('ignore changes in the amount of white space')),
2730 2734 ('B', 'ignore-blank-lines', None,
2731 2735 _('ignore changes whose lines are all blank')),
2732 2736 ] + walkopts,
2733 2737 _('hg diff [OPTION]... [-r REV1 [-r REV2]] [FILE]...')),
2734 2738 "^export":
2735 2739 (export,
2736 2740 [('o', 'output', '', _('print output to file with formatted name')),
2737 2741 ('a', 'text', None, _('treat all files as text')),
2738 2742 ('g', 'git', None, _('use git extended diff format')),
2739 2743 ('', 'nodates', None, _("don't include dates in diff headers")),
2740 2744 ('', 'switch-parent', None, _('diff against the second parent'))],
2741 2745 _('hg export [OPTION]... [-o OUTFILESPEC] REV...')),
2742 2746 "grep":
2743 2747 (grep,
2744 2748 [('0', 'print0', None, _('end fields with NUL')),
2745 2749 ('', 'all', None, _('print all revisions that match')),
2746 2750 ('f', 'follow', None,
2747 2751 _('follow changeset history, or file history across copies and renames')),
2748 2752 ('i', 'ignore-case', None, _('ignore case when matching')),
2749 2753 ('l', 'files-with-matches', None,
2750 2754 _('print only filenames and revs that match')),
2751 2755 ('n', 'line-number', None, _('print matching line numbers')),
2752 2756 ('r', 'rev', [], _('search in given revision range')),
2753 2757 ('u', 'user', None, _('print user who committed change')),
2754 2758 ] + walkopts,
2755 2759 _('hg grep [OPTION]... PATTERN [FILE]...')),
2756 2760 "heads":
2757 2761 (heads,
2758 2762 [('b', 'branches', None, _('show branches (DEPRECATED)')),
2759 2763 ('', 'style', '', _('display using template map file')),
2760 2764 ('r', 'rev', '', _('show only heads which are descendants of rev')),
2761 2765 ('', 'template', '', _('display with template'))],
2762 2766 _('hg heads [-r REV]')),
2763 2767 "help": (help_, [], _('hg help [COMMAND]')),
2764 2768 "identify|id": (identify, [], _('hg identify')),
2765 2769 "import|patch":
2766 2770 (import_,
2767 2771 [('p', 'strip', 1,
2768 2772 _('directory strip option for patch. This has the same\n'
2769 2773 'meaning as the corresponding patch option')),
2770 2774 ('b', 'base', '', _('base path (DEPRECATED)')),
2771 2775 ('f', 'force', None,
2772 2776 _('skip check for outstanding uncommitted changes'))] + commitopts,
2773 2777 _('hg import [-p NUM] [-m MESSAGE] [-f] PATCH...')),
2774 2778 "incoming|in": (incoming,
2775 2779 [('M', 'no-merges', None, _('do not show merges')),
2776 2780 ('f', 'force', None,
2777 2781 _('run even when remote repository is unrelated')),
2778 2782 ('', 'style', '', _('display using template map file')),
2779 2783 ('n', 'newest-first', None, _('show newest record first')),
2780 2784 ('', 'bundle', '', _('file to store the bundles into')),
2781 2785 ('p', 'patch', None, _('show patch')),
2782 2786 ('r', 'rev', [], _('a specific revision up to which you would like to pull')),
2783 2787 ('', 'template', '', _('display with template')),
2784 2788 ] + remoteopts,
2785 2789 _('hg incoming [-p] [-n] [-M] [-f] [-r REV]...'
2786 2790 ' [--bundle FILENAME] [SOURCE]')),
2787 2791 "^init":
2788 2792 (init,
2789 2793 remoteopts,
2790 2794 _('hg init [-e CMD] [--remotecmd CMD] [DEST]')),
2791 2795 "locate":
2792 2796 (locate,
2793 2797 [('r', 'rev', '', _('search the repository as it stood at rev')),
2794 2798 ('0', 'print0', None,
2795 2799 _('end filenames with NUL, for use with xargs')),
2796 2800 ('f', 'fullpath', None,
2797 2801 _('print complete paths from the filesystem root')),
2798 2802 ] + walkopts,
2799 2803 _('hg locate [OPTION]... [PATTERN]...')),
2800 2804 "^log|history":
2801 2805 (log,
2802 2806 [('b', 'branches', None, _('show branches (DEPRECATED)')),
2803 2807 ('f', 'follow', None,
2804 2808 _('follow changeset history, or file history across copies and renames')),
2805 2809 ('', 'follow-first', None,
2806 2810 _('only follow the first parent of merge changesets')),
2807 2811 ('d', 'date', '', _('show revs matching date spec')),
2808 2812 ('C', 'copies', None, _('show copied files')),
2809 2813 ('k', 'keyword', [], _('search for a keyword')),
2810 2814 ('l', 'limit', '', _('limit number of changes displayed')),
2811 2815 ('r', 'rev', [], _('show the specified revision or range')),
2812 2816 ('', 'removed', None, _('include revs where files were removed')),
2813 2817 ('M', 'no-merges', None, _('do not show merges')),
2814 2818 ('', 'style', '', _('display using template map file')),
2815 2819 ('m', 'only-merges', None, _('show only merges')),
2816 2820 ('p', 'patch', None, _('show patch')),
2817 2821 ('P', 'prune', [], _('do not display revision or any of its ancestors')),
2818 2822 ('', 'template', '', _('display with template')),
2819 2823 ] + walkopts,
2820 2824 _('hg log [OPTION]... [FILE]')),
2821 2825 "manifest": (manifest, [], _('hg manifest [REV]')),
2822 2826 "^merge":
2823 2827 (merge,
2824 2828 [('b', 'branch', '', _('merge with head of a specific branch (DEPRECATED)')),
2825 2829 ('f', 'force', None, _('force a merge with outstanding changes'))],
2826 2830 _('hg merge [-f] [REV]')),
2827 2831 "outgoing|out": (outgoing,
2828 2832 [('M', 'no-merges', None, _('do not show merges')),
2829 2833 ('f', 'force', None,
2830 2834 _('run even when remote repository is unrelated')),
2831 2835 ('p', 'patch', None, _('show patch')),
2832 2836 ('', 'style', '', _('display using template map file')),
2833 2837 ('r', 'rev', [], _('a specific revision you would like to push')),
2834 2838 ('n', 'newest-first', None, _('show newest record first')),
2835 2839 ('', 'template', '', _('display with template')),
2836 2840 ] + remoteopts,
2837 2841 _('hg outgoing [-M] [-p] [-n] [-f] [-r REV]... [DEST]')),
2838 2842 "^parents":
2839 2843 (parents,
2840 2844 [('b', 'branches', None, _('show branches (DEPRECATED)')),
2841 2845 ('r', 'rev', '', _('show parents from the specified rev')),
2842 2846 ('', 'style', '', _('display using template map file')),
2843 2847 ('', 'template', '', _('display with template'))],
2844 2848 _('hg parents [-r REV] [FILE]')),
2845 2849 "paths": (paths, [], _('hg paths [NAME]')),
2846 2850 "^pull":
2847 2851 (pull,
2848 2852 [('u', 'update', None,
2849 2853 _('update to new tip if changesets were pulled')),
2850 2854 ('f', 'force', None,
2851 2855 _('run even when remote repository is unrelated')),
2852 2856 ('r', 'rev', [],
2853 2857 _('a specific revision up to which you would like to pull')),
2854 2858 ] + remoteopts,
2855 2859 _('hg pull [-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]')),
2856 2860 "^push":
2857 2861 (push,
2858 2862 [('f', 'force', None, _('force push')),
2859 2863 ('r', 'rev', [], _('a specific revision you would like to push')),
2860 2864 ] + remoteopts,
2861 2865 _('hg push [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]')),
2862 2866 "debugrawcommit|rawcommit":
2863 2867 (rawcommit,
2864 2868 [('p', 'parent', [], _('parent')),
2865 2869 ('d', 'date', '', _('date code')),
2866 2870 ('u', 'user', '', _('user')),
2867 2871 ('F', 'files', '', _('file list'))
2868 2872 ] + commitopts,
2869 2873 _('hg debugrawcommit [OPTION]... [FILE]...')),
2870 2874 "recover": (recover, [], _('hg recover')),
2871 2875 "^remove|rm":
2872 2876 (remove,
2873 2877 [('A', 'after', None, _('record remove that has already occurred')),
2874 2878 ('f', 'force', None, _('remove file even if modified')),
2875 2879 ] + walkopts,
2876 2880 _('hg remove [OPTION]... FILE...')),
2877 2881 "rename|mv":
2878 2882 (rename,
2879 2883 [('A', 'after', None, _('record a rename that has already occurred')),
2880 2884 ('f', 'force', None,
2881 2885 _('forcibly copy over an existing managed file')),
2882 2886 ] + walkopts + dryrunopts,
2883 2887 _('hg rename [OPTION]... SOURCE... DEST')),
2884 2888 "^revert":
2885 2889 (revert,
2886 2890 [('a', 'all', None, _('revert all changes when no arguments given')),
2887 2891 ('d', 'date', '', _('tipmost revision matching date')),
2888 2892 ('r', 'rev', '', _('revision to revert to')),
2889 2893 ('', 'no-backup', None, _('do not save backup copies of files')),
2890 2894 ] + walkopts + dryrunopts,
2891 2895 _('hg revert [OPTION]... [-r REV] [NAME]...')),
2892 2896 "rollback": (rollback, [], _('hg rollback')),
2893 2897 "root": (root, [], _('hg root')),
2894 2898 "showconfig|debugconfig":
2895 2899 (showconfig,
2896 2900 [('u', 'untrusted', None, _('show untrusted configuration options'))],
2897 2901 _('showconfig [-u] [NAME]...')),
2898 2902 "^serve":
2899 2903 (serve,
2900 2904 [('A', 'accesslog', '', _('name of access log file to write to')),
2901 2905 ('d', 'daemon', None, _('run server in background')),
2902 2906 ('', 'daemon-pipefds', '', _('used internally by daemon mode')),
2903 2907 ('E', 'errorlog', '', _('name of error log file to write to')),
2904 2908 ('p', 'port', 0, _('port to use (default: 8000)')),
2905 2909 ('a', 'address', '', _('address to use')),
2906 2910 ('n', 'name', '',
2907 2911 _('name to show in web pages (default: working dir)')),
2908 2912 ('', 'webdir-conf', '', _('name of the webdir config file'
2909 2913 ' (serve more than one repo)')),
2910 2914 ('', 'pid-file', '', _('name of file to write process ID to')),
2911 2915 ('', 'stdio', None, _('for remote clients')),
2912 2916 ('t', 'templates', '', _('web templates to use')),
2913 2917 ('', 'style', '', _('template style to use')),
2914 2918 ('6', 'ipv6', None, _('use IPv6 in addition to IPv4'))],
2915 2919 _('hg serve [OPTION]...')),
2916 2920 "^status|st":
2917 2921 (status,
2918 2922 [('A', 'all', None, _('show status of all files')),
2919 2923 ('m', 'modified', None, _('show only modified files')),
2920 2924 ('a', 'added', None, _('show only added files')),
2921 2925 ('r', 'removed', None, _('show only removed files')),
2922 2926 ('d', 'deleted', None, _('show only deleted (but tracked) files')),
2923 2927 ('c', 'clean', None, _('show only files without changes')),
2924 2928 ('u', 'unknown', None, _('show only unknown (not tracked) files')),
2925 2929 ('i', 'ignored', None, _('show only ignored files')),
2926 2930 ('n', 'no-status', None, _('hide status prefix')),
2927 2931 ('C', 'copies', None, _('show source of copied files')),
2928 2932 ('0', 'print0', None,
2929 2933 _('end filenames with NUL, for use with xargs')),
2930 2934 ('', 'rev', [], _('show difference from revision')),
2931 2935 ] + walkopts,
2932 2936 _('hg status [OPTION]... [FILE]...')),
2933 2937 "tag":
2934 2938 (tag,
2935 2939 [('l', 'local', None, _('make the tag local')),
2936 2940 ('m', 'message', '', _('message for tag commit log entry')),
2937 2941 ('d', 'date', '', _('record datecode as commit date')),
2938 2942 ('u', 'user', '', _('record user as commiter')),
2939 2943 ('r', 'rev', '', _('revision to tag'))],
2940 2944 _('hg tag [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME')),
2941 2945 "tags": (tags, [], _('hg tags')),
2942 2946 "tip":
2943 2947 (tip,
2944 2948 [('b', 'branches', None, _('show branches (DEPRECATED)')),
2945 2949 ('', 'style', '', _('display using template map file')),
2946 2950 ('p', 'patch', None, _('show patch')),
2947 2951 ('', 'template', '', _('display with template'))],
2948 2952 _('hg tip [-p]')),
2949 2953 "unbundle":
2950 2954 (unbundle,
2951 2955 [('u', 'update', None,
2952 2956 _('update to new tip if changesets were unbundled'))],
2953 2957 _('hg unbundle [-u] FILE')),
2954 2958 "^update|up|checkout|co":
2955 2959 (update,
2956 2960 [('b', 'branch', '',
2957 2961 _('checkout the head of a specific branch (DEPRECATED)')),
2958 2962 ('C', 'clean', None, _('overwrite locally modified files')),
2959 2963 ('d', 'date', '', _('tipmost revision matching date'))],
2960 2964 _('hg update [-C] [-d DATE] [REV]')),
2961 2965 "verify": (verify, [], _('hg verify')),
2962 2966 "version": (version_, [], _('hg version')),
2963 2967 }
2964 2968
2965 2969 norepo = ("clone init version help debugancestor debugcomplete debugdata"
2966 2970 " debugindex debugindexdot debugdate debuginstall")
2967 2971 optionalrepo = ("paths serve showconfig")
2968 2972
2969 2973 def findpossible(ui, cmd):
2970 2974 """
2971 2975 Return cmd -> (aliases, command table entry)
2972 2976 for each matching command.
2973 2977 Return debug commands (or their aliases) only if no normal command matches.
2974 2978 """
2975 2979 choice = {}
2976 2980 debugchoice = {}
2977 2981 for e in table.keys():
2978 2982 aliases = e.lstrip("^").split("|")
2979 2983 found = None
2980 2984 if cmd in aliases:
2981 2985 found = cmd
2982 2986 elif not ui.config("ui", "strict"):
2983 2987 for a in aliases:
2984 2988 if a.startswith(cmd):
2985 2989 found = a
2986 2990 break
2987 2991 if found is not None:
2988 2992 if aliases[0].startswith("debug") or found.startswith("debug"):
2989 2993 debugchoice[found] = (aliases, table[e])
2990 2994 else:
2991 2995 choice[found] = (aliases, table[e])
2992 2996
2993 2997 if not choice and debugchoice:
2994 2998 choice = debugchoice
2995 2999
2996 3000 return choice
2997 3001
2998 3002 def findcmd(ui, cmd):
2999 3003 """Return (aliases, command table entry) for command string."""
3000 3004 choice = findpossible(ui, cmd)
3001 3005
3002 3006 if choice.has_key(cmd):
3003 3007 return choice[cmd]
3004 3008
3005 3009 if len(choice) > 1:
3006 3010 clist = choice.keys()
3007 3011 clist.sort()
3008 3012 raise AmbiguousCommand(cmd, clist)
3009 3013
3010 3014 if choice:
3011 3015 return choice.values()[0]
3012 3016
3013 3017 raise UnknownCommand(cmd)
3014 3018
3015 3019 def catchterm(*args):
3016 3020 raise util.SignalInterrupt
3017 3021
3018 3022 def run():
3019 3023 sys.exit(dispatch(sys.argv[1:]))
3020 3024
3021 3025 class ParseError(Exception):
3022 3026 """Exception raised on errors in parsing the command line."""
3023 3027
3024 3028 def parse(ui, args):
3025 3029 options = {}
3026 3030 cmdoptions = {}
3027 3031
3028 3032 try:
3029 3033 args = fancyopts.fancyopts(args, globalopts, options)
3030 3034 except fancyopts.getopt.GetoptError, inst:
3031 3035 raise ParseError(None, inst)
3032 3036
3033 3037 if args:
3034 3038 cmd, args = args[0], args[1:]
3035 3039 aliases, i = findcmd(ui, cmd)
3036 3040 cmd = aliases[0]
3037 3041 defaults = ui.config("defaults", cmd)
3038 3042 if defaults:
3039 3043 args = shlex.split(defaults) + args
3040 3044 c = list(i[1])
3041 3045 else:
3042 3046 cmd = None
3043 3047 c = []
3044 3048
3045 3049 # combine global options into local
3046 3050 for o in globalopts:
3047 3051 c.append((o[0], o[1], options[o[1]], o[3]))
3048 3052
3049 3053 try:
3050 3054 args = fancyopts.fancyopts(args, c, cmdoptions)
3051 3055 except fancyopts.getopt.GetoptError, inst:
3052 3056 raise ParseError(cmd, inst)
3053 3057
3054 3058 # separate global options back out
3055 3059 for o in globalopts:
3056 3060 n = o[1]
3057 3061 options[n] = cmdoptions[n]
3058 3062 del cmdoptions[n]
3059 3063
3060 3064 return (cmd, cmd and i[0] or None, args, options, cmdoptions)
3061 3065
3062 3066 external = {}
3063 3067
3064 3068 def findext(name):
3065 3069 '''return module with given extension name'''
3066 3070 try:
3067 3071 return sys.modules[external[name]]
3068 3072 except KeyError:
3069 3073 for k, v in external.iteritems():
3070 3074 if k.endswith('.' + name) or k.endswith('/' + name) or v == name:
3071 3075 return sys.modules[v]
3072 3076 raise KeyError(name)
3073 3077
3074 3078 def load_extensions(ui):
3075 3079 added = []
3076 3080 for ext_name, load_from_name in ui.extensions():
3077 3081 if ext_name in external:
3078 3082 continue
3079 3083 try:
3080 3084 if load_from_name:
3081 3085 # the module will be loaded in sys.modules
3082 3086 # choose an unique name so that it doesn't
3083 3087 # conflicts with other modules
3084 3088 module_name = "hgext_%s" % ext_name.replace('.', '_')
3085 3089 mod = imp.load_source(module_name, load_from_name)
3086 3090 else:
3087 3091 def importh(name):
3088 3092 mod = __import__(name)
3089 3093 components = name.split('.')
3090 3094 for comp in components[1:]:
3091 3095 mod = getattr(mod, comp)
3092 3096 return mod
3093 3097 try:
3094 3098 mod = importh("hgext.%s" % ext_name)
3095 3099 except ImportError:
3096 3100 mod = importh(ext_name)
3097 3101 external[ext_name] = mod.__name__
3098 3102 added.append((mod, ext_name))
3099 3103 except (util.SignalInterrupt, KeyboardInterrupt):
3100 3104 raise
3101 3105 except Exception, inst:
3102 3106 ui.warn(_("*** failed to import extension %s: %s\n") %
3103 3107 (ext_name, inst))
3104 3108 if ui.print_exc():
3105 3109 return 1
3106 3110
3107 3111 for mod, name in added:
3108 3112 uisetup = getattr(mod, 'uisetup', None)
3109 3113 if uisetup:
3110 3114 uisetup(ui)
3111 3115 reposetup = getattr(mod, 'reposetup', None)
3112 3116 if reposetup:
3113 3117 hg.repo_setup_hooks.append(reposetup)
3114 3118 cmdtable = getattr(mod, 'cmdtable', {})
3115 3119 for t in cmdtable:
3116 3120 if t in table:
3117 3121 ui.warn(_("module %s overrides %s\n") % (name, t))
3118 3122 table.update(cmdtable)
3119 3123
3120 3124 def parseconfig(config):
3121 3125 """parse the --config options from the command line"""
3122 3126 parsed = []
3123 3127 for cfg in config:
3124 3128 try:
3125 3129 name, value = cfg.split('=', 1)
3126 3130 section, name = name.split('.', 1)
3127 3131 if not section or not name:
3128 3132 raise IndexError
3129 3133 parsed.append((section, name, value))
3130 3134 except (IndexError, ValueError):
3131 3135 raise util.Abort(_('malformed --config option: %s') % cfg)
3132 3136 return parsed
3133 3137
3134 3138 def dispatch(args):
3135 3139 for name in 'SIGBREAK', 'SIGHUP', 'SIGTERM':
3136 3140 num = getattr(signal, name, None)
3137 3141 if num: signal.signal(num, catchterm)
3138 3142
3139 3143 try:
3140 3144 u = ui.ui(traceback='--traceback' in sys.argv[1:])
3141 3145 except util.Abort, inst:
3142 3146 sys.stderr.write(_("abort: %s\n") % inst)
3143 3147 return -1
3144 3148
3145 3149 load_extensions(u)
3146 3150 u.addreadhook(load_extensions)
3147 3151
3148 3152 try:
3149 3153 cmd, func, args, options, cmdoptions = parse(u, args)
3150 3154 if options["encoding"]:
3151 3155 util._encoding = options["encoding"]
3152 3156 if options["encodingmode"]:
3153 3157 util._encodingmode = options["encodingmode"]
3154 3158 if options["time"]:
3155 3159 def get_times():
3156 3160 t = os.times()
3157 3161 if t[4] == 0.0: # Windows leaves this as zero, so use time.clock()
3158 3162 t = (t[0], t[1], t[2], t[3], time.clock())
3159 3163 return t
3160 3164 s = get_times()
3161 3165 def print_time():
3162 3166 t = get_times()
3163 3167 u.warn(_("Time: real %.3f secs (user %.3f+%.3f sys %.3f+%.3f)\n") %
3164 3168 (t[4]-s[4], t[0]-s[0], t[2]-s[2], t[1]-s[1], t[3]-s[3]))
3165 3169 atexit.register(print_time)
3166 3170
3167 3171 # enter the debugger before command execution
3168 3172 if options['debugger']:
3169 3173 pdb.set_trace()
3170 3174
3171 3175 try:
3172 3176 if options['cwd']:
3173 3177 os.chdir(options['cwd'])
3174 3178
3175 3179 u.updateopts(options["verbose"], options["debug"], options["quiet"],
3176 3180 not options["noninteractive"], options["traceback"],
3177 3181 parseconfig(options["config"]))
3178 3182
3179 3183 path = u.expandpath(options["repository"]) or ""
3180 3184 repo = path and hg.repository(u, path=path) or None
3181 3185 if repo and not repo.local():
3182 3186 raise util.Abort(_("repository '%s' is not local") % path)
3183 3187
3184 3188 if options['help']:
3185 3189 return help_(u, cmd, options['version'])
3186 3190 elif options['version']:
3187 3191 return version_(u)
3188 3192 elif not cmd:
3189 3193 return help_(u, 'shortlist')
3190 3194
3191 3195 if cmd not in norepo.split():
3192 3196 try:
3193 3197 if not repo:
3194 3198 repo = hg.repository(u, path=path)
3195 3199 u = repo.ui
3196 3200 except hg.RepoError:
3197 3201 if cmd not in optionalrepo.split():
3198 3202 raise
3199 3203 d = lambda: func(u, repo, *args, **cmdoptions)
3200 3204 else:
3201 3205 d = lambda: func(u, *args, **cmdoptions)
3202 3206
3203 3207 try:
3204 3208 if options['profile']:
3205 3209 import hotshot, hotshot.stats
3206 3210 prof = hotshot.Profile("hg.prof")
3207 3211 try:
3208 3212 try:
3209 3213 return prof.runcall(d)
3210 3214 except:
3211 3215 try:
3212 3216 u.warn(_('exception raised - generating '
3213 3217 'profile anyway\n'))
3214 3218 except:
3215 3219 pass
3216 3220 raise
3217 3221 finally:
3218 3222 prof.close()
3219 3223 stats = hotshot.stats.load("hg.prof")
3220 3224 stats.strip_dirs()
3221 3225 stats.sort_stats('time', 'calls')
3222 3226 stats.print_stats(40)
3223 3227 elif options['lsprof']:
3224 3228 try:
3225 3229 from mercurial import lsprof
3226 3230 except ImportError:
3227 3231 raise util.Abort(_(
3228 3232 'lsprof not available - install from '
3229 3233 'http://codespeak.net/svn/user/arigo/hack/misc/lsprof/'))
3230 3234 p = lsprof.Profiler()
3231 3235 p.enable(subcalls=True)
3232 3236 try:
3233 3237 return d()
3234 3238 finally:
3235 3239 p.disable()
3236 3240 stats = lsprof.Stats(p.getstats())
3237 3241 stats.sort()
3238 3242 stats.pprint(top=10, file=sys.stderr, climit=5)
3239 3243 else:
3240 3244 return d()
3241 3245 finally:
3242 3246 u.flush()
3243 3247 except:
3244 3248 # enter the debugger when we hit an exception
3245 3249 if options['debugger']:
3246 3250 pdb.post_mortem(sys.exc_info()[2])
3247 3251 u.print_exc()
3248 3252 raise
3249 3253 except ParseError, inst:
3250 3254 if inst.args[0]:
3251 3255 u.warn(_("hg %s: %s\n") % (inst.args[0], inst.args[1]))
3252 3256 help_(u, inst.args[0])
3253 3257 else:
3254 3258 u.warn(_("hg: %s\n") % inst.args[1])
3255 3259 help_(u, 'shortlist')
3256 3260 except AmbiguousCommand, inst:
3257 3261 u.warn(_("hg: command '%s' is ambiguous:\n %s\n") %
3258 3262 (inst.args[0], " ".join(inst.args[1])))
3259 3263 except UnknownCommand, inst:
3260 3264 u.warn(_("hg: unknown command '%s'\n") % inst.args[0])
3261 3265 help_(u, 'shortlist')
3262 3266 except hg.RepoError, inst:
3263 3267 u.warn(_("abort: %s!\n") % inst)
3264 3268 except lock.LockHeld, inst:
3265 3269 if inst.errno == errno.ETIMEDOUT:
3266 3270 reason = _('timed out waiting for lock held by %s') % inst.locker
3267 3271 else:
3268 3272 reason = _('lock held by %s') % inst.locker
3269 3273 u.warn(_("abort: %s: %s\n") % (inst.desc or inst.filename, reason))
3270 3274 except lock.LockUnavailable, inst:
3271 3275 u.warn(_("abort: could not lock %s: %s\n") %
3272 3276 (inst.desc or inst.filename, inst.strerror))
3273 3277 except revlog.RevlogError, inst:
3274 3278 u.warn(_("abort: %s!\n") % inst)
3275 3279 except util.SignalInterrupt:
3276 3280 u.warn(_("killed!\n"))
3277 3281 except KeyboardInterrupt:
3278 3282 try:
3279 3283 u.warn(_("interrupted!\n"))
3280 3284 except IOError, inst:
3281 3285 if inst.errno == errno.EPIPE:
3282 3286 if u.debugflag:
3283 3287 u.warn(_("\nbroken pipe\n"))
3284 3288 else:
3285 3289 raise
3286 3290 except socket.error, inst:
3287 3291 u.warn(_("abort: %s\n") % inst[1])
3288 3292 except IOError, inst:
3289 3293 if hasattr(inst, "code"):
3290 3294 u.warn(_("abort: %s\n") % inst)
3291 3295 elif hasattr(inst, "reason"):
3292 3296 try: # usually it is in the form (errno, strerror)
3293 3297 reason = inst.reason.args[1]
3294 3298 except: # it might be anything, for example a string
3295 3299 reason = inst.reason
3296 3300 u.warn(_("abort: error: %s\n") % reason)
3297 3301 elif hasattr(inst, "args") and inst[0] == errno.EPIPE:
3298 3302 if u.debugflag:
3299 3303 u.warn(_("broken pipe\n"))
3300 3304 elif getattr(inst, "strerror", None):
3301 3305 if getattr(inst, "filename", None):
3302 3306 u.warn(_("abort: %s: %s\n") % (inst.strerror, inst.filename))
3303 3307 else:
3304 3308 u.warn(_("abort: %s\n") % inst.strerror)
3305 3309 else:
3306 3310 raise
3307 3311 except OSError, inst:
3308 3312 if getattr(inst, "filename", None):
3309 3313 u.warn(_("abort: %s: %s\n") % (inst.strerror, inst.filename))
3310 3314 else:
3311 3315 u.warn(_("abort: %s\n") % inst.strerror)
3312 3316 except util.UnexpectedOutput, inst:
3313 3317 u.warn(_("abort: %s") % inst[0])
3314 3318 if not isinstance(inst[1], basestring):
3315 3319 u.warn(" %r\n" % (inst[1],))
3316 3320 elif not inst[1]:
3317 3321 u.warn(_(" empty string\n"))
3318 3322 else:
3319 3323 u.warn("\n%r\n" % util.ellipsis(inst[1]))
3320 3324 except util.Abort, inst:
3321 3325 u.warn(_("abort: %s\n") % inst)
3322 3326 except TypeError, inst:
3323 3327 # was this an argument error?
3324 3328 tb = traceback.extract_tb(sys.exc_info()[2])
3325 3329 if len(tb) > 2: # no
3326 3330 raise
3327 3331 u.debug(inst, "\n")
3328 3332 u.warn(_("%s: invalid arguments\n") % cmd)
3329 3333 help_(u, cmd)
3330 3334 except SystemExit, inst:
3331 3335 # Commands shouldn't sys.exit directly, but give a return code.
3332 3336 # Just in case catch this and and pass exit code to caller.
3333 3337 return inst.code
3334 3338 except:
3335 3339 u.warn(_("** unknown exception encountered, details follow\n"))
3336 3340 u.warn(_("** report bug details to "
3337 3341 "http://www.selenic.com/mercurial/bts\n"))
3338 3342 u.warn(_("** or mercurial@selenic.com\n"))
3339 3343 u.warn(_("** Mercurial Distributed SCM (version %s)\n")
3340 3344 % version.get_version())
3341 3345 raise
3342 3346
3343 3347 return -1
@@ -1,31 +1,31 b''
1 1 #!/bin/sh
2 2 #
3 3 mkdir t
4 4 cd t
5 5 hg init
6 6 echo 0 > a
7 7 echo 0 > b
8 8 echo 0 > t.h
9 9 mkdir t
10 10 echo 0 > t/x
11 11 hg ci -A -m m -d "1000000 0"
12 12 touch nottracked
13 hg locate a
14 hg locate NONEXISTENT
13 hg locate a && echo locate succeeded || echo locate failed
14 hg locate NONEXISTENT && echo locate succeeded || echo locate failed
15 15 hg locate
16 16 hg rm a
17 17 hg ci -m m -d "1000000 0"
18 18 hg locate a
19 19 hg locate NONEXISTENT
20 20 hg locate
21 21 hg locate -r 0 a
22 22 hg locate -r 0 NONEXISTENT
23 23 hg locate -r 0
24 24 echo % -I/-X with relative path should work
25 25 cd t
26 26 hg locate
27 27 hg locate -I ../t
28 28 # test issue294
29 29 cd ..
30 30 rm -r t
31 31 hg locate t
@@ -1,23 +1,25 b''
1 1 adding a
2 2 adding b
3 3 adding t.h
4 4 adding t/x
5 5 a
6 locate succeeded
7 locate failed
6 8 a
7 9 b
8 10 t.h
9 11 t/x
10 12 b
11 13 t.h
12 14 t/x
13 15 a
14 16 a
15 17 b
16 18 t.h
17 19 t/x
18 20 % -I/-X with relative path should work
19 21 b
20 22 t.h
21 23 t/x
22 24 t/x
23 25 t/x
General Comments 0
You need to be logged in to leave comments. Login now