hgkw/keyword.py
branch0.9.2compat
changeset 678 5684a76da263
parent 673 b94f7991f06b
child 689 c23ba1aef69d
equal deleted inserted replaced
673:b94f7991f06b 678:5684a76da263
    90 
    90 
    91 from mercurial import commands, cmdutil, fancyopts, filelog
    91 from mercurial import commands, cmdutil, fancyopts, filelog
    92 from mercurial import localrepo, patch, revlog, templater, util
    92 from mercurial import localrepo, patch, revlog, templater, util
    93 from mercurial.node import nullid, hex
    93 from mercurial.node import nullid, hex
    94 from mercurial.i18n import gettext as _
    94 from mercurial.i18n import gettext as _
    95 import getopt, os, re, shutil, tempfile
    95 import getopt, os, re, shutil, tempfile, time
    96 
    96 
    97 commands.optionalrepo += ' kwdemo'
    97 commands.optionalrepo += ' kwdemo'
    98 
    98 
    99 # hg commands that do not act on keywords
    99 # hg commands that do not act on keywords
   100 nokwcommands = ('add addremove annotate bundle copy export grep incoming init'
   100 nokwcommands = ('add addremove annotate bundle copy export grep incoming init'
   105 # not when reading filelog, and unexpand when reading from working dir
   105 # not when reading filelog, and unexpand when reading from working dir
   106 restricted = ('merge record resolve qfold qimport qnew qpush qrefresh qrecord'
   106 restricted = ('merge record resolve qfold qimport qnew qpush qrefresh qrecord'
   107               ' transplant')
   107               ' transplant')
   108 
   108 
   109 # provide cvs-like UTC date filter
   109 # provide cvs-like UTC date filter
   110 def utcdate(date):
   110 utcdate = lambda x: time.strftime('%Y/%m/%d %H:%M:%S',
   111     try:
   111                                   time.gmtime(float(x[0])))
   112         return util.datestr(date, '%Y/%m/%d %H:%M:%S', False)
       
   113     except TypeError:
       
   114         return util.datestr(date, '%Y/%m/%d %H:%M:%S')
       
   115 
   112 
   116 def textsafe(s):
   113 def textsafe(s):
   117     '''Safe version of util.binary with reversed logic.
   114     '''Safe version of util.binary with reversed logic.
   118     Note: argument may not be None, which is allowed for util.binary.'''
   115     Note: argument may not be None, which is allowed for util.binary.'''
   119     return '\0' not in s
   116     return '\0' not in s