hgext/convert/__init__.py
changeset 43077 687b865b95ad
parent 43076 2372284d9457
child 45942 89a2afe31e82
equal deleted inserted replaced
43076:2372284d9457 43077:687b865b95ad
    22 command = registrar.command(cmdtable)
    22 command = registrar.command(cmdtable)
    23 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
    23 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
    24 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
    24 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
    25 # be specifying the version(s) of Mercurial they are tested with, or
    25 # be specifying the version(s) of Mercurial they are tested with, or
    26 # leave the attribute unspecified.
    26 # leave the attribute unspecified.
    27 testedwith = 'ships-with-hg-core'
    27 testedwith = b'ships-with-hg-core'
    28 
    28 
    29 # Commands definition was moved elsewhere to ease demandload job.
    29 # Commands definition was moved elsewhere to ease demandload job.
    30 
    30 
    31 
    31 
    32 @command(
    32 @command(
    33     'convert',
    33     b'convert',
    34     [
    34     [
    35         (
    35         (
    36             '',
    36             b'',
    37             'authors',
    37             b'authors',
    38             '',
    38             b'',
    39             _(
    39             _(
    40                 'username mapping filename (DEPRECATED) (use --authormap instead)'
    40                 b'username mapping filename (DEPRECATED) (use --authormap instead)'
    41             ),
    41             ),
    42             _('FILE'),
    42             _(b'FILE'),
    43         ),
    43         ),
    44         ('s', 'source-type', '', _('source repository type'), _('TYPE')),
    44         (b's', b'source-type', b'', _(b'source repository type'), _(b'TYPE')),
    45         ('d', 'dest-type', '', _('destination repository type'), _('TYPE')),
    45         (
    46         ('r', 'rev', [], _('import up to source revision REV'), _('REV')),
    46             b'd',
    47         ('A', 'authormap', '', _('remap usernames using this file'), _('FILE')),
    47             b'dest-type',
    48         (
    48             b'',
    49             '',
    49             _(b'destination repository type'),
    50             'filemap',
    50             _(b'TYPE'),
    51             '',
    51         ),
    52             _('remap file names using contents of file'),
    52         (b'r', b'rev', [], _(b'import up to source revision REV'), _(b'REV')),
    53             _('FILE'),
    53         (
    54         ),
    54             b'A',
    55         (
    55             b'authormap',
    56             '',
    56             b'',
    57             'full',
    57             _(b'remap usernames using this file'),
       
    58             _(b'FILE'),
       
    59         ),
       
    60         (
       
    61             b'',
       
    62             b'filemap',
       
    63             b'',
       
    64             _(b'remap file names using contents of file'),
       
    65             _(b'FILE'),
       
    66         ),
       
    67         (
       
    68             b'',
       
    69             b'full',
    58             None,
    70             None,
    59             _('apply filemap changes by converting all files again'),
    71             _(b'apply filemap changes by converting all files again'),
    60         ),
    72         ),
    61         (
    73         (
    62             '',
    74             b'',
    63             'splicemap',
    75             b'splicemap',
    64             '',
    76             b'',
    65             _('splice synthesized history into place'),
    77             _(b'splice synthesized history into place'),
    66             _('FILE'),
    78             _(b'FILE'),
    67         ),
    79         ),
    68         (
    80         (
    69             '',
    81             b'',
    70             'branchmap',
    82             b'branchmap',
    71             '',
    83             b'',
    72             _('change branch names while converting'),
    84             _(b'change branch names while converting'),
    73             _('FILE'),
    85             _(b'FILE'),
    74         ),
    86         ),
    75         ('', 'branchsort', None, _('try to sort changesets by branches')),
    87         (b'', b'branchsort', None, _(b'try to sort changesets by branches')),
    76         ('', 'datesort', None, _('try to sort changesets by date')),
    88         (b'', b'datesort', None, _(b'try to sort changesets by date')),
    77         ('', 'sourcesort', None, _('preserve source changesets order')),
    89         (b'', b'sourcesort', None, _(b'preserve source changesets order')),
    78         ('', 'closesort', None, _('try to reorder closed revisions')),
    90         (b'', b'closesort', None, _(b'try to reorder closed revisions')),
    79     ],
    91     ],
    80     _('hg convert [OPTION]... SOURCE [DEST [REVMAP]]'),
    92     _(b'hg convert [OPTION]... SOURCE [DEST [REVMAP]]'),
    81     norepo=True,
    93     norepo=True,
    82 )
    94 )
    83 def convert(ui, src, dest=None, revmapfile=None, **opts):
    95 def convert(ui, src, dest=None, revmapfile=None, **opts):
    84     """convert a foreign SCM repository to a Mercurial one.
    96     """convert a foreign SCM repository to a Mercurial one.
    85 
    97 
   481         repo. The default is False.
   493         repo. The default is False.
   482     """
   494     """
   483     return convcmd.convert(ui, src, dest, revmapfile, **opts)
   495     return convcmd.convert(ui, src, dest, revmapfile, **opts)
   484 
   496 
   485 
   497 
   486 @command('debugsvnlog', [], 'hg debugsvnlog', norepo=True)
   498 @command(b'debugsvnlog', [], b'hg debugsvnlog', norepo=True)
   487 def debugsvnlog(ui, **opts):
   499 def debugsvnlog(ui, **opts):
   488     return subversion.debugsvnlog(ui, **opts)
   500     return subversion.debugsvnlog(ui, **opts)
   489 
   501 
   490 
   502 
   491 @command(
   503 @command(
   492     'debugcvsps',
   504     b'debugcvsps',
   493     [
   505     [
   494         # Main options shared with cvsps-2.1
   506         # Main options shared with cvsps-2.1
   495         ('b', 'branches', [], _('only return changes on specified branches')),
   507         (
   496         ('p', 'prefix', '', _('prefix to remove from file names')),
   508             b'b',
   497         (
   509             b'branches',
   498             'r',
       
   499             'revisions',
       
   500             [],
   510             [],
   501             _('only return changes after or between specified tags'),
   511             _(b'only return changes on specified branches'),
   502         ),
   512         ),
   503         ('u', 'update-cache', None, _("update cvs log cache")),
   513         (b'p', b'prefix', b'', _(b'prefix to remove from file names')),
   504         ('x', 'new-cache', None, _("create new cvs log cache")),
   514         (
   505         ('z', 'fuzz', 60, _('set commit time fuzz in seconds')),
   515             b'r',
   506         ('', 'root', '', _('specify cvsroot')),
   516             b'revisions',
       
   517             [],
       
   518             _(b'only return changes after or between specified tags'),
       
   519         ),
       
   520         (b'u', b'update-cache', None, _(b"update cvs log cache")),
       
   521         (b'x', b'new-cache', None, _(b"create new cvs log cache")),
       
   522         (b'z', b'fuzz', 60, _(b'set commit time fuzz in seconds')),
       
   523         (b'', b'root', b'', _(b'specify cvsroot')),
   507         # Options specific to builtin cvsps
   524         # Options specific to builtin cvsps
   508         ('', 'parents', '', _('show parent changesets')),
   525         (b'', b'parents', b'', _(b'show parent changesets')),
   509         ('', 'ancestors', '', _('show current changeset in ancestor branches')),
   526         (
       
   527             b'',
       
   528             b'ancestors',
       
   529             b'',
       
   530             _(b'show current changeset in ancestor branches'),
       
   531         ),
   510         # Options that are ignored for compatibility with cvsps-2.1
   532         # Options that are ignored for compatibility with cvsps-2.1
   511         ('A', 'cvs-direct', None, _('ignored for compatibility')),
   533         (b'A', b'cvs-direct', None, _(b'ignored for compatibility')),
   512     ],
   534     ],
   513     _('hg debugcvsps [OPTION]... [PATH]...'),
   535     _(b'hg debugcvsps [OPTION]... [PATH]...'),
   514     norepo=True,
   536     norepo=True,
   515 )
   537 )
   516 def debugcvsps(ui, *args, **opts):
   538 def debugcvsps(ui, *args, **opts):
   517     '''create changeset information from CVS
   539     '''create changeset information from CVS
   518 
   540 
   526     dates.'''
   548     dates.'''
   527     return cvsps.debugcvsps(ui, *args, **opts)
   549     return cvsps.debugcvsps(ui, *args, **opts)
   528 
   550 
   529 
   551 
   530 def kwconverted(context, mapping, name):
   552 def kwconverted(context, mapping, name):
   531     ctx = context.resource(mapping, 'ctx')
   553     ctx = context.resource(mapping, b'ctx')
   532     rev = ctx.extra().get('convert_revision', '')
   554     rev = ctx.extra().get(b'convert_revision', b'')
   533     if rev.startswith('svn:'):
   555     if rev.startswith(b'svn:'):
   534         if name == 'svnrev':
   556         if name == b'svnrev':
   535             return b"%d" % subversion.revsplit(rev)[2]
   557             return b"%d" % subversion.revsplit(rev)[2]
   536         elif name == 'svnpath':
   558         elif name == b'svnpath':
   537             return subversion.revsplit(rev)[1]
   559             return subversion.revsplit(rev)[1]
   538         elif name == 'svnuuid':
   560         elif name == b'svnuuid':
   539             return subversion.revsplit(rev)[0]
   561             return subversion.revsplit(rev)[0]
   540     return rev
   562     return rev
   541 
   563 
   542 
   564 
   543 templatekeyword = registrar.templatekeyword()
   565 templatekeyword = registrar.templatekeyword()
   544 
   566 
   545 
   567 
   546 @templatekeyword('svnrev', requires={'ctx'})
   568 @templatekeyword(b'svnrev', requires={b'ctx'})
   547 def kwsvnrev(context, mapping):
   569 def kwsvnrev(context, mapping):
   548     """String. Converted subversion revision number."""
   570     """String. Converted subversion revision number."""
   549     return kwconverted(context, mapping, 'svnrev')
   571     return kwconverted(context, mapping, b'svnrev')
   550 
   572 
   551 
   573 
   552 @templatekeyword('svnpath', requires={'ctx'})
   574 @templatekeyword(b'svnpath', requires={b'ctx'})
   553 def kwsvnpath(context, mapping):
   575 def kwsvnpath(context, mapping):
   554     """String. Converted subversion revision project path."""
   576     """String. Converted subversion revision project path."""
   555     return kwconverted(context, mapping, 'svnpath')
   577     return kwconverted(context, mapping, b'svnpath')
   556 
   578 
   557 
   579 
   558 @templatekeyword('svnuuid', requires={'ctx'})
   580 @templatekeyword(b'svnuuid', requires={b'ctx'})
   559 def kwsvnuuid(context, mapping):
   581 def kwsvnuuid(context, mapping):
   560     """String. Converted subversion revision repository identifier."""
   582     """String. Converted subversion revision repository identifier."""
   561     return kwconverted(context, mapping, 'svnuuid')
   583     return kwconverted(context, mapping, b'svnuuid')
   562 
   584 
   563 
   585 
   564 # tell hggettext to extract docstrings from these functions:
   586 # tell hggettext to extract docstrings from these functions:
   565 i18nfunctions = [kwsvnrev, kwsvnpath, kwsvnuuid]
   587 i18nfunctions = [kwsvnrev, kwsvnpath, kwsvnuuid]