hgext/shelve.py
changeset 27888 6c740218215d
parent 27841 83995fdde225
child 27908 d73a5ab18015
equal deleted inserted replaced
27887:a30b582b8be4 27888:6c740218215d
   262     def gennames():
   262     def gennames():
   263         yield label
   263         yield label
   264         for i in xrange(1, 100):
   264         for i in xrange(1, 100):
   265             yield '%s-%02d' % (label, i)
   265             yield '%s-%02d' % (label, i)
   266 
   266 
   267     def commitfunc(ui, repo, message, match, opts):
       
   268         hasmq = util.safehasattr(repo, 'mq')
       
   269         if hasmq:
       
   270             saved, repo.mq.checkapplied = repo.mq.checkapplied, False
       
   271         backup = repo.ui.backupconfig('phases', 'new-commit')
       
   272         try:
       
   273             repo.ui. setconfig('phases', 'new-commit', phases.secret)
       
   274             editor = cmdutil.getcommiteditor(editform='shelve.shelve', **opts)
       
   275             return repo.commit(message, user, opts.get('date'), match,
       
   276                                editor=editor)
       
   277         finally:
       
   278             repo.ui.restoreconfig(backup)
       
   279             if hasmq:
       
   280                 repo.mq.checkapplied = saved
       
   281 
       
   282     if parent.node() != nullid:
   267     if parent.node() != nullid:
   283         desc = "changes to: %s" % parent.description().split('\n', 1)[0]
   268         desc = "changes to: %s" % parent.description().split('\n', 1)[0]
   284     else:
   269     else:
   285         desc = '(changes in empty repository)'
   270         desc = '(changes in empty repository)'
   286 
   271 
   314         if '/' in name or '\\' in name:
   299         if '/' in name or '\\' in name:
   315             raise error.Abort(_('shelved change names may not contain slashes'))
   300             raise error.Abort(_('shelved change names may not contain slashes'))
   316         if name.startswith('.'):
   301         if name.startswith('.'):
   317             raise error.Abort(_("shelved change names may not start with '.'"))
   302             raise error.Abort(_("shelved change names may not start with '.'"))
   318         interactive = opts.get('interactive', False)
   303         interactive = opts.get('interactive', False)
       
   304 
       
   305         def commitfunc(ui, repo, message, match, opts):
       
   306             hasmq = util.safehasattr(repo, 'mq')
       
   307             if hasmq:
       
   308                 saved, repo.mq.checkapplied = repo.mq.checkapplied, False
       
   309             backup = repo.ui.backupconfig('phases', 'new-commit')
       
   310             try:
       
   311                 repo.ui. setconfig('phases', 'new-commit', phases.secret)
       
   312                 editor = cmdutil.getcommiteditor(editform='shelve.shelve',
       
   313                                                  **opts)
       
   314                 return repo.commit(message, user, opts.get('date'), match,
       
   315                                    editor=editor)
       
   316             finally:
       
   317                 repo.ui.restoreconfig(backup)
       
   318                 if hasmq:
       
   319                     repo.mq.checkapplied = saved
   319 
   320 
   320         def interactivecommitfunc(ui, repo, *pats, **opts):
   321         def interactivecommitfunc(ui, repo, *pats, **opts):
   321             match = scmutil.match(repo['.'], pats, {})
   322             match = scmutil.match(repo['.'], pats, {})
   322             message = opts['message']
   323             message = opts['message']
   323             return commitfunc(ui, repo, message, match, opts)
   324             return commitfunc(ui, repo, message, match, opts)