Changeset 1416 in tailor for vcpx/repository/darcs/source.py


Ignore:
Timestamp:
07/01/07 21:11:51 (6 years ago)
Author:
lele@…
Hash name:
20070701191151-97f81-1a1ae73ef1f18fddd73b9a1e12f1ba239ebadf27
Message:

Yet another way to fix a silly problem
Now the timestamp is splitted on chars/colons, and the first 7 fields
are used to build the datetime object. The remaining part is the
author.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vcpx/repository/darcs/source.py

    r1415 r1416  
    303303            ##   * Refix _getUpstreamChangesets for darcs 
    304304 
     305            fsep = re.compile('[ :]+') 
    305306            l = output.readline() 
    306307            while not l.startswith('Making no changes:  this is a dry run.'): 
    307308                # Assume it's a line like 
    308309                #    Sun Jan  2 00:24:04 UTC 2005  lele@nautilus.homeip.net 
    309                 # we used to split on the double space before the email, 
    310                 # but in this case this is wrong. Then we assumed the date 
    311                 # part to be exactly 28 chars long, but what about timezone 
    312                 # names like 'CEST'? Waiting for xml output... 
    313                 # We still assume there are *two* spaces before the email. 
    314                 # The alternative is using some sort of a regex: Aaron Kaplan 
    315                 # kindly suggested his own perl snippet 
    316                 #    /^(... ... .\d .\d:\d\d:\d\d ...?. \d\d\d\d)  (.*)/ || die; 
    317                 #    my ($date, $author) = ($1, $2); 
    318                 # but that assumes the two spaces as separator, so I find the 
    319                 # following solution easier and by any chance faster too. 
    320                 pieces = l.rstrip().split('  ') 
    321                 assert len(pieces)>1, "Cannot parse %r as a patch timestamp" % l 
    322  
    323                 # Even the author part may contain double spaces: so 
    324                 # join the date and time with a single space, and the 
    325                 # remaining pieces with a double space. 
    326                 date = ' '.join(pieces[:2]) 
    327                 author = '  '.join(pieces[2:]) 
    328                 y,m,d,hh,mm,ss,d1,d2,d3 = strptime(date, "%a %b %d %H:%M:%S %Z %Y") 
     310                # Use a regular expression matching multiple spaces or colons 
     311                # to split it, and use the first 7 fields to build up a datetime. 
     312                pieces = fsep.split(l.rstrip(), 8) 
     313                assert len(pieces)>=7, "Cannot parse %r as a patch timestamp" % l 
     314                date = ' '.join(pieces[:8]) 
     315                author = pieces[8] 
     316                y,m,d,hh,mm,ss,d1,d2,d3 = strptime(date, "%a %b %d %H %M %S %Z %Y") 
    329317                date = datetime(y,m,d,hh,mm,ss,0,UTC) 
    330318                l = output.readline().rstrip() 
Note: See TracChangeset for help on using the changeset viewer.