$this->didStartParse($diff);
+ // Strip off header comments. While `patch` allows comments anywhere in the
+ // file, `git apply` is more strict. We get these comments in `hg export`
+ // diffs, and Eclipse can also produce them.
+ $line = $this->getLineTrimmed();
+ while (preg_match('/^#/', $line)) {
+ $line = $this->nextLine();
+ }
+
do {
$patterns = array(
// This is a normal SVN text change, probably from "svn diff".
}
protected function isFirstNonEmptyLine() {
- $count = count($this->text);
- for ($i = 0; $i < $count; $i++) {
- if (strlen(trim($this->text[$i])) != 0) {
- return ($i == $this->line);
+ $len = count($this->text);
+ for ($ii = 0; $ii < $len; $ii++) {
+ $line = $this->text[$ii];
+
+ if (!strlen(trim($line))) {
+ // This line is empty, skip it.
+ continue;
}
+
+ if (preg_match('/^#/', $line)) {
+ // This line is a comment, skip it.
+ continue;
+ }
+
+ return ($ii == $this->line);
}
+
// Entire file is empty.
return false;
}
ArcanistDiffChangeType::TYPE_CHANGE,
$change->getType());
break;
+ case 'comment.svndiff':
+ $this->assertEqual(1, count($changes));
+ $change = array_shift($changes);
+ $this->assertEqual(
+ ArcanistDiffChangeType::TYPE_CHANGE,
+ $change->getType());
+ break;
default:
throw new Exception("No test block for diff file {$diff_file}.");
break;
--- /dev/null
+### Eclipse Workspace Patch 1.0
+#P Services
+Index: example
+===================================================================
+--- example (revision 80)
++++ example (working copy)
+@@ -1 +1 @@
+-a
++apple