Mercurial > hg
changeset 15510:5414b56cfad6
patch: simplify hunk extents parsing
Do not capture unwanted groups in regexps
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Mon, 14 Nov 2011 18:16:01 +0100 |
parents | 7ee7b7426aad |
children | 646759147717 |
files | mercurial/patch.py |
diffstat | 1 files changed, 5 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/patch.py Thu Nov 17 15:44:37 2011 -0600 +++ b/mercurial/patch.py Mon Nov 14 18:16:01 2011 +0100 @@ -566,8 +566,8 @@ return self.changed | self.removed # @@ -start,len +start,len @@ or @@ -start +start @@ if len is 1 -unidesc = re.compile('@@ -(\d+)(,(\d+))? \+(\d+)(,(\d+))? @@') -contextdesc = re.compile('(---|\*\*\*) (\d+)(,(\d+))? (---|\*\*\*)') +unidesc = re.compile('@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@') +contextdesc = re.compile('(?:---|\*\*\*) (\d+)(?:,(\d+))? (?:---|\*\*\*)') eolmodes = ['strict', 'crlf', 'lf', 'auto'] class patchfile(object): @@ -830,7 +830,7 @@ m = unidesc.match(self.desc) if not m: raise PatchError(_("bad hunk #%d") % self.number) - self.starta, foo, self.lena, self.startb, foo2, self.lenb = m.groups() + self.starta, self.lena, self.startb, self.lenb = m.groups() if self.lena is None: self.lena = 1 else: @@ -857,7 +857,7 @@ m = contextdesc.match(self.desc) if not m: raise PatchError(_("bad hunk #%d") % self.number) - foo, self.starta, foo2, aend, foo3 = m.groups() + self.starta, aend = m.groups() self.starta = int(self.starta) if aend is None: aend = self.starta @@ -890,7 +890,7 @@ m = contextdesc.match(l) if not m: raise PatchError(_("bad hunk #%d") % self.number) - foo, self.startb, foo2, bend, foo3 = m.groups() + self.startb, bend = m.groups() self.startb = int(self.startb) if bend is None: bend = self.startb