Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Unified Diff: dart/tests/try/poi/source_update.dart

Issue 809363002: Parse merge conflict format for multi diffs. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Merged with r42456 Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | dart/tests/try/poi/source_update_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/tests/try/poi/source_update.dart
diff --git a/dart/tests/try/poi/source_update.dart b/dart/tests/try/poi/source_update.dart
index 571311d703dbf6298e8572b0b0dbe961226a5c7f..95ea1d18ce5239dead68d95df91c32355ed3da5d 100644
--- a/dart/tests/try/poi/source_update.dart
+++ b/dart/tests/try/poi/source_update.dart
@@ -40,7 +40,7 @@ List<String> expandUpdates(List updates) {
return result.map((e) => '$e').toList();
}
-/// Returns [files] split into mulitple named files. The keys in the returned
+/// Returns [files] split into multiple named files. The keys in the returned
/// map are filenames, the values are the files' content.
///
/// Names are indicated by a line on the form "==> filename <==". Spaces are
@@ -112,3 +112,43 @@ Map<String, String> splitFiles(String files) {
List<String> splitLines(String text) {
return text.split(new RegExp('^', multiLine: true));
}
+
+/// Expand a file with diffs in common merge conflict format into a [List] that
+/// can be passed to [expandUpdates].
+///
+/// For example:
+/// first
+/// <<<<<<<
+/// v1
+/// =======
+/// v2
+/// =======
+/// v3
+/// >>>>>>>
+/// last
+///
+/// Would be expanded to something equivalent to:
+///
+/// ["first\n", ["v1\n", "v2\n", "v3\n"], "last\n"]
+List expandDiff(String text) {
+ List result = [new StringBuffer()];
+ bool inDiff = false;
+ for (String line in splitLines(text)) {
+ if (inDiff) {
+ if (line.startsWith("=======")) {
+ result.last.add(new StringBuffer());
+ } else if (line.startsWith(">>>>>>>")) {
+ inDiff = false;
+ result.add(new StringBuffer());
+ } else {
+ result.last.last.write(line);
+ }
+ } else if (line.startsWith("<<<<<<<")) {
+ inDiff = true;
+ result.add(<StringBuffer>[new StringBuffer()]);
+ } else {
+ result.last.write(line);
+ }
+ }
+ return result;
+}
« no previous file with comments | « no previous file | dart/tests/try/poi/source_update_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698