hgext/evolve.py
changeset 894 4f21a3279a60
parent 890 7de15cfd79f7
child 895 17ac69db9329
equal deleted inserted replaced
890:7de15cfd79f7 894:4f21a3279a60
   871     ('d', 'date', '',
   871     ('d', 'date', '',
   872      _('record the specified date in metadata'), _('DATE')),
   872      _('record the specified date in metadata'), _('DATE')),
   873     ('u', 'user', '',
   873     ('u', 'user', '',
   874      _('record the specified user in metadata'), _('USER')),
   874      _('record the specified user in metadata'), _('USER')),
   875 ]
   875 ]
       
   876 
       
   877 def _deprecatealias(oldalias, newalias):
       
   878     '''Deprecates an alias for a command in favour of another
       
   879 
       
   880     Creates a new entry in the command table for the old alias. It creates a
       
   881     wrapper that has its synopsis set to show that is has been deprecated.
       
   882     The documentation will be replace with a pointer to the new alias.
       
   883     If a user invokes the command a deprecation warning will be printed and
       
   884     the command of the *new* alias will be invoked.
       
   885 
       
   886     This function is loosely based on the extensions.wrapcommand function.
       
   887     '''
       
   888     aliases, entry = cmdutil.findcmd(newalias, cmdtable)
       
   889     for alias, e in cmdtable.iteritems():
       
   890         if e is entry:
       
   891             break
       
   892 
       
   893     synopsis = '(DEPRECATED)'
       
   894     if len(entry) > 2:
       
   895         fn, opts, _syn = entry
       
   896     else:
       
   897         fn, opts, = entry
       
   898     deprecationwarning = _('%s have been deprecated in favor of %s\n' % (
       
   899         oldalias, newalias))
       
   900     def newfn(*args, **kwargs):
       
   901         ui = args[0]
       
   902         ui.warn(deprecationwarning)
       
   903         util.checksignature(fn)(*args, **kwargs)
       
   904     newfn.__doc__  = deprecationwarning
       
   905     cmdwrapper = command(oldalias, opts, synopsis)
       
   906     cmdwrapper(newfn)
       
   907 
   876 
   908 
   877 @command('debugrecordpruneparents', [], '')
   909 @command('debugrecordpruneparents', [], '')
   878 def cmddebugrecordpruneparents(ui, repo):
   910 def cmddebugrecordpruneparents(ui, repo):
   879     """add parents data to prune markers when possible
   911     """add parents data to prune markers when possible
   880 
   912