comparison hgext/convert/__init__.py @ 43076:2372284d9457

formatting: blacken the codebase This is using my patch to black (https://github.com/psf/black/pull/826) so we don't un-wrap collection literals. Done with: hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**"' | xargs black -S # skip-blame mass-reformatting only # no-check-commit reformats foo_bar functions Differential Revision: https://phab.mercurial-scm.org/D6971
author Augie Fackler <augie@google.com>
date Sun, 06 Oct 2019 09:45:02 -0400
parents d98ec36be808
children 687b865b95ad
comparison
equal deleted inserted replaced
43075:57875cf423c9 43076:2372284d9457
8 '''import revisions from foreign VCS repositories into Mercurial''' 8 '''import revisions from foreign VCS repositories into Mercurial'''
9 9
10 from __future__ import absolute_import 10 from __future__ import absolute_import
11 11
12 from mercurial.i18n import _ 12 from mercurial.i18n import _
13 from mercurial import ( 13 from mercurial import registrar
14 registrar,
15 )
16 14
17 from . import ( 15 from . import (
18 convcmd, 16 convcmd,
19 cvsps, 17 cvsps,
20 subversion, 18 subversion,
28 # leave the attribute unspecified. 26 # leave the attribute unspecified.
29 testedwith = 'ships-with-hg-core' 27 testedwith = 'ships-with-hg-core'
30 28
31 # Commands definition was moved elsewhere to ease demandload job. 29 # Commands definition was moved elsewhere to ease demandload job.
32 30
33 @command('convert', 31
34 [('', 'authors', '', 32 @command(
35 _('username mapping filename (DEPRECATED) (use --authormap instead)'), 33 'convert',
36 _('FILE')), 34 [
37 ('s', 'source-type', '', _('source repository type'), _('TYPE')), 35 (
38 ('d', 'dest-type', '', _('destination repository type'), _('TYPE')), 36 '',
39 ('r', 'rev', [], _('import up to source revision REV'), _('REV')), 37 'authors',
40 ('A', 'authormap', '', _('remap usernames using this file'), _('FILE')), 38 '',
41 ('', 'filemap', '', _('remap file names using contents of file'), 39 _(
42 _('FILE')), 40 'username mapping filename (DEPRECATED) (use --authormap instead)'
43 ('', 'full', None, 41 ),
44 _('apply filemap changes by converting all files again')), 42 _('FILE'),
45 ('', 'splicemap', '', _('splice synthesized history into place'), 43 ),
46 _('FILE')), 44 ('s', 'source-type', '', _('source repository type'), _('TYPE')),
47 ('', 'branchmap', '', _('change branch names while converting'), 45 ('d', 'dest-type', '', _('destination repository type'), _('TYPE')),
48 _('FILE')), 46 ('r', 'rev', [], _('import up to source revision REV'), _('REV')),
49 ('', 'branchsort', None, _('try to sort changesets by branches')), 47 ('A', 'authormap', '', _('remap usernames using this file'), _('FILE')),
50 ('', 'datesort', None, _('try to sort changesets by date')), 48 (
51 ('', 'sourcesort', None, _('preserve source changesets order')), 49 '',
52 ('', 'closesort', None, _('try to reorder closed revisions'))], 50 'filemap',
53 _('hg convert [OPTION]... SOURCE [DEST [REVMAP]]'), 51 '',
54 norepo=True) 52 _('remap file names using contents of file'),
53 _('FILE'),
54 ),
55 (
56 '',
57 'full',
58 None,
59 _('apply filemap changes by converting all files again'),
60 ),
61 (
62 '',
63 'splicemap',
64 '',
65 _('splice synthesized history into place'),
66 _('FILE'),
67 ),
68 (
69 '',
70 'branchmap',
71 '',
72 _('change branch names while converting'),
73 _('FILE'),
74 ),
75 ('', 'branchsort', None, _('try to sort changesets by branches')),
76 ('', 'datesort', None, _('try to sort changesets by date')),
77 ('', 'sourcesort', None, _('preserve source changesets order')),
78 ('', 'closesort', None, _('try to reorder closed revisions')),
79 ],
80 _('hg convert [OPTION]... SOURCE [DEST [REVMAP]]'),
81 norepo=True,
82 )
55 def convert(ui, src, dest=None, revmapfile=None, **opts): 83 def convert(ui, src, dest=None, revmapfile=None, **opts):
56 """convert a foreign SCM repository to a Mercurial one. 84 """convert a foreign SCM repository to a Mercurial one.
57 85
58 Accepted source formats [identifiers]: 86 Accepted source formats [identifiers]:
59 87
452 :convert.skiptags: does not convert tags from the source repo to the target 480 :convert.skiptags: does not convert tags from the source repo to the target
453 repo. The default is False. 481 repo. The default is False.
454 """ 482 """
455 return convcmd.convert(ui, src, dest, revmapfile, **opts) 483 return convcmd.convert(ui, src, dest, revmapfile, **opts)
456 484
485
457 @command('debugsvnlog', [], 'hg debugsvnlog', norepo=True) 486 @command('debugsvnlog', [], 'hg debugsvnlog', norepo=True)
458 def debugsvnlog(ui, **opts): 487 def debugsvnlog(ui, **opts):
459 return subversion.debugsvnlog(ui, **opts) 488 return subversion.debugsvnlog(ui, **opts)
460 489
461 @command('debugcvsps', 490
491 @command(
492 'debugcvsps',
462 [ 493 [
463 # Main options shared with cvsps-2.1 494 # Main options shared with cvsps-2.1
464 ('b', 'branches', [], _('only return changes on specified branches')), 495 ('b', 'branches', [], _('only return changes on specified branches')),
465 ('p', 'prefix', '', _('prefix to remove from file names')), 496 ('p', 'prefix', '', _('prefix to remove from file names')),
466 ('r', 'revisions', [], 497 (
467 _('only return changes after or between specified tags')), 498 'r',
468 ('u', 'update-cache', None, _("update cvs log cache")), 499 'revisions',
469 ('x', 'new-cache', None, _("create new cvs log cache")), 500 [],
470 ('z', 'fuzz', 60, _('set commit time fuzz in seconds')), 501 _('only return changes after or between specified tags'),
471 ('', 'root', '', _('specify cvsroot')), 502 ),
472 # Options specific to builtin cvsps 503 ('u', 'update-cache', None, _("update cvs log cache")),
473 ('', 'parents', '', _('show parent changesets')), 504 ('x', 'new-cache', None, _("create new cvs log cache")),
474 ('', 'ancestors', '', _('show current changeset in ancestor branches')), 505 ('z', 'fuzz', 60, _('set commit time fuzz in seconds')),
475 # Options that are ignored for compatibility with cvsps-2.1 506 ('', 'root', '', _('specify cvsroot')),
476 ('A', 'cvs-direct', None, _('ignored for compatibility')), 507 # Options specific to builtin cvsps
508 ('', 'parents', '', _('show parent changesets')),
509 ('', 'ancestors', '', _('show current changeset in ancestor branches')),
510 # Options that are ignored for compatibility with cvsps-2.1
511 ('A', 'cvs-direct', None, _('ignored for compatibility')),
477 ], 512 ],
478 _('hg debugcvsps [OPTION]... [PATH]...'), 513 _('hg debugcvsps [OPTION]... [PATH]...'),
479 norepo=True) 514 norepo=True,
515 )
480 def debugcvsps(ui, *args, **opts): 516 def debugcvsps(ui, *args, **opts):
481 '''create changeset information from CVS 517 '''create changeset information from CVS
482 518
483 This command is intended as a debugging tool for the CVS to 519 This command is intended as a debugging tool for the CVS to
484 Mercurial converter, and can be used as a direct replacement for 520 Mercurial converter, and can be used as a direct replacement for
488 named directory) in the CVS repository, and converts the log to a 524 named directory) in the CVS repository, and converts the log to a
489 series of changesets based on matching commit log entries and 525 series of changesets based on matching commit log entries and
490 dates.''' 526 dates.'''
491 return cvsps.debugcvsps(ui, *args, **opts) 527 return cvsps.debugcvsps(ui, *args, **opts)
492 528
529
493 def kwconverted(context, mapping, name): 530 def kwconverted(context, mapping, name):
494 ctx = context.resource(mapping, 'ctx') 531 ctx = context.resource(mapping, 'ctx')
495 rev = ctx.extra().get('convert_revision', '') 532 rev = ctx.extra().get('convert_revision', '')
496 if rev.startswith('svn:'): 533 if rev.startswith('svn:'):
497 if name == 'svnrev': 534 if name == 'svnrev':
498 return (b"%d" % subversion.revsplit(rev)[2]) 535 return b"%d" % subversion.revsplit(rev)[2]
499 elif name == 'svnpath': 536 elif name == 'svnpath':
500 return subversion.revsplit(rev)[1] 537 return subversion.revsplit(rev)[1]
501 elif name == 'svnuuid': 538 elif name == 'svnuuid':
502 return subversion.revsplit(rev)[0] 539 return subversion.revsplit(rev)[0]
503 return rev 540 return rev
504 541
542
505 templatekeyword = registrar.templatekeyword() 543 templatekeyword = registrar.templatekeyword()
544
506 545
507 @templatekeyword('svnrev', requires={'ctx'}) 546 @templatekeyword('svnrev', requires={'ctx'})
508 def kwsvnrev(context, mapping): 547 def kwsvnrev(context, mapping):
509 """String. Converted subversion revision number.""" 548 """String. Converted subversion revision number."""
510 return kwconverted(context, mapping, 'svnrev') 549 return kwconverted(context, mapping, 'svnrev')
511 550
551
512 @templatekeyword('svnpath', requires={'ctx'}) 552 @templatekeyword('svnpath', requires={'ctx'})
513 def kwsvnpath(context, mapping): 553 def kwsvnpath(context, mapping):
514 """String. Converted subversion revision project path.""" 554 """String. Converted subversion revision project path."""
515 return kwconverted(context, mapping, 'svnpath') 555 return kwconverted(context, mapping, 'svnpath')
516 556
557
517 @templatekeyword('svnuuid', requires={'ctx'}) 558 @templatekeyword('svnuuid', requires={'ctx'})
518 def kwsvnuuid(context, mapping): 559 def kwsvnuuid(context, mapping):
519 """String. Converted subversion revision repository identifier.""" 560 """String. Converted subversion revision repository identifier."""
520 return kwconverted(context, mapping, 'svnuuid') 561 return kwconverted(context, mapping, 'svnuuid')
521 562
563
522 # tell hggettext to extract docstrings from these functions: 564 # tell hggettext to extract docstrings from these functions:
523 i18nfunctions = [kwsvnrev, kwsvnpath, kwsvnuuid] 565 i18nfunctions = [kwsvnrev, kwsvnpath, kwsvnuuid]