comparison mercurial/util.py @ 1329:8f06817bf266

Allow files to be opened in text mode, even on Windows.
author Bryan O'Sullivan <bos@serpentine.com>
date Fri, 23 Sep 2005 10:28:55 -0700
parents b47f96a178a3
children 0f4e53e8c66b
comparison
equal deleted inserted replaced
1328:04ed65045bcc 1329:8f06817bf266
325 325
326 this function is used to hide the details of COW semantics and 326 this function is used to hide the details of COW semantics and
327 remote file access from higher level code. 327 remote file access from higher level code.
328 """ 328 """
329 p = base 329 p = base
330 def o(path, mode="r"): 330 def o(path, mode="r", text=False):
331 f = os.path.join(p, path) 331 f = os.path.join(p, path)
332 332
333 mode += "b" # for that other OS 333 if not text:
334 mode += "b" # for that other OS
334 335
335 if mode[0] != "r": 336 if mode[0] != "r":
336 try: 337 try:
337 nlink = nlinks(f) 338 nlink = nlinks(f)
338 except OSError: 339 except OSError:
547 def makedate(): 548 def makedate():
548 t = time.time() 549 t = time.time()
549 if time.daylight: tz = time.altzone 550 if time.daylight: tz = time.altzone
550 else: tz = time.timezone 551 else: tz = time.timezone
551 return t, tz 552 return t, tz
552 553
553 def datestr(date=None, format='%c'): 554 def datestr(date=None, format='%c'):
554 """represent a (unixtime, offset) tuple as a localized time. 555 """represent a (unixtime, offset) tuple as a localized time.
555 unixtime is seconds since the epoch, and offset is the time zone's 556 unixtime is seconds since the epoch, and offset is the time zone's
556 number of seconds away from UTC.""" 557 number of seconds away from UTC."""
557 t, tz = date or makedate() 558 t, tz = date or makedate()