hgkw/keyword.py
changeset 250 b28a2832cba4
parent 248 2c222367dab3
child 251 b37f2f065a9c
equal deleted inserted replaced
249:8df281c5ca8b 250:b28a2832cba4
    78 Caveat: "hg import" fails if the patch context contains an active
    78 Caveat: "hg import" fails if the patch context contains an active
    79         keyword. In that case run "hg kwshrink", and then reimport.
    79         keyword. In that case run "hg kwshrink", and then reimport.
    80         Or, better, use bundle/unbundle to share changes.
    80         Or, better, use bundle/unbundle to share changes.
    81 '''
    81 '''
    82 
    82 
    83 from mercurial import commands, cmdutil, context, fancyopts, filelog
    83 from mercurial import commands, cmdutil, context, fancyopts
    84 from mercurial import localrepo, revlog, templater, util, hg
    84 from mercurial import filelog, localrepo, revlog, templater, util
    85 from mercurial.i18n import gettext as _
    85 from mercurial.i18n import gettext as _
    86 import getopt, re, shutil, sys, tempfile, time
    86 import getopt, re, shutil, sys, tempfile, time
    87 
    87 
    88 # backwards compatibility hacks
    88 # backwards compatibility hacks
    89 
    89 
   324     try:
   324     try:
   325         wlock = repo.wlock()
   325         wlock = repo.wlock()
   326         lock = repo.lock()
   326         lock = repo.lock()
   327         bail_if_changed(repo)
   327         bail_if_changed(repo)
   328         ctx = repo.changectx()
   328         ctx = repo.changectx()
   329         if not ctx:
       
   330             raise hg.RepoError(_('no revision checked out'))
       
   331         kwfmatcher = _keywordmatcher(ui, repo)
   329         kwfmatcher = _keywordmatcher(ui, repo)
   332         if kwfmatcher is None:
   330         if kwfmatcher is None:
   333             ui.warn(_('no files configured for keyword expansion\n'))
   331             ui.warn(_('no files configured for keyword expansion\n'))
   334             return
   332             return
   335         man = ctx.manifest()
   333         man = ctx.manifest()
   336         if files:
   334         if files:
   337             cwd = repo.getcwd()
   335             cwd = repo.getcwd()
   338             files = [util.canonpath(repo.root, cwd, f) for f in files]
   336             files = [util.canonpath(repo.root, cwd, f) for f in files]
   339         files = _weedcandidates(man, kwfmatcher, files)
   337         files = _weedcandidates(man, kwfmatcher, files)
   340         if not files:
   338         if files:
   341             ui.warn(_('files not configured for expansion or untracked\n'))
   339             kwt = kwtemplater(ui, repo, expand, node=ctx.node())
   342             return
   340             # 3rd argument sets commit to False
   343         kwt = kwtemplater(ui, repo, expand, node=ctx.node())
   341             kwt.overwrite(files, man, False)
   344         # 3rd argument sets commit to False
       
   345         kwt.overwrite(files, man, False)
       
   346     finally:
   342     finally:
   347         del wlock, lock
   343         del wlock, lock
   348 
   344 
   349 
   345 
   350 def shrink(ui, repo, *args):
   346 def shrink(ui, repo, *args):