/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

  • Committer: James Westby
  • Date: 2008-03-09 18:09:13 UTC
  • mto: (0.64.56 fastimport_trunk)
  • mto: This revision was merged to the branch mainline in revision 6631.
  • Revision ID: jw+debian@jameswestby.net-20080309180913-3kk2mg0fwpv1waqu
Make the parser handle multiple words in the committer name.

Also improve the coverage of the parser tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
252
252
# part should be non-empty but git-fast-export doesn't always do that so
253
253
# the first bit is \w*, not \w+.) Also git-fast-import code says the
254
254
# space before the email is optional.
255
 
_WHO_AND_WHEN_RE = re.compile(r'(\w*) ?<(.+)> (.+)')
 
255
_WHO_AND_WHEN_RE = re.compile(r'([^<]*)<(.+)> (.+)')
256
256
 
257
257
 
258
258
class ImportParser(LineBasedParser):
440
440
                next = self.input.readline()
441
441
                self.lineno += 1
442
442
                if len(next) > 1 or next != "\n":
443
 
                    self.push_line(next)
 
443
                    self.push_line(next[:-1])
444
444
                return read_bytes
445
445
        else:
446
446
            self.abort(errors.MissingSection, required_for, section)
448
448
    def _who_when(self, s, cmd, section):
449
449
        """Parse who and when information from a string.
450
450
        
451
 
        :return: a tuple of (name,email,timestamp,timezone)
 
451
        :return: a tuple of (name,email,timestamp,timezone). name may be
 
452
            the empty string if only an email address was given.
452
453
        """
453
454
        match = _WHO_AND_WHEN_RE.search(s)
454
455
        if match:
463
464
                    format = 'rfc2822'
464
465
                self.date_parser = dates.DATE_PARSERS_BY_NAME[format]
465
466
            when = self.date_parser(datestr)
466
 
            return (match.group(1),match.group(2),when[0],when[1])
 
467
            name = match.group(1)
 
468
            if len(name) > 0:
 
469
                if name[-1] == " ":
 
470
                    name = name[:-1]
 
471
            return (name,match.group(2),when[0],when[1])
467
472
        else:
468
473
            self.abort(errors.BadFormat, cmd, section, s)
469
474