equal
deleted
inserted
replaced
422 def close(self): |
422 def close(self): |
423 if self.fp: |
423 if self.fp: |
424 self.fp.close() |
424 self.fp.close() |
425 self.fp = None |
425 self.fp = None |
426 |
426 |
427 def parsesplicemap(path): |
|
428 """Parse a splicemap, return a child/parents dictionary.""" |
|
429 if not path: |
|
430 return {} |
|
431 m = {} |
|
432 try: |
|
433 fp = open(path, 'r') |
|
434 for i, line in enumerate(fp): |
|
435 line = line.splitlines()[0].rstrip() |
|
436 if not line: |
|
437 # Ignore blank lines |
|
438 continue |
|
439 try: |
|
440 child, parents = line.split(' ', 1) |
|
441 parents = parents.replace(',', ' ').split() |
|
442 except ValueError: |
|
443 raise util.Abort(_('syntax error in %s(%d): child parent1' |
|
444 '[,parent2] expected') % (path, i + 1)) |
|
445 pp = [] |
|
446 for p in parents: |
|
447 if p not in pp: |
|
448 pp.append(p) |
|
449 m[child] = pp |
|
450 except IOError, e: |
|
451 if e.errno != errno.ENOENT: |
|
452 raise |
|
453 return m |
|
454 |
|
455 def makedatetimestamp(t): |
427 def makedatetimestamp(t): |
456 """Like util.makedate() but for time t instead of current time""" |
428 """Like util.makedate() but for time t instead of current time""" |
457 delta = (datetime.datetime.utcfromtimestamp(t) - |
429 delta = (datetime.datetime.utcfromtimestamp(t) - |
458 datetime.datetime.fromtimestamp(t)) |
430 datetime.datetime.fromtimestamp(t)) |
459 tz = delta.days * 86400 + delta.seconds |
431 tz = delta.days * 86400 + delta.seconds |