324 def _debugbundle2(ui, gen, all=None, **opts): |
324 def _debugbundle2(ui, gen, all=None, **opts): |
325 """lists the contents of a bundle2""" |
325 """lists the contents of a bundle2""" |
326 if not isinstance(gen, bundle2.unbundle20): |
326 if not isinstance(gen, bundle2.unbundle20): |
327 raise error.Abort(_('not a bundle2 file')) |
327 raise error.Abort(_('not a bundle2 file')) |
328 ui.write(('Stream params: %s\n' % repr(gen.params))) |
328 ui.write(('Stream params: %s\n' % repr(gen.params))) |
329 parttypes = opts.get('part_type', []) |
329 parttypes = opts.get(r'part_type', []) |
330 for part in gen.iterparts(): |
330 for part in gen.iterparts(): |
331 if parttypes and part.type not in parttypes: |
331 if parttypes and part.type not in parttypes: |
332 continue |
332 continue |
333 ui.write('%s -- %r\n' % (part.type, repr(part.params))) |
333 ui.write('%s -- %r\n' % (part.type, repr(part.params))) |
334 if part.type == 'changegroup': |
334 if part.type == 'changegroup': |
391 [('', 'style', None, _('show all configured styles'))], |
391 [('', 'style', None, _('show all configured styles'))], |
392 'hg debugcolor') |
392 'hg debugcolor') |
393 def debugcolor(ui, repo, **opts): |
393 def debugcolor(ui, repo, **opts): |
394 """show available color, effects or style""" |
394 """show available color, effects or style""" |
395 ui.write(('color mode: %s\n') % ui._colormode) |
395 ui.write(('color mode: %s\n') % ui._colormode) |
396 if opts.get('style'): |
396 if opts.get(r'style'): |
397 return _debugdisplaystyle(ui) |
397 return _debugdisplaystyle(ui) |
398 else: |
398 else: |
399 return _debugdisplaycolor(ui) |
399 return _debugdisplaycolor(ui) |
400 |
400 |
401 def _debugdisplaycolor(ui): |
401 def _debugdisplaycolor(ui): |
459 If you pass a revlog index, the revlog's DAG is emitted. If you list |
459 If you pass a revlog index, the revlog's DAG is emitted. If you list |
460 revision numbers, they get labeled in the output as rN. |
460 revision numbers, they get labeled in the output as rN. |
461 |
461 |
462 Otherwise, the changelog DAG of the current repo is emitted. |
462 Otherwise, the changelog DAG of the current repo is emitted. |
463 """ |
463 """ |
464 spaces = opts.get('spaces') |
464 spaces = opts.get(r'spaces') |
465 dots = opts.get('dots') |
465 dots = opts.get(r'dots') |
466 if file_: |
466 if file_: |
467 rlog = revlog.revlog(vfsmod.vfs(pycompat.getcwd(), audit=False), |
467 rlog = revlog.revlog(vfsmod.vfs(pycompat.getcwd(), audit=False), |
468 file_) |
468 file_) |
469 revs = set((int(r) for r in revs)) |
469 revs = set((int(r) for r in revs)) |
470 def events(): |
470 def events(): |
473 if p != -1)) |
473 if p != -1)) |
474 if r in revs: |
474 if r in revs: |
475 yield 'l', (r, "r%i" % r) |
475 yield 'l', (r, "r%i" % r) |
476 elif repo: |
476 elif repo: |
477 cl = repo.changelog |
477 cl = repo.changelog |
478 tags = opts.get('tags') |
478 tags = opts.get(r'tags') |
479 branches = opts.get('branches') |
479 branches = opts.get(r'branches') |
480 if tags: |
480 if tags: |
481 labels = {} |
481 labels = {} |
482 for l, n in repo.tags().items(): |
482 for l, n in repo.tags().items(): |
483 labels.setdefault(cl.rev(n), []).append(l) |
483 labels.setdefault(cl.rev(n), []).append(l) |
484 def events(): |
484 def events(): |
529 [('e', 'extended', None, _('try extended date formats'))], |
529 [('e', 'extended', None, _('try extended date formats'))], |
530 _('[-e] DATE [RANGE]'), |
530 _('[-e] DATE [RANGE]'), |
531 norepo=True, optionalrepo=True) |
531 norepo=True, optionalrepo=True) |
532 def debugdate(ui, date, range=None, **opts): |
532 def debugdate(ui, date, range=None, **opts): |
533 """parse and display a date""" |
533 """parse and display a date""" |
534 if opts["extended"]: |
534 if opts[r"extended"]: |
535 d = util.parsedate(date, util.extendeddateformats) |
535 d = util.parsedate(date, util.extendeddateformats) |
536 else: |
536 else: |
537 d = util.parsedate(date) |
537 d = util.parsedate(date) |
538 ui.write(("internal: %s %s\n") % d) |
538 ui.write(("internal: %s %s\n") % d) |
539 ui.write(("standard: %s\n") % util.datestr(d)) |
539 ui.write(("standard: %s\n") % util.datestr(d)) |
648 ('', 'datesort', None, _('sort by saved mtime'))], |
648 ('', 'datesort', None, _('sort by saved mtime'))], |
649 _('[OPTION]...')) |
649 _('[OPTION]...')) |
650 def debugstate(ui, repo, **opts): |
650 def debugstate(ui, repo, **opts): |
651 """show the contents of the current dirstate""" |
651 """show the contents of the current dirstate""" |
652 |
652 |
653 nodates = opts.get('nodates') |
653 nodates = opts.get(r'nodates') |
654 datesort = opts.get('datesort') |
654 datesort = opts.get(r'datesort') |
655 |
655 |
656 timestr = "" |
656 timestr = "" |
657 if datesort: |
657 if datesort: |
658 keyfunc = lambda x: (x[1][3], x[0]) # sort by mtime, then by filename |
658 keyfunc = lambda x: (x[1][3], x[0]) # sort by mtime, then by filename |
659 else: |
659 else: |
790 @command('debugfileset', |
790 @command('debugfileset', |
791 [('r', 'rev', '', _('apply the filespec on this revision'), _('REV'))], |
791 [('r', 'rev', '', _('apply the filespec on this revision'), _('REV'))], |
792 _('[-r REV] FILESPEC')) |
792 _('[-r REV] FILESPEC')) |
793 def debugfileset(ui, repo, expr, **opts): |
793 def debugfileset(ui, repo, expr, **opts): |
794 '''parse and apply a fileset specification''' |
794 '''parse and apply a fileset specification''' |
795 ctx = scmutil.revsingle(repo, opts.get('rev'), None) |
795 ctx = scmutil.revsingle(repo, opts.get(r'rev'), None) |
796 if ui.verbose: |
796 if ui.verbose: |
797 tree = fileset.parse(expr) |
797 tree = fileset.parse(expr) |
798 ui.note(fileset.prettyformat(tree), "\n") |
798 ui.note(fileset.prettyformat(tree), "\n") |
799 |
799 |
800 for f in ctx.getfileset(expr): |
800 for f in ctx.getfileset(expr): |
831 repo = hg.peer(ui, opts, repopath) |
831 repo = hg.peer(ui, opts, repopath) |
832 if not repo.capable('getbundle'): |
832 if not repo.capable('getbundle'): |
833 raise error.Abort("getbundle() not supported by target repository") |
833 raise error.Abort("getbundle() not supported by target repository") |
834 args = {} |
834 args = {} |
835 if common: |
835 if common: |
836 args['common'] = [bin(s) for s in common] |
836 args[r'common'] = [bin(s) for s in common] |
837 if head: |
837 if head: |
838 args['heads'] = [bin(s) for s in head] |
838 args[r'heads'] = [bin(s) for s in head] |
839 # TODO: get desired bundlecaps from command line. |
839 # TODO: get desired bundlecaps from command line. |
840 args['bundlecaps'] = None |
840 args[r'bundlecaps'] = None |
841 bundle = repo.getbundle('debug', **args) |
841 bundle = repo.getbundle('debug', **args) |
842 |
842 |
843 bundletype = opts.get('type', 'bzip2').lower() |
843 bundletype = opts.get('type', 'bzip2').lower() |
844 btypes = {'none': 'HG10UN', |
844 btypes = {'none': 'HG10UN', |
845 'bzip2': 'HG10BZ', |
845 'bzip2': 'HG10BZ', |
1174 |
1174 |
1175 Returns 0 if no locks are held. |
1175 Returns 0 if no locks are held. |
1176 |
1176 |
1177 """ |
1177 """ |
1178 |
1178 |
1179 if opts.get('force_lock'): |
1179 if opts.get(r'force_lock'): |
1180 repo.svfs.unlink('lock') |
1180 repo.svfs.unlink('lock') |
1181 if opts.get('force_wlock'): |
1181 if opts.get(r'force_wlock'): |
1182 repo.vfs.unlink('wlock') |
1182 repo.vfs.unlink('wlock') |
1183 if opts.get('force_lock') or opts.get('force_lock'): |
1183 if opts.get(r'force_lock') or opts.get(r'force_lock'): |
1184 return 0 |
1184 return 0 |
1185 |
1185 |
1186 now = time.time() |
1186 now = time.time() |
1187 held = 0 |
1187 held = 0 |
1188 |
1188 |
1483 spec = spec[len(rootdir):] |
1483 spec = spec[len(rootdir):] |
1484 fixpaths = pycompat.ossep != '/' |
1484 fixpaths = pycompat.ossep != '/' |
1485 if fixpaths: |
1485 if fixpaths: |
1486 spec = spec.replace(pycompat.ossep, '/') |
1486 spec = spec.replace(pycompat.ossep, '/') |
1487 speclen = len(spec) |
1487 speclen = len(spec) |
1488 fullpaths = opts['full'] |
1488 fullpaths = opts[r'full'] |
1489 files, dirs = set(), set() |
1489 files, dirs = set(), set() |
1490 adddir, addfile = dirs.add, files.add |
1490 adddir, addfile = dirs.add, files.add |
1491 for f, st in dirstate.iteritems(): |
1491 for f, st in dirstate.iteritems(): |
1492 if f.startswith(spec) and st[0] in acceptable: |
1492 if f.startswith(spec) and st[0] in acceptable: |
1493 if fixpaths: |
1493 if fixpaths: |
1669 ctx = scmutil.revsingle(repo, rev) |
1669 ctx = scmutil.revsingle(repo, rev) |
1670 with repo.wlock(): |
1670 with repo.wlock(): |
1671 dirstate = repo.dirstate |
1671 dirstate = repo.dirstate |
1672 changedfiles = None |
1672 changedfiles = None |
1673 # See command doc for what minimal does. |
1673 # See command doc for what minimal does. |
1674 if opts.get('minimal'): |
1674 if opts.get(r'minimal'): |
1675 manifestfiles = set(ctx.manifest().keys()) |
1675 manifestfiles = set(ctx.manifest().keys()) |
1676 dirstatefiles = set(dirstate) |
1676 dirstatefiles = set(dirstate) |
1677 manifestonly = manifestfiles - dirstatefiles |
1677 manifestonly = manifestfiles - dirstatefiles |
1678 dsonly = dirstatefiles - manifestfiles |
1678 dsonly = dirstatefiles - manifestfiles |
1679 dsnotadded = set(f for f in dsonly if dirstate[f] != 'a') |
1679 dsnotadded = set(f for f in dsonly if dirstate[f] != 'a') |
2132 template. |
2132 template. |
2133 |
2133 |
2134 Use --verbose to print the parsed tree. |
2134 Use --verbose to print the parsed tree. |
2135 """ |
2135 """ |
2136 revs = None |
2136 revs = None |
2137 if opts['rev']: |
2137 if opts[r'rev']: |
2138 if repo is None: |
2138 if repo is None: |
2139 raise error.RepoError(_('there is no Mercurial repository here ' |
2139 raise error.RepoError(_('there is no Mercurial repository here ' |
2140 '(.hg not found)')) |
2140 '(.hg not found)')) |
2141 revs = scmutil.revrange(repo, opts['rev']) |
2141 revs = scmutil.revrange(repo, opts[r'rev']) |
2142 |
2142 |
2143 props = {} |
2143 props = {} |
2144 for d in opts['define']: |
2144 for d in opts[r'define']: |
2145 try: |
2145 try: |
2146 k, v = (e.strip() for e in d.split('=', 1)) |
2146 k, v = (e.strip() for e in d.split('=', 1)) |
2147 if not k or k == 'ui': |
2147 if not k or k == 'ui': |
2148 raise ValueError |
2148 raise ValueError |
2149 props[k] = v |
2149 props[k] = v |