# HG changeset patch # User Patrick Mezard # Date 1321290961 -3600 # Node ID 5414b56cfad648a0e06ca5f6252f43f69cad264a # Parent 7ee7b7426aad050b0989a786568c2a87cb74b1d7 patch: simplify hunk extents parsing Do not capture unwanted groups in regexps diff -r 7ee7b7426aad -r 5414b56cfad6 mercurial/patch.py --- 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