/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to parser.py

tweak parser for better git-fast-export compatibility

Show diffs side-by-side

added added

removed removed

Lines of Context:
243
243
        raise NotImplementedError(self.read_until)
244
244
 
245
245
 
246
 
# Regular expressions used for parsing
247
 
_WHO_AND_WHEN_RE = re.compile(r'(\w+) <(.+)> (.+)')
 
246
# Regular expression used for parsing. (Note: The spec states that the name
 
247
# part should be non-empty but git-fast-export doesn't always do that so
 
248
# the first bit is \w*, not \w+.)
 
249
_WHO_AND_WHEN_RE = re.compile(r'(\w*) <(.+)> (.+)')
248
250
 
249
251
 
250
252
class ImportParser(LineBasedParser):
432
434
    def _who_when(self, s, cmd, section):
433
435
        """Parse who and when information from a string.
434
436
        
435
 
        :return: a tuple of (who,email,when) where who and
436
 
          email are strings and when is a datetime object
 
437
        :return: a tuple of (name,email,timestamp,timezone)
437
438
        """
438
439
        match = _WHO_AND_WHEN_RE.search(s)
439
440
        if match:
440
441
            datestr = match.group(3)
441
442
            if self.date_parser is None:
442
443
                # auto-detect the date format
443
 
                if len(datestr) == 16:
 
444
                if len(datestr.split(' ')) == 2:
444
445
                    format = 'raw'
445
446
                elif datestr == 'now':
446
447
                    format = 'now'
448
449
                    format = 'rfc2822'
449
450
                self.date_parser = dates.DATE_PARSERS_BY_NAME[format]
450
451
            when = self.date_parser(datestr)
451
 
            return (match.group(1), match.group(2), when)
 
452
            return (match.group(1),match.group(2),when[0],when[1])
452
453
        else:
453
454
            self.abort(errors.BadFormat, cmd, section, s)
454
455
 
472
473
            return False, False
473
474
        elif s in ['755', '100755', '0100755']:
474
475
            return True, False
475
 
        elif s == '120000':
 
476
        elif s in ['120000', '0120000']:
476
477
            return False, True
477
478
        else:
478
479
            self.abort(errors.BadFormat, 'filemodify', 'mode', s)