hgext3rd/evolve/cmdrewrite.py
changeset 4715 12c8b24757f4
parent 4714 c51fc0ae7a7e
child 4721 b69497b23d31
equal deleted inserted replaced
4714:c51fc0ae7a7e 4715:12c8b24757f4
    84         opts['date'] = '%d %d' % compat.makedate()
    84         opts['date'] = '%d %d' % compat.makedate()
    85     if not opts.get('user') and opts.get('current_user'):
    85     if not opts.get('user') and opts.get('current_user'):
    86         opts['user'] = ui.username()
    86         opts['user'] = ui.username()
    87 
    87 
    88 commitopts3 = [
    88 commitopts3 = [
    89     ('D', 'current-date', None,
    89     (b'D', b'current-date', None,
    90      _('record the current date as commit date')),
    90      _(b'record the current date as commit date')),
    91     ('U', 'current-user', None,
    91     (b'U', b'current-user', None,
    92      _('record the current user as committer')),
    92      _(b'record the current user as committer')),
    93 ]
    93 ]
    94 
    94 
    95 interactiveopt = [['i', 'interactive', None, _('use interactive mode')]]
    95 interactiveopt = [[b'i', b'interactive', None, _(b'use interactive mode')]]
    96 
    96 
    97 @eh.command(
    97 @eh.command(
    98     'amend|refresh',
    98     b'amend|refresh',
    99     [('A', 'addremove', None,
    99     [(b'A', b'addremove', None,
   100       _('mark new/missing files as added/removed before committing')),
   100       _(b'mark new/missing files as added/removed before committing')),
   101      ('a', 'all', False, _("match all files")),
   101      (b'a', b'all', False, _(b"match all files")),
   102      ('e', 'edit', False, _('invoke editor on commit messages')),
   102      (b'e', b'edit', False, _(b'invoke editor on commit messages')),
   103      ('', 'extract', False, _('extract changes from the commit to the working copy')),
   103      (b'', b'extract', False, _(b'extract changes from the commit to the working copy')),
   104      ('', 'patch', False, _('make changes to wdir parent by editing patch')),
   104      (b'', b'patch', False, _(b'make changes to wdir parent by editing patch')),
   105      ('', 'close-branch', None,
   105      (b'', b'close-branch', None,
   106       _('mark a branch as closed, hiding it from the branch list')),
   106       _(b'mark a branch as closed, hiding it from the branch list')),
   107      ('s', 'secret', None, _('use the secret phase for committing')),
   107      (b's', b'secret', None, _(b'use the secret phase for committing')),
   108      ('n', 'note', '', _('store a note on amend'), _('TEXT')),
   108      (b'n', b'note', b'', _(b'store a note on amend'), _(b'TEXT')),
   109     ] + walkopts + commitopts + commitopts2 + commitopts3 + interactiveopt,
   109      ] + walkopts + commitopts + commitopts2 + commitopts3 + interactiveopt,
   110     _('[OPTION]... [FILE]...'),
   110     _(b'[OPTION]... [FILE]...'),
   111     helpbasic=True)
   111     helpbasic=True)
   112 def amend(ui, repo, *pats, **opts):
   112 def amend(ui, repo, *pats, **opts):
   113     """combine a changeset with updates and replace it with a new one
   113     """combine a changeset with updates and replace it with a new one
   114 
   114 
   115     Commits a new changeset incorporating both the changes to the given files
   115     Commits a new changeset incorporating both the changes to the given files
   447         if (src not in ctx or dst in ctx or ds[dst] != 'a'):
   447         if (src not in ctx or dst in ctx or ds[dst] != 'a'):
   448             src = None
   448             src = None
   449         ds.copy(src, dst)
   449         ds.copy(src, dst)
   450 
   450 
   451 @eh.command(
   451 @eh.command(
   452     'uncommit',
   452     b'uncommit',
   453     [('a', 'all', None, _('uncommit all changes when no arguments given')),
   453     [(b'a', b'all', None, _(b'uncommit all changes when no arguments given')),
   454      ('i', 'interactive', False, _('interactive mode to uncommit (EXPERIMENTAL)')),
   454      (b'i', b'interactive', False, _(b'interactive mode to uncommit (EXPERIMENTAL)')),
   455      ('r', 'rev', '', _('revert commit content to REV instead'), _('REV')),
   455      (b'r', b'rev', b'', _(b'revert commit content to REV instead'), _(b'REV')),
   456      ('', 'revert', False, _('discard working directory changes after uncommit')),
   456      (b'', b'revert', False, _(b'discard working directory changes after uncommit')),
   457      ('n', 'note', '', _('store a note on uncommit'), _('TEXT')),
   457      (b'n', b'note', b'', _(b'store a note on uncommit'), _(b'TEXT')),
   458      ] + commands.walkopts + commitopts + commitopts2 + commitopts3,
   458      ] + commands.walkopts + commitopts + commitopts2 + commitopts3,
   459     _('[OPTION]... [NAME]'))
   459     _(b'[OPTION]... [NAME]'))
   460 def uncommit(ui, repo, *pats, **opts):
   460 def uncommit(ui, repo, *pats, **opts):
   461     """move changes from parent revision to working directory
   461     """move changes from parent revision to working directory
   462 
   462 
   463     Changes to selected files in the checked out revision appear again as
   463     Changes to selected files in the checked out revision appear again as
   464     uncommitted changed in the working directory. A new revision
   464     uncommitted changed in the working directory. A new revision
   683     finally:
   683     finally:
   684         store.close()
   684         store.close()
   685     return newcm
   685     return newcm
   686 
   686 
   687 @eh.command(
   687 @eh.command(
   688     'fold|squash',
   688     b'fold|squash',
   689     [('r', 'rev', [], _("revision to fold"), _('REV')),
   689     [(b'r', b'rev', [], _(b"revision to fold"), _(b'REV')),
   690      ('', 'exact', None, _("only fold specified revisions")),
   690      (b'', b'exact', None, _(b"only fold specified revisions")),
   691      ('', 'from', None, _("fold revisions linearly to working copy parent")),
   691      (b'', b'from', None, _(b"fold revisions linearly to working copy parent")),
   692      ('n', 'note', '', _('store a note on fold'), _('TEXT')),
   692      (b'n', b'note', b'', _(b'store a note on fold'), _(b'TEXT')),
   693     ] + commitopts + commitopts2 + commitopts3,
   693      ] + commitopts + commitopts2 + commitopts3,
   694     _('hg fold [OPTION]... [-r] REV'),
   694     _(b'hg fold [OPTION]... [-r] REV'),
   695     helpbasic=True)
   695     helpbasic=True)
   696 def fold(ui, repo, *revs, **opts):
   696 def fold(ui, repo, *revs, **opts):
   697     """fold multiple revisions into a single one
   697     """fold multiple revisions into a single one
   698 
   698 
   699     With --from, folds all the revisions linearly between the given revisions
   699     With --from, folds all the revisions linearly between the given revisions
   811             hg.update(repo, newid)
   811             hg.update(repo, newid)
   812     finally:
   812     finally:
   813         lockmod.release(lock, wlock)
   813         lockmod.release(lock, wlock)
   814 
   814 
   815 @eh.command(
   815 @eh.command(
   816     'metaedit',
   816     b'metaedit',
   817     [('r', 'rev', [], _("revision to edit"), _('REV')),
   817     [(b'r', b'rev', [], _(b"revision to edit"), _(b'REV')),
   818      ('', 'fold', None, _("also fold specified revisions into one")),
   818      (b'', b'fold', None, _(b"also fold specified revisions into one")),
   819      ('n', 'note', '', _('store a note on metaedit'), _('TEXT')),
   819      (b'n', b'note', b'', _(b'store a note on metaedit'), _(b'TEXT')),
   820     ] + commitopts + commitopts2 + commitopts3,
   820      ] + commitopts + commitopts2 + commitopts3,
   821     _('hg metaedit [OPTION]... [-r] [REV]'))
   821     _(b'hg metaedit [OPTION]... [-r] [REV]'))
   822 def metaedit(ui, repo, *revs, **opts):
   822 def metaedit(ui, repo, *revs, **opts):
   823     """edit commit information
   823     """edit commit information
   824 
   824 
   825     Edits the commit information for the specified revisions. By default, edits
   825     Edits the commit information for the specified revisions. By default, edits
   826     commit information for the working directory parent.
   826     commit information for the working directory parent.
   937             ui.status('%i changesets folded\n' % len(revs))
   937             ui.status('%i changesets folded\n' % len(revs))
   938         if newp1 is not None:
   938         if newp1 is not None:
   939             hg.update(repo, newp1)
   939             hg.update(repo, newp1)
   940 
   940 
   941 metadataopts = [
   941 metadataopts = [
   942     ('d', 'date', '',
   942     (b'd', b'date', b'',
   943      _('record the specified date in metadata'), _('DATE')),
   943      _(b'record the specified date in metadata'), _(b'DATE')),
   944     ('u', 'user', '',
   944     (b'u', b'user', b'',
   945      _('record the specified user in metadata'), _('USER')),
   945      _(b'record the specified user in metadata'), _(b'USER')),
   946 ]
   946 ]
   947 
   947 
   948 def _getmetadata(**opts):
   948 def _getmetadata(**opts):
   949     metadata = {}
   949     metadata = {}
   950     date = opts.get('date')
   950     date = opts.get('date')
   954     if user:
   954     if user:
   955         metadata['user'] = user
   955         metadata['user'] = user
   956     return metadata
   956     return metadata
   957 
   957 
   958 @eh.command(
   958 @eh.command(
   959     'prune|obsolete',
   959     b'prune|obsolete',
   960     [('n', 'new', [], _("successor changeset (DEPRECATED)")),
   960     [(b'n', b'new', [], _(b"successor changeset (DEPRECATED)")),
   961      ('s', 'succ', [], _("successor changeset"), _('REV')),
   961      (b's', b'succ', [], _(b"successor changeset"), _(b'REV')),
   962      ('r', 'rev', [], _("revisions to prune"), _('REV')),
   962      (b'r', b'rev', [], _(b"revisions to prune"), _(b'REV')),
   963      ('k', 'keep', None, _("does not modify working copy during prune")),
   963      (b'k', b'keep', None, _(b"does not modify working copy during prune")),
   964      ('n', 'note', '', _('store a note on prune'), _('TEXT')),
   964      (b'n', b'note', b'', _(b'store a note on prune'), _(b'TEXT')),
   965      ('', 'pair', False, _("record a pairing, such as a rebase or divergence resolution "
   965      (b'', b'pair', False, _(b"record a pairing, such as a rebase or divergence resolution "
   966                            "(pairing multiple precursors to multiple successors)")),
   966                              b"(pairing multiple precursors to multiple successors)")),
   967      ('', 'biject', False, _("alias to --pair (DEPRECATED)")),
   967      (b'', b'biject', False, _(b"alias to --pair (DEPRECATED)")),
   968      ('', 'fold', False,
   968      (b'', b'fold', False,
   969       _("record a fold (multiple precursors, one successors)")),
   969       _(b"record a fold (multiple precursors, one successors)")),
   970      ('', 'split', False,
   970      (b'', b'split', False,
   971       _("record a split (on precursor, multiple successors)")),
   971       _(b"record a split (on precursor, multiple successors)")),
   972      ('B', 'bookmark', [], _("remove revs only reachable from given"
   972      (b'B', b'bookmark', [], _(b"remove revs only reachable from given"
   973                              " bookmark"), _('BOOKMARK'))] + metadataopts,
   973                                b" bookmark"), _(b'BOOKMARK'))] + metadataopts,
   974     _('[OPTION] [-r] REV...'),
   974     _(b'[OPTION] [-r] REV...'),
   975     helpbasic=True)
   975     helpbasic=True)
   976 # XXX -U  --noupdate option to prevent wc update and or bookmarks update ?
   976 # XXX -U  --noupdate option to prevent wc update and or bookmarks update ?
   977 def cmdprune(ui, repo, *revs, **opts):
   977 def cmdprune(ui, repo, *revs, **opts):
   978     """mark changesets as obsolete or succeeded by another changeset
   978     """mark changesets as obsolete or succeeded by another changeset
   979 
   979 
  1151         tr.close()
  1151         tr.close()
  1152     finally:
  1152     finally:
  1153         lockmod.release(tr, lock, wlock)
  1153         lockmod.release(tr, lock, wlock)
  1154 
  1154 
  1155 @eh.command(
  1155 @eh.command(
  1156     'split',
  1156     b'split',
  1157     [('i', 'interactive', True, _('use interactive mode')),
  1157     [(b'i', b'interactive', True, _(b'use interactive mode')),
  1158      ('r', 'rev', [], _("revision to split"), _('REV')),
  1158      (b'r', b'rev', [], _(b"revision to split"), _(b'REV')),
  1159      ('n', 'note', '', _("store a note on split"), _('TEXT')),
  1159      (b'n', b'note', b'', _(b"store a note on split"), _(b'TEXT')),
  1160     ] + commitopts + commitopts2 + commitopts3,
  1160      ] + commitopts + commitopts2 + commitopts3,
  1161     _('hg split [OPTION] [-r REV] [FILES]'),
  1161     _(b'hg split [OPTION] [-r REV] [FILES]'),
  1162     helpbasic=True)
  1162     helpbasic=True)
  1163 def cmdsplit(ui, repo, *pats, **opts):
  1163 def cmdsplit(ui, repo, *pats, **opts):
  1164     """split a changeset into smaller changesets
  1164     """split a changeset into smaller changesets
  1165 
  1165 
  1166     By default, split the current revision by prompting for all its hunks to be
  1166     By default, split the current revision by prompting for all its hunks to be
  1323         repo.dirstate.setbranch(savedbranch)
  1323         repo.dirstate.setbranch(savedbranch)
  1324 
  1324 
  1325         lockmod.release(tr, lock, wlock)
  1325         lockmod.release(tr, lock, wlock)
  1326 
  1326 
  1327 @eh.command(
  1327 @eh.command(
  1328     'touch',
  1328     b'touch',
  1329     [('r', 'rev', [], _('revision to update'), _('REV')),
  1329     [(b'r', b'rev', [], _(b'revision to update'), _(b'REV')),
  1330      ('n', 'note', '', _('store a note on touch'), _('TEXT')),
  1330      (b'n', b'note', b'', _(b'store a note on touch'), _(b'TEXT')),
  1331      ('D', 'duplicate', False,
  1331      (b'D', b'duplicate', False,
  1332       'do not mark the new revision as successor of the old one'),
  1332       b'do not mark the new revision as successor of the old one'),
  1333      ('A', 'allowdivergence', False,
  1333      (b'A', b'allowdivergence', False,
  1334       'mark the new revision as successor of the old one potentially creating '
  1334       b'mark the new revision as successor of the old one potentially creating '
  1335       'divergence')],
  1335       b'divergence')],
  1336     # allow to choose the seed ?
  1336     # allow to choose the seed ?
  1337     _('[-r] revs'))
  1337     _('[-r] revs'))
  1338 def touch(ui, repo, *revs, **opts):
  1338 def touch(ui, repo, *revs, **opts):
  1339     """create successors identical to their predecessors but the changeset ID
  1339     """create successors identical to their predecessors but the changeset ID
  1340 
  1340 
  1415         if ctx in repo[None].parents():
  1415         if ctx in repo[None].parents():
  1416             with repo.dirstate.parentchange():
  1416             with repo.dirstate.parentchange():
  1417                 repo.dirstate.setparents(new, node.nullid)
  1417                 repo.dirstate.setparents(new, node.nullid)
  1418 
  1418 
  1419 @eh.command(
  1419 @eh.command(
  1420     'pick|grab',
  1420     b'pick|grab',
  1421     [('r', 'rev', '', _('revision to pick'), _('REV')),
  1421     [(b'r', b'rev', b'', _(b'revision to pick'), _(b'REV')),
  1422      ('c', 'continue', False, 'continue interrupted pick'),
  1422      (b'c', b'continue', False, b'continue interrupted pick'),
  1423      ('a', 'abort', False, 'abort interrupted pick'),
  1423      (b'a', b'abort', False, b'abort interrupted pick'),
  1424     ] + mergetoolopts,
  1424     ] + mergetoolopts,
  1425     _('[-r] rev'))
  1425     _(b'[-r] rev'))
  1426 def cmdpick(ui, repo, *revs, **opts):
  1426 def cmdpick(ui, repo, *revs, **opts):
  1427     """move a commit on the top of working directory parent and updates to it."""
  1427     """move a commit on the top of working directory parent and updates to it."""
  1428 
  1428 
  1429     cont = opts.get('continue')
  1429     cont = opts.get('continue')
  1430     abort = opts.get('abort')
  1430     abort = opts.get('abort')