mercurial/util.py
changeset 26311 60dd8e3977f0
parent 26267 eca468b8fae4
child 26392 127b59787fd5
equal deleted inserted replaced
26310:61efe9ef6ad4 26311:60dd8e3977f0
   728 def _sethgexecutable(path):
   728 def _sethgexecutable(path):
   729     """set location of the 'hg' executable"""
   729     """set location of the 'hg' executable"""
   730     global _hgexecutable
   730     global _hgexecutable
   731     _hgexecutable = path
   731     _hgexecutable = path
   732 
   732 
   733 def system(cmd, environ={}, cwd=None, onerr=None, errprefix=None, out=None):
   733 def system(cmd, environ=None, cwd=None, onerr=None, errprefix=None, out=None):
   734     '''enhanced shell command execution.
   734     '''enhanced shell command execution.
   735     run with environment maybe modified, maybe in different dir.
   735     run with environment maybe modified, maybe in different dir.
   736 
   736 
   737     if command fails and onerr is None, return status, else raise onerr
   737     if command fails and onerr is None, return status, else raise onerr
   738     object as exception.
   738     object as exception.
   739 
   739 
   740     if out is specified, it is assumed to be a file-like object that has a
   740     if out is specified, it is assumed to be a file-like object that has a
   741     write() method. stdout and stderr will be redirected to out.'''
   741     write() method. stdout and stderr will be redirected to out.'''
       
   742     if environ is None:
       
   743         environ = {}
   742     try:
   744     try:
   743         sys.stdout.flush()
   745         sys.stdout.flush()
   744     except Exception:
   746     except Exception:
   745         pass
   747         pass
   746     def py2shell(val):
   748     def py2shell(val):
  1412         offset = unixtime - localunixtime
  1414         offset = unixtime - localunixtime
  1413     else:
  1415     else:
  1414         unixtime = localunixtime + offset
  1416         unixtime = localunixtime + offset
  1415     return unixtime, offset
  1417     return unixtime, offset
  1416 
  1418 
  1417 def parsedate(date, formats=None, bias={}):
  1419 def parsedate(date, formats=None, bias=None):
  1418     """parse a localized date/time and return a (unixtime, offset) tuple.
  1420     """parse a localized date/time and return a (unixtime, offset) tuple.
  1419 
  1421 
  1420     The date may be a "unixtime offset" string or in one of the specified
  1422     The date may be a "unixtime offset" string or in one of the specified
  1421     formats. If the date already is a (unixtime, offset) tuple, it is returned.
  1423     formats. If the date already is a (unixtime, offset) tuple, it is returned.
  1422 
  1424 
  1432     >>> (strnow - now) < 1
  1434     >>> (strnow - now) < 1
  1433     True
  1435     True
  1434     >>> tz == strtz
  1436     >>> tz == strtz
  1435     True
  1437     True
  1436     """
  1438     """
       
  1439     if bias is None:
       
  1440         bias = {}
  1437     if not date:
  1441     if not date:
  1438         return 0, 0
  1442         return 0, 0
  1439     if isinstance(date, tuple) and len(date) == 2:
  1443     if isinstance(date, tuple) and len(date) == 2:
  1440         return date
  1444         return date
  1441     if not formats:
  1445     if not formats: