[Svnmerge] [PATCH] Bidirectional patch take 2
Blair Zajac
blair at orcaware.com
Thu Feb 23 22:28:29 PST 2006
Raman Gupta wrote:
> Blair Zajac wrote:
>
>>+ for line in lines:
>>+ match = find_revision_re.match(line)
>>+ if match:
>>+ rev = match.groups()[0]
>>+ current_rev = int(rev)
>>+ revs.append(rev)
>>+ continue
>>+
>>+ if not current_rev:
>>+ continue
>>+
>>+ if source_dir_modified_re.match(line):
>>+ potential_reflected_revs.append(current_rev)
>
>
> Minor optimization to prevent the regular expression from evaluating for
> each line of the log output *after* the revision has already been
> identified as a potential (of course this version has to run the
> contains operation for each rev, but I still think it will be slightly
> faster most of the time):
>
> if current_rev not in potential_reflected_revs \
> and source_dir_modified_re.match(line):
Good catch. I've simplified it further to use a boolean flag instead of the
'in' operator:
find_revision_re = re.compile(r"^r(\d+)")
source_dir_modified_re = re.compile(r"\s*M\s+%s\s+$" % re.escape(rlpath))
source_dir_modified = False
for line in lines:
find_revision_match = find_revision_re.match(line)
if find_revision_match:
rev = find_revision_match.groups()[0]
current_rev = int(rev)
revs.append(rev)
source_dir_modified = False
continue
if not current_rev:
continue
if not source_dir_modified and source_dir_modified_re.match(line):
source_dir_modified = True
potential_reflected_revs.append(current_rev)
Regards,
Blair
More information about the Svnmerge
mailing list