1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-10 00:42:40 +01:00

Use the '(?P<' syntax instead of '(?<' for capturing named subgroups.

This commit is contained in:
epriestley 2011-02-09 09:12:21 -08:00
parent 4b51720ba1
commit 6082b89eb4

View file

@ -176,18 +176,18 @@ class ArcanistDiffParser {
do { do {
$patterns = array( $patterns = array(
// This is a normal SVN text change, probably from "svn diff". // This is a normal SVN text change, probably from "svn diff".
'(?<type>Index): (?<cur>.+)', '(?P<type>Index): (?P<cur>.+)',
// This is an SVN property change, probably from "svn diff". // This is an SVN property change, probably from "svn diff".
'(?<type>Property changes on): (?<cur>.+)', '(?P<type>Property changes on): (?P<cur>.+)',
// This is a git commit message, probably from "git show". // This is a git commit message, probably from "git show".
'(?<type>commit) (?<hash>[a-f0-9]+)', '(?P<type>commit) (?P<hash>[a-f0-9]+)',
// This is a git diff, probably from "git show" or "git diff". // This is a git diff, probably from "git show" or "git diff".
'(?<type>diff --git) a/(?<old>.+) b/(?<cur>.+)', '(?P<type>diff --git) a/(?P<old>.+) b/(?P<cur>.+)',
// This is a unified diff, probably from "diff -u" or synthetic diffing. // This is a unified diff, probably from "diff -u" or synthetic diffing.
'(?<type>---) (?<old>.+)\s+\d{4}-\d{2}-\d{2}.*', '(?P<type>---) (?P<old>.+)\s+\d{4}-\d{2}-\d{2}.*',
'(?<binary>Binary) files '. '(?P<binary>Binary) files '.
'(?<old>.+)\s+\d{4}-\d{2}-\d{2} and '. '(?P<old>.+)\s+\d{4}-\d{2}-\d{2} and '.
'(?<new>.+)\s+\d{4}-\d{2}-\d{2} differ.*', '(?P<new>.+)\s+\d{4}-\d{2}-\d{2} differ.*',
); );
$ok = false; $ok = false;
@ -419,17 +419,17 @@ class ArcanistDiffParser {
do { do {
$patterns = array( $patterns = array(
'(?<new>new) file mode (?<newmode>\d+)', '(?P<new>new) file mode (?P<newmode>\d+)',
'(?<deleted>deleted) file mode (?<oldmode>\d+)', '(?P<deleted>deleted) file mode (?P<oldmode>\d+)',
// These occur when someone uses `chmod` on a file. // These occur when someone uses `chmod` on a file.
'old mode (?<oldmode>\d+)', 'old mode (?P<oldmode>\d+)',
'new mode (?<newmode>\d+)', 'new mode (?P<newmode>\d+)',
// These occur when you `mv` a file and git figures it out. // These occur when you `mv` a file and git figures it out.
'similarity index ', 'similarity index ',
'rename from (?<old>.*)', 'rename from (?P<old>.*)',
'(?<move>rename) to (?<cur>.*)', '(?P<move>rename) to (?P<cur>.*)',
'copy from (?<old>.*)', 'copy from (?P<old>.*)',
'(?<copy>copy) to (?<cur>.*)' '(?P<copy>copy) to (?P<cur>.*)'
); );
$ok = false; $ok = false;
@ -576,7 +576,7 @@ class ArcanistDiffParser {
$line = $this->getLine(); $line = $this->getLine();
$matches = null; $matches = null;
$ok = preg_match( $ok = preg_match(
'@^[-+]{3} (?:[ab]/)?(?<path>.*?)(?:\s*\(.*\))?$@', '@^[-+]{3} (?:[ab]/)?(?P<path>.*?)(?:\s*\(.*\))?$@',
$line, $line,
$matches); $matches);
if (!$ok) { if (!$ok) {