hgkw/keyword.py
branch0.9.2compat
changeset 639 d41074cb161b
parent 630 d0185236a089
child 640 7e80fc29ba27
equal deleted inserted replaced
638:439e096ce144 639:d41074cb161b
    88 
    88 
    89 from mercurial import commands, cmdutil, fancyopts, filelog
    89 from mercurial import commands, cmdutil, fancyopts, filelog
    90 from mercurial import localrepo, patch, revlog, templater, util
    90 from mercurial import localrepo, patch, revlog, templater, util
    91 from mercurial.node import nullid, hex
    91 from mercurial.node import nullid, hex
    92 from mercurial.i18n import gettext as _
    92 from mercurial.i18n import gettext as _
    93 import getopt, os, re, shutil, tempfile, time
    93 import getopt, os, re, shutil, tempfile
    94 
    94 
    95 commands.optionalrepo += ' kwdemo'
    95 commands.optionalrepo += ' kwdemo'
    96 
    96 
    97 # hg commands that do not act on keywords
    97 # hg commands that do not act on keywords
    98 nokwcommands = ('add addremove annotate bundle copy export grep incoming init'
    98 nokwcommands = ('add addremove annotate bundle copy export grep incoming init'
   101 
   101 
   102 # hg commands that trigger expansion only when writing to working dir,
   102 # hg commands that trigger expansion only when writing to working dir,
   103 # not when reading filelog, and unexpand when reading from working dir
   103 # not when reading filelog, and unexpand when reading from working dir
   104 restricted = 'merge record resolve qfold qimport qnew qpush qrefresh qrecord'
   104 restricted = 'merge record resolve qfold qimport qnew qpush qrefresh qrecord'
   105 
   105 
       
   106 # provide cvs-like UTC date filter
   106 def utcdate(date):
   107 def utcdate(date):
   107     '''Returns hgdate in cvs-like UTC format.'''
   108     try:
   108     return time.strftime('%Y/%m/%d %H:%M:%S', time.gmtime(date[0]))
   109         return util.datestr(date, '%Y/%m/%d %H:%M:%S', False)
       
   110     except TypeError:
       
   111         return util.datestr(date, '%Y/%m/%d %H:%M:%S')
   109 
   112 
   110 def textsafe(s):
   113 def textsafe(s):
   111     '''Safe version of util.binary with reversed logic.
   114     '''Safe version of util.binary with reversed logic.
   112     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.'''
   113     return '\0' not in s
   116     return '\0' not in s