hgext/mq.py
changeset 7157 fd3cba5e73ae
parent 7142 88f1b8081f1c
child 7158 d1d011accf94
equal deleted inserted replaced
7153:353141d74ca8 7157:fd3cba5e73ae
   639             or name.startswith('.mq')):
   639             or name.startswith('.mq')):
   640             raise util.Abort(_('"%s" cannot be used as the name of a patch')
   640             raise util.Abort(_('"%s" cannot be used as the name of a patch')
   641                              % name)
   641                              % name)
   642 
   642 
   643     def new(self, repo, patch, *pats, **opts):
   643     def new(self, repo, patch, *pats, **opts):
       
   644         """options:
       
   645            msg: a string or a no-argument function returning a string
       
   646         """
   644         msg = opts.get('msg')
   647         msg = opts.get('msg')
   645         force = opts.get('force')
   648         force = opts.get('force')
   646         user = opts.get('user')
   649         user = opts.get('user')
   647         date = opts.get('date')
   650         date = opts.get('date')
   648         if date:
   651         if date:
   659         commitfiles = m + a + r
   662         commitfiles = m + a + r
   660         self.check_toppatch(repo)
   663         self.check_toppatch(repo)
   661         wlock = repo.wlock()
   664         wlock = repo.wlock()
   662         try:
   665         try:
   663             insert = self.full_series_end()
   666             insert = self.full_series_end()
       
   667             if callable(msg):
       
   668                 msg = msg()
   664             commitmsg = msg and msg or ("[mq]: %s" % patch)
   669             commitmsg = msg and msg or ("[mq]: %s" % patch)
   665             n = repo.commit(commitfiles, commitmsg, user, date, match=match, force=True)
   670             n = repo.commit(commitfiles, commitmsg, user, date, match=match, force=True)
   666             if n == None:
   671             if n == None:
   667                 raise util.Abort(_("repo commit failed"))
   672                 raise util.Abort(_("repo commit failed"))
   668             self.full_series[insert:insert] = [patch]
   673             self.full_series[insert:insert] = [patch]
  1733     to the new patch, leaving the rest as uncommitted modifications.
  1738     to the new patch, leaving the rest as uncommitted modifications.
  1734 
  1739 
  1735     -e, -m or -l set the patch header as well as the commit message.
  1740     -e, -m or -l set the patch header as well as the commit message.
  1736     If none is specified, the patch header is empty and the
  1741     If none is specified, the patch header is empty and the
  1737     commit message is '[mq]: PATCH'"""
  1742     commit message is '[mq]: PATCH'"""
       
  1743     msg = cmdutil.logmessage(opts)
       
  1744     def getmsg(): return ui.edit(msg, ui.username())
  1738     q = repo.mq
  1745     q = repo.mq
  1739     message = cmdutil.logmessage(opts)
  1746     opts['msg'] = msg
  1740     if opts['edit']:
  1747     if opts.get('edit'):
  1741         message = ui.edit(message, ui.username())
  1748         opts['msg'] = getmsg
  1742     opts['msg'] = message
  1749     else:
       
  1750         opts['msg'] = msg
  1743     setupheaderopts(ui, opts)
  1751     setupheaderopts(ui, opts)
  1744     q.new(repo, patch, *args, **opts)
  1752     q.new(repo, patch, *args, **opts)
  1745     q.save_dirty()
  1753     q.save_dirty()
  1746     return 0
  1754     return 0
  1747 
  1755