hgkw/keyword.py
changeset 278 232df68a0bcc
parent 277 c848b8e3089a
child 280 2088e409d360
equal deleted inserted replaced
277:c848b8e3089a 278:232df68a0bcc
   102     # bail_if_changed moves from commands to cmdutil in 0c61124ad877
   102     # bail_if_changed moves from commands to cmdutil in 0c61124ad877
   103     bail_if_changed = cmdutil.bail_if_changed
   103     bail_if_changed = cmdutil.bail_if_changed
   104 except AttributeError:
   104 except AttributeError:
   105     bail_if_changed = commands.bail_if_changed
   105     bail_if_changed = commands.bail_if_changed
   106 
   106 
   107 def _pathto(repo, cwd, f):
   107 def _pathto(repo, f, cwd=None):
   108     '''kwfiles behaves similar to status, using pathto since 78b6add1f966.'''
   108     '''kwfiles behaves similar to status, using pathto since 78b6add1f966.'''
   109     try:
   109     try:
       
   110         if cwd is None:
       
   111             cwd = repo.getcwd()
   110         return repo.pathto(f, cwd)
   112         return repo.pathto(f, cwd)
   111     except AttributeError:
   113     except AttributeError:
   112         return f
   114         return f
   113 
   115 
   114 # commands.parse/cmdutil.parse returned nothing for
   116 # commands.parse/cmdutil.parse returned nothing for
   348                         files.append(ff)
   350                         files.append(ff)
   349                     del fdict[ff]
   351                     del fdict[ff]
   350                     break
   352                     break
   351             if not f in files and match(f) and _iskwfile(ui, man, f):
   353             if not f in files and match(f) and _iskwfile(ui, man, f):
   352                 files.append(f)
   354                 files.append(f)
   353         if fdict:
   355         ffiles = fdict.keys()
   354             ffiles = fdict.keys()
   356         ffiles.sort()
   355             ffiles.sort()
   357         for f in ffiles:
   356             cwd = repo.getcwd()
   358             ui.warn(_('%s: No such file in working copy\n') % _pathto(repo, f))
   357             for f in ffiles:
       
   358                 ui.warn(_('%s: No such file in working copy\n')
       
   359                         % _pathto(repo, cwd, f))
       
   360         # 7th argument sets commit to False
   359         # 7th argument sets commit to False
   361         _overwrite(ui, repo, files, ctx.node(), man, expand, False)
   360         _overwrite(ui, repo, files, ctx.node(), man, expand, False)
   362     finally:
   361     finally:
   363         del wlock, lock
   362         del wlock, lock
   364 
   363 
   404     ignore = opts['ignore']
   403     ignore = opts['ignore']
   405     flag = (allf or ui.verbose) and 1 or 0
   404     flag = (allf or ui.verbose) and 1 or 0
   406     if not ignore:
   405     if not ignore:
   407         format = ('%s\n', 'K %s\n')[flag]
   406         format = ('%s\n', 'K %s\n')[flag]
   408         for k in kwfiles:
   407         for k in kwfiles:
   409             ui.write(format % _pathto(repo, cwd, k))
   408             ui.write(format % _pathto(repo, k, cwd))
   410     if allf or ignore:
   409     if allf or ignore:
   411         format = ('%s\n', 'I %s\n')[flag]
   410         format = ('%s\n', 'I %s\n')[flag]
   412         for i in [f for f in files if f not in kwfiles]:
   411         for i in [f for f in files if f not in kwfiles]:
   413             ui.write(format % _pathto(repo, cwd, i))
   412             ui.write(format % _pathto(repo, i, cwd))
   414 
   413 
   415 def demo(ui, repo, *args, **opts):
   414 def demo(ui, repo, *args, **opts):
   416     '''print [keywordmaps] configuration and an expansion example
   415     '''print [keywordmaps] configuration and an expansion example
   417 
   416 
   418     Show current, custom, or default keyword template maps
   417     Show current, custom, or default keyword template maps