comparison mercurial/util.py @ 15513:646759147717

merge with stable
author Matt Mackall <mpm@selenic.com>
date Thu, 17 Nov 2011 16:53:17 -0600
parents 25ea33fe7e5c ae04af1ce78d
children ec8a49c46d7e
comparison
equal deleted inserted replaced
15510:5414b56cfad6 15513:646759147717
14 """ 14 """
15 15
16 from i18n import _ 16 from i18n import _
17 import error, osutil, encoding 17 import error, osutil, encoding
18 import errno, re, shutil, sys, tempfile, traceback 18 import errno, re, shutil, sys, tempfile, traceback
19 import os, time, calendar, textwrap, signal 19 import os, time, datetime, calendar, textwrap, signal
20 import imp, socket, urllib 20 import imp, socket, urllib
21 21
22 if os.name == 'nt': 22 if os.name == 'nt':
23 import windows as platform 23 import windows as platform
24 else: 24 else:
898 if limit: 898 if limit:
899 limit -= len(s) 899 limit -= len(s)
900 yield s 900 yield s
901 901
902 def makedate(): 902 def makedate():
903 lt = time.localtime() 903 ct = time.time()
904 if lt[8] == 1 and time.daylight: 904 if ct < 0:
905 tz = time.altzone
906 else:
907 tz = time.timezone
908 t = time.mktime(lt)
909 if t < 0:
910 hint = _("check your clock") 905 hint = _("check your clock")
911 raise Abort(_("negative timestamp: %d") % t, hint=hint) 906 raise Abort(_("negative timestamp: %d") % ct, hint=hint)
912 return t, tz 907 delta = (datetime.datetime.utcfromtimestamp(ct) -
908 datetime.datetime.fromtimestamp(ct))
909 tz = delta.days * 86400 + delta.seconds
910 return ct, tz
913 911
914 def datestr(date=None, format='%a %b %d %H:%M:%S %Y %1%2'): 912 def datestr(date=None, format='%a %b %d %H:%M:%S %Y %1%2'):
915 """represent a (unixtime, offset) tuple as a localized time. 913 """represent a (unixtime, offset) tuple as a localized time.
916 unixtime is seconds since the epoch, and offset is the time zone's 914 unixtime is seconds since the epoch, and offset is the time zone's
917 number of seconds away from UTC. if timezone is false, do not 915 number of seconds away from UTC. if timezone is false, do not
1706 path = self.path or '/' 1704 path = self.path or '/'
1707 # For Windows, we need to promote hosts containing drive 1705 # For Windows, we need to promote hosts containing drive
1708 # letters to paths with drive letters. 1706 # letters to paths with drive letters.
1709 if hasdriveletter(self._hostport): 1707 if hasdriveletter(self._hostport):
1710 path = self._hostport + '/' + self.path 1708 path = self._hostport + '/' + self.path
1711 elif self.host is not None and self.path: 1709 elif (self.host is not None and self.path
1710 and not hasdriveletter(path)):
1712 path = '/' + path 1711 path = '/' + path
1713 return path 1712 return path
1714 return self._origpath 1713 return self._origpath
1715 1714
1716 def hasscheme(path): 1715 def hasscheme(path):