hgext/transplant.py
changeset 19028 b512934988d4
parent 19027 3f5fac4b1cfa
child 19055 0fc41f88f148
equal deleted inserted replaced
19027:3f5fac4b1cfa 19028:b512934988d4
     5 # This software may be used and distributed according to the terms of the
     5 # This software may be used and distributed according to the terms of the
     6 # GNU General Public License version 2 or any later version.
     6 # GNU General Public License version 2 or any later version.
     7 
     7 
     8 '''command to transplant changesets from another branch
     8 '''command to transplant changesets from another branch
     9 
     9 
    10 This extension allows you to transplant patches from another branch.
    10 This extension allows you to transplant changes to another parent revision,
       
    11 possibly in another repository. The transplant is done using 'diff' patches.
    11 
    12 
    12 Transplanted patches are recorded in .hg/transplant/transplants, as a
    13 Transplanted patches are recorded in .hg/transplant/transplants, as a
    13 map from a changeset hash to its hash in the source repository.
    14 map from a changeset hash to its hash in the source repository.
    14 '''
    15 '''
    15 
    16 
   490             break
   491             break
   491     displayer.close()
   492     displayer.close()
   492     return (transplants, merges)
   493     return (transplants, merges)
   493 
   494 
   494 @command('transplant',
   495 @command('transplant',
   495     [('s', 'source', '', _('pull patches from REPO'), _('REPO')),
   496     [('s', 'source', '', _('transplant changesets from REPO'), _('REPO')),
   496     ('b', 'branch', [], _('use this source changeset as head'), _('REV')),
   497     ('b', 'branch', [], _('use this source changeset as head'), _('REV')),
   497     ('a', 'all', None, _('pull all changesets up to the --branch revisions')),
   498     ('a', 'all', None, _('pull all changesets up to the --branch revisions')),
   498     ('p', 'prune', [], _('skip over REV'), _('REV')),
   499     ('p', 'prune', [], _('skip over REV'), _('REV')),
   499     ('m', 'merge', [], _('merge at REV'), _('REV')),
   500     ('m', 'merge', [], _('merge at REV'), _('REV')),
   500     ('', 'parent', '',
   501     ('', 'parent', '',
   501      _('parent to choose when transplanting merge'), _('REV')),
   502      _('parent to choose when transplanting merge'), _('REV')),
   502     ('e', 'edit', False, _('invoke editor on commit messages')),
   503     ('e', 'edit', False, _('invoke editor on commit messages')),
   503     ('', 'log', None, _('append transplant info to log message')),
   504     ('', 'log', None, _('append transplant info to log message')),
   504     ('c', 'continue', None, _('continue last transplant session '
   505     ('c', 'continue', None, _('continue last transplant session '
   505                               'after repair')),
   506                               'after fixing conflicts')),
   506     ('', 'filter', '',
   507     ('', 'filter', '',
   507      _('filter changesets through command'), _('CMD'))],
   508      _('filter changesets through command'), _('CMD'))],
   508     _('hg transplant [-s REPO] [-b BRANCH [-a]] [-p REV] '
   509     _('hg transplant [-s REPO] [-b BRANCH [-a]] [-p REV] '
   509       '[-m REV] [REV]...'))
   510       '[-m REV] [REV]...'))
   510 def transplant(ui, repo, *revs, **opts):
   511 def transplant(ui, repo, *revs, **opts):
   511     '''transplant changesets from another branch
   512     '''transplant changesets from another branch
   512 
   513 
   513     Selected changesets will be applied on top of the current working
   514     Selected changesets will be applied on top of the current working
   514     directory with the log of the original changeset. The changesets
   515     directory with the log of the original changeset. The changesets
   515     are copied and will thus appear twice in the history. Use the
   516     are copied and will thus appear twice in the history with different
   516     rebase extension instead if you want to move a whole branch of
   517     identities.
   517     unpublished changesets.
   518 
       
   519     Consider using the graft command if everything is inside the same
       
   520     repository - it will use merges and will usually give a better result.
       
   521     Use the rebase extension if the changesets are unpublished and you want
       
   522     to move them instead of copying them.
   518 
   523 
   519     If --log is specified, log messages will have a comment appended
   524     If --log is specified, log messages will have a comment appended
   520     of the form::
   525     of the form::
   521 
   526 
   522       (transplanted from CHANGESETHASH)
   527       (transplanted from CHANGESETHASH)
   523 
   528 
   524     You can rewrite the changelog message with the --filter option.
   529     You can rewrite the changelog message with the --filter option.
   525     Its argument will be invoked with the current changelog message as
   530     Its argument will be invoked with the current changelog message as
   526     $1 and the patch as $2.
   531     $1 and the patch as $2.
   527 
   532 
   528     If --source/-s is specified, selects changesets from the named
   533     --source/-s specifies another repository to use for selecting changesets,
   529     repository.
   534     just as if it temporarily had been pulled.
   530     If --branch/-b is specified, these revisions will be used as
   535     If --branch/-b is specified, these revisions will be used as
   531     heads when deciding which changsets to transplant, just as if only
   536     heads when deciding which changsets to transplant, just as if only
   532     these revisions had been pulled.
   537     these revisions had been pulled.
   533     If --all/-a is specified, all the revisions up to the heads specified
   538     If --all/-a is specified, all the revisions up to the heads specified
   534     with --branch will be transplanted.
   539     with --branch will be transplanted.
   574 
   579 
   575     def checkopts(opts, revs):
   580     def checkopts(opts, revs):
   576         if opts.get('continue'):
   581         if opts.get('continue'):
   577             if opts.get('branch') or opts.get('all') or opts.get('merge'):
   582             if opts.get('branch') or opts.get('all') or opts.get('merge'):
   578                 raise util.Abort(_('--continue is incompatible with '
   583                 raise util.Abort(_('--continue is incompatible with '
   579                                    'branch, all or merge'))
   584                                    '--branch, --all and --merge'))
   580             return
   585             return
   581         if not (opts.get('source') or revs or
   586         if not (opts.get('source') or revs or
   582                 opts.get('merge') or opts.get('branch')):
   587                 opts.get('merge') or opts.get('branch')):
   583             raise util.Abort(_('no source URL, branch revision or revision '
   588             raise util.Abort(_('no source URL, branch revision or revision '
   584                                'list provided'))
   589                                'list provided'))