diff options
author | Tomasz Zarna | 2012-03-06 11:49:01 +0000 |
---|---|---|
committer | Tomasz Zarna | 2012-03-06 11:49:01 +0000 |
commit | c16d33cb372c32c25cb422662c7f86d9761572b3 (patch) | |
tree | 16f008dae1d2d6724878af734ecaa2fcc7d071a7 /bundles/org.eclipse.compare.core | |
parent | eb45436e1ee334a41ac502f87d306b7e45e69e4f (diff) | |
download | eclipse.platform.team-c16d33cb372c32c25cb422662c7f86d9761572b3.tar.gz eclipse.platform.team-c16d33cb372c32c25cb422662c7f86d9761572b3.tar.xz eclipse.platform.team-c16d33cb372c32c25cb422662c7f86d9761572b3.zip |
Applying a Git patch needs too much user workv20120306-1149
Bug: 358527
Change-Id: I544dbf9e3bc274e776dfa17473a02fe2141aa6d5
Diffstat (limited to 'bundles/org.eclipse.compare.core')
-rw-r--r-- | bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/PatchReader.java | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/PatchReader.java b/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/PatchReader.java index adf5deb6a..983b7f6b7 100644 --- a/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/PatchReader.java +++ b/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/PatchReader.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2010 IBM Corporation and others. + * Copyright (c) 2006, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -20,6 +20,7 @@ import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.StringTokenizer; +import java.util.regex.Pattern; import org.eclipse.compare.patch.IFilePatch2; import org.eclipse.core.runtime.Assert; @@ -52,6 +53,7 @@ public class PatchReader { }; private boolean fIsWorkspacePatch; + private boolean fIsGitPatch; private DiffProject[] fDiffProjects; private FilePatch2[] fDiffs; @@ -61,7 +63,9 @@ public class PatchReader { public static final String MULTIPROJECTPATCH_VERSION= "1.0"; //$NON-NLS-1$ public static final String MULTIPROJECTPATCH_PROJECT= "#P"; //$NON-NLS-1$ - + + private static final Pattern GIT_PATCH_PATTERN = Pattern.compile("^diff --git a/.+ b/.+[\r\n]+$"); + /** * Create a patch reader for the default date formats. */ @@ -92,6 +96,7 @@ public class PatchReader { // which will be replaced by the target selected by the user in the preview pane String projectName= ""; //$NON-NLS-1$ this.fIsWorkspacePatch= false; + this.fIsGitPatch = false; LineReader lr= new LineReader(reader); if (!Platform.WS_CARBON.equals(Platform.getWS())) @@ -102,6 +107,8 @@ public class PatchReader { if (line != null && line.startsWith(PatchReader.MULTIPROJECTPATCH_HEADER)) { this.fIsWorkspacePatch= true; } else { + if (line != null && GIT_PATCH_PATTERN.matcher(line).matches()) + this.fIsGitPatch = true; parse(lr, line); return; } @@ -661,6 +668,10 @@ public class PatchReader { return this.fIsWorkspacePatch; } + public boolean isGitPatch() { + return this.fIsGitPatch; + } + public DiffProject[] getDiffProjects() { return this.fDiffProjects; } |