hgext/record.py
changeset 10323 0aa59f532ef9
parent 10282 08a0f04b56bd
child 10694 d7732d2df54a
child 11235 113536751190
equal deleted inserted replaced
10322:d9a2bc2f776b 10323:0aa59f532ef9
   379       a - record all changes to all remaining files
   379       a - record all changes to all remaining files
   380       q - quit, recording no changes
   380       q - quit, recording no changes
   381 
   381 
   382       ? - display help'''
   382       ? - display help'''
   383 
   383 
   384     def record_committer(ui, repo, pats, opts):
   384     dorecord(ui, repo, commands.commit, *pats, **opts)
   385         commands.commit(ui, repo, *pats, **opts)
       
   386 
       
   387     dorecord(ui, repo, record_committer, *pats, **opts)
       
   388 
   385 
   389 
   386 
   390 def qrecord(ui, repo, patch, *pats, **opts):
   387 def qrecord(ui, repo, patch, *pats, **opts):
   391     '''interactively record a new patch
   388     '''interactively record a new patch
   392 
   389 
   397     try:
   394     try:
   398         mq = extensions.find('mq')
   395         mq = extensions.find('mq')
   399     except KeyError:
   396     except KeyError:
   400         raise util.Abort(_("'mq' extension not loaded"))
   397         raise util.Abort(_("'mq' extension not loaded"))
   401 
   398 
   402     def qrecord_committer(ui, repo, pats, opts):
   399     def committomq(ui, repo, *pats, **opts):
   403         mq.new(ui, repo, patch, *pats, **opts)
   400         mq.new(ui, repo, patch, *pats, **opts)
   404 
   401 
   405     opts = opts.copy()
   402     opts = opts.copy()
   406     opts['force'] = True    # always 'qnew -f'
   403     opts['force'] = True    # always 'qnew -f'
   407     dorecord(ui, repo, qrecord_committer, *pats, **opts)
   404     dorecord(ui, repo, committomq, *pats, **opts)
   408 
   405 
   409 
   406 
   410 def dorecord(ui, repo, committer, *pats, **opts):
   407 def dorecord(ui, repo, commitfunc, *pats, **opts):
   411     if not ui.interactive():
   408     if not ui.interactive():
   412         raise util.Abort(_('running non-interactively, use commit instead'))
   409         raise util.Abort(_('running non-interactively, use commit instead'))
   413 
   410 
   414     def recordfunc(ui, repo, message, match, opts):
   411     def recordfunc(ui, repo, message, match, opts):
   415         """This is generic record driver.
   412         """This is generic record driver.
   505             # it is important to first chdir to repo root -- we'll call a
   502             # it is important to first chdir to repo root -- we'll call a
   506             # highlevel command with list of pathnames relative to repo root
   503             # highlevel command with list of pathnames relative to repo root
   507             cwd = os.getcwd()
   504             cwd = os.getcwd()
   508             os.chdir(repo.root)
   505             os.chdir(repo.root)
   509             try:
   506             try:
   510                 committer(ui, repo, newfiles, opts)
   507                 commitfunc(ui, repo, *newfiles, **opts)
   511             finally:
   508             finally:
   512                 os.chdir(cwd)
   509                 os.chdir(cwd)
   513 
   510 
   514             return 0
   511             return 0
   515         finally:
   512         finally: