Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 125240 Details for
Bug 183238
[Apply Patch] API to get IHunks from IFilePatch and select which of them to apply
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch_v01
183238_v01.txt (text/plain), 24.48 KB, created by
Pawel Pogorzelski
on 2009-02-10 08:49:52 EST
(
hide
)
Description:
Patch_v01
Filename:
MIME Type:
Creator:
Pawel Pogorzelski
Created:
2009-02-10 08:49:52 EST
Size:
24.48 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.compare >Index: compare/org/eclipse/compare/internal/patch/Patcher.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java,v >retrieving revision 1.65 >diff -u -r1.65 Patcher.java >--- compare/org/eclipse/compare/internal/patch/Patcher.java 11 Dec 2008 13:39:37 -0000 1.65 >+++ compare/org/eclipse/compare/internal/patch/Patcher.java 10 Feb 2009 13:32:11 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2008 IBM Corporation and others. >+ * Copyright (c) 2000, 2009 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 >@@ -31,10 +31,11 @@ > import org.eclipse.compare.internal.core.patch.FileDiff; > import org.eclipse.compare.internal.core.patch.FileDiffResult; > import org.eclipse.compare.internal.core.patch.Hunk; >-import org.eclipse.compare.internal.core.patch.IHunkFilter; > import org.eclipse.compare.internal.core.patch.LineReader; > import org.eclipse.compare.internal.core.patch.PatchReader; > import org.eclipse.compare.internal.core.patch.Utilities; >+import org.eclipse.compare.patch.IHunk; >+import org.eclipse.compare.patch.IHunkFilter; > import org.eclipse.compare.patch.PatchConfiguration; > import org.eclipse.core.resources.IContainer; > import org.eclipse.core.resources.IFile; >@@ -92,7 +93,7 @@ > public Patcher() { > configuration = new PatchConfiguration(); > configuration.setProperty(PROP_PATCHER, this); >- configuration.setProperty(IHunkFilter.HUNK_FILTER_PROPERTY, this); >+ configuration.addHunkFilter(this); > } > > /* >@@ -193,8 +194,8 @@ > int removedLines = 0; > FileDiff fileDiff = fileDiffs[i]; > for (int j = 0; j < fileDiff.getHunkCount(); j++) { >- Hunk hunk = fileDiff.getHunks()[j]; >- String[] lines = hunk.getLines(); >+ IHunk hunk = fileDiff.getHunks()[j]; >+ String[] lines = ((Hunk) hunk).getLines(); > for (int k = 0; k < lines.length; k++) { > char c = lines[k].charAt(0); > switch (c) { >@@ -518,9 +519,9 @@ > } > > private void setEnabledFile(FileDiff fileDiff, boolean enabled) { >- Hunk[] hunks = fileDiff.getHunks(); >+ IHunk[] hunks = fileDiff.getHunks(); > for (int i = 0; i < hunks.length; i++) { >- setEnabledHunk(hunks[i], enabled); >+ setEnabledHunk((Hunk) hunks[i], enabled); > } > } > >@@ -753,7 +754,7 @@ > return false; > } > >- public boolean select(Hunk hunk) { >+ public boolean select(IHunk hunk) { > return isEnabled(hunk); > } > } >Index: compare/org/eclipse/compare/internal/patch/WorkspacePatcher.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/WorkspacePatcher.java,v >retrieving revision 1.15 >diff -u -r1.15 WorkspacePatcher.java >--- compare/org/eclipse/compare/internal/patch/WorkspacePatcher.java 15 Jul 2008 14:45:29 -0000 1.15 >+++ compare/org/eclipse/compare/internal/patch/WorkspacePatcher.java 10 Feb 2009 13:32:12 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 2009 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 >@@ -22,6 +22,7 @@ > import org.eclipse.compare.internal.core.patch.Hunk; > import org.eclipse.compare.internal.core.patch.LineReader; > import org.eclipse.compare.internal.core.patch.PatchReader; >+import org.eclipse.compare.patch.IHunk; > import org.eclipse.core.resources.IFile; > import org.eclipse.core.resources.IMarker; > import org.eclipse.core.resources.IProject; >@@ -259,7 +260,7 @@ > > public void retargetDiff(FileDiff diff, IFile file) { > retargetedDiffs.put(diff, diff.getPath(false)); >- Hunk[] hunks = diff.getHunks(); >+ IHunk[] hunks = diff.getHunks(); > > if (isWorkspacePatch()){ > //since the diff has no more hunks to apply, remove it from the parent and the patcher >@@ -268,7 +269,7 @@ > removeDiff(diff); > FileDiff newDiff = getDiffForFile(file); > for (int i = 0; i < hunks.length; i++) { >- Hunk hunk = hunks[i]; >+ Hunk hunk = (Hunk) hunks[i]; > newDiff.add(hunk); > } > } >Index: compare/org/eclipse/compare/internal/patch/PreviewPatchPage2.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PreviewPatchPage2.java,v >retrieving revision 1.38 >diff -u -r1.38 PreviewPatchPage2.java >--- compare/org/eclipse/compare/internal/patch/PreviewPatchPage2.java 4 Aug 2008 12:08:10 -0000 1.38 >+++ compare/org/eclipse/compare/internal/patch/PreviewPatchPage2.java 10 Feb 2009 13:32:12 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005, 2008 IBM Corporation and others. >+ * Copyright (c) 2005, 2009 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 >@@ -21,6 +21,7 @@ > import org.eclipse.compare.internal.ICompareUIConstants; > import org.eclipse.compare.internal.core.patch.FileDiff; > import org.eclipse.compare.internal.core.patch.Hunk; >+import org.eclipse.compare.patch.IHunk; > import org.eclipse.core.runtime.Assert; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IProgressMonitor; >@@ -716,9 +717,9 @@ > > FileDiff[] fileDiffs = fPatcher.getDiffs(); > for (int i = 0; i < fileDiffs.length; i++) { >- Hunk[] hunks = fileDiffs[i].getHunks(); >+ IHunk[] hunks = fileDiffs[i].getHunks(); > for (int j = 0; j < hunks.length; j++) { >- String[] lines = hunks[j].getLines(); >+ String[] lines = ((Hunk) hunks[j]).getLines(); > for (int k = 0; k < lines.length; k++) { > String line = lines[k]; > if (addedPattern.matcher(line).find()) >Index: compare/org/eclipse/compare/internal/patch/HunkTypedElement.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/HunkTypedElement.java,v >retrieving revision 1.11 >diff -u -r1.11 HunkTypedElement.java >--- compare/org/eclipse/compare/internal/patch/HunkTypedElement.java 15 Jul 2008 14:45:29 -0000 1.11 >+++ compare/org/eclipse/compare/internal/patch/HunkTypedElement.java 10 Feb 2009 13:32:10 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2006, 2008 IBM Corporation and others. >+ * Copyright (c) 2006, 2009 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 >@@ -15,6 +15,7 @@ > import org.eclipse.compare.IEncodedStreamContentAccessor; > import org.eclipse.compare.ITypedElement; > import org.eclipse.compare.internal.*; >+import org.eclipse.compare.internal.core.patch.FileDiffResult; > import org.eclipse.compare.internal.core.patch.HunkResult; > import org.eclipse.compare.patch.IHunk; > import org.eclipse.core.runtime.*; >@@ -71,7 +72,7 @@ > * @see org.eclipse.compare.ITypedElement#getName() > */ > public String getName() { >- return fHunkResult.getLabel(); >+ return fHunkResult.getHunk().getLabel(); > } > > /* (non-Javadoc) >@@ -86,7 +87,7 @@ > */ > public InputStream getContents() throws CoreException { > String contents = fHunkResult.getContents(fIsAfterState, fFullContext); >- return fHunkResult.asInputStream(contents); >+ return FileDiffResult.asInputStream(contents, fHunkResult.getCharset()); > } > > public String getCharset() throws CoreException { >#P org.eclipse.compare.core >Index: src/org/eclipse/compare/internal/core/patch/FileDiffResult.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/FileDiffResult.java,v >retrieving revision 1.1 >diff -u -r1.1 FileDiffResult.java >--- src/org/eclipse/compare/internal/core/patch/FileDiffResult.java 15 Jul 2008 14:43:27 -0000 1.1 >+++ src/org/eclipse/compare/internal/core/patch/FileDiffResult.java 10 Feb 2009 13:32:16 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2006, 2007 IBM Corporation and others. >+ * Copyright (c) 2006, 2009 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 >@@ -99,9 +99,9 @@ > // results for display > fBeforeLines = new ArrayList(getLines(storage, false)); > fAfterLines = fMatches ? new ArrayList() : fBeforeLines; >- Hunk[] hunks = fDiff.getHunks(); >+ IHunk[] hunks = fDiff.getHunks(); > for (int i = 0; i < hunks.length; i++) { >- Hunk hunk = hunks[i]; >+ Hunk hunk = (Hunk) hunks[i]; > HunkResult result = getHunkResult(hunk); > result.setMatches(false); > } >@@ -114,9 +114,9 @@ > if (fMatches) { > // Check to see if we have at least one hunk that matches > fMatches = false; >- Hunk[] hunks = fDiff.getHunks(); >+ IHunk[] hunks = fDiff.getHunks(); > for (int i = 0; i < hunks.length; i++) { >- Hunk hunk = hunks[i]; >+ Hunk hunk = (Hunk) hunks[i]; > HunkResult result = getHunkResult(hunk); > if (result.isOK()) { > fMatches = true; >@@ -157,9 +157,9 @@ > calculateFuzz(fBeforeLines, monitor); > } > int shift= 0; >- Hunk[] hunks = fDiff.getHunks(); >+ IHunk[] hunks = fDiff.getHunks(); > for (int i = 0; i < hunks.length; i++) { >- Hunk hunk = hunks[i]; >+ Hunk hunk = (Hunk) hunks[i]; > HunkResult result = getHunkResult(hunk); > result.setShift(shift); > if (result.patch(lines)) { >@@ -226,9 +226,9 @@ > int shift= 0; > int highestFuzz = -1; // the maximum fuzz factor for all hunks > String name = getTargetPath() != null ? getTargetPath().lastSegment() : ""; //$NON-NLS-1$ >- Hunk[] hunks = fDiff.getHunks(); >+ IHunk[] hunks = fDiff.getHunks(); > for (int j = 0; j < hunks.length; j++) { >- Hunk h = hunks[j]; >+ Hunk h = (Hunk) hunks[j]; > monitor.subTask(NLS.bind(Messages.FileDiffResult_3, new String[] {name, Integer.toString(j + 1)})); > HunkResult result = getHunkResult(h); > result.setShift(shift); >@@ -264,16 +264,6 @@ > } > return failedHunks; > } >- >- private HunkResult[] getFailedHunkResults() { >- List failedHunks = new ArrayList(); >- for (Iterator iterator = fHunkResults.values().iterator(); iterator.hasNext();) { >- HunkResult result = (HunkResult) iterator.next(); >- if (!result.isOK()) >- failedHunks.add(result); >- } >- return (HunkResult[]) failedHunks.toArray(new HunkResult[failedHunks.size()]); >- } > > public FileDiff getDiff() { > return fDiff; >@@ -310,13 +300,14 @@ > } > > public IHunk[] getRejects() { >- return getFailedHunkResults(); >+ List failedHunks = getFailedHunks(); >+ return (IHunk[]) failedHunks.toArray(new IHunk[failedHunks.size()]); > } > > public boolean hasRejects() { >- return getFailedHunkResults().length > 0; >+ return getFailedHunks().size() > 0; > } >- >+ > public static InputStream asInputStream(String contents, String charSet) { > byte[] bytes = null; > if (charSet != null) { >Index: src/org/eclipse/compare/internal/core/patch/FileDiff.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/FileDiff.java,v >retrieving revision 1.1 >diff -u -r1.1 FileDiff.java >--- src/org/eclipse/compare/internal/core/patch/FileDiff.java 15 Jul 2008 14:43:27 -0000 1.1 >+++ src/org/eclipse/compare/internal/core/patch/FileDiff.java 10 Feb 2009 13:32:16 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2006, 2008 IBM Corporation and others. >+ * Copyright (c) 2006, 2009 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 >@@ -16,6 +16,7 @@ > > import org.eclipse.compare.patch.IFilePatch; > import org.eclipse.compare.patch.IFilePatchResult; >+import org.eclipse.compare.patch.IHunk; > import org.eclipse.compare.patch.PatchConfiguration; > import org.eclipse.core.resources.IStorage; > import org.eclipse.core.runtime.IPath; >@@ -124,8 +125,8 @@ > * Return the hunks associated with this file diff. > * @return the hunks associated with this file diff > */ >- public Hunk[] getHunks() { >- return (Hunk[]) fHunks.toArray(new Hunk[fHunks.size()]); >+ public IHunk[] getHunks() { >+ return (IHunk[]) fHunks.toArray(new IHunk[fHunks.size()]); > } > > /** >Index: src/org/eclipse/compare/internal/core/patch/IHunkFilter.java >=================================================================== >RCS file: src/org/eclipse/compare/internal/core/patch/IHunkFilter.java >diff -N src/org/eclipse/compare/internal/core/patch/IHunkFilter.java >--- src/org/eclipse/compare/internal/core/patch/IHunkFilter.java 15 Jul 2008 14:43:27 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,27 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2008 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 >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.compare.internal.core.patch; >- >-/** >- * Filter that is used to determine if a hunk should be applied or not >- */ >-public interface IHunkFilter { >- >- public static final String HUNK_FILTER_PROPERTY = "org.eclipse.compare.core.hunkFilter"; //$NON-NLS-1$ >- >- /** >- * Returns true if the given hunk should be applied >- * @param hunk the hunk >- * @return true if the given hunk should be applied >- */ >- public boolean select(Hunk hunk); >- >-} >Index: src/org/eclipse/compare/internal/core/patch/HunkResult.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/HunkResult.java,v >retrieving revision 1.1 >diff -u -r1.1 HunkResult.java >--- src/org/eclipse/compare/internal/core/patch/HunkResult.java 15 Jul 2008 14:43:27 -0000 1.1 >+++ src/org/eclipse/compare/internal/core/patch/HunkResult.java 10 Feb 2009 13:32:16 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2006, 2008 IBM Corporation and others. >+ * Copyright (c) 2006, 2009 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 >@@ -10,15 +10,14 @@ > *******************************************************************************/ > package org.eclipse.compare.internal.core.patch; > >-import java.io.InputStream; > import java.util.List; > >-import org.eclipse.compare.patch.IHunk; >+import org.eclipse.compare.patch.IHunkFilter; > import org.eclipse.compare.patch.PatchConfiguration; > import org.eclipse.core.runtime.IProgressMonitor; > import org.eclipse.core.runtime.OperationCanceledException; > >-public class HunkResult implements IHunk { >+public class HunkResult { > > private static final boolean DEBUG= false; > >@@ -251,10 +250,11 @@ > } > > private boolean isEnabled(PatchConfiguration configuration) { >- Object property = configuration.getProperty(IHunkFilter.HUNK_FILTER_PROPERTY); >- if (property instanceof IHunkFilter) { >- IHunkFilter filter = (IHunkFilter) property; >- return filter.select(fHunk); >+ IHunkFilter[] filters = configuration.getHunkFilters(); >+ for (int i = 0; i < filters.length; i++) { >+ if (!filters[i].select(fHunk)) { >+ return false; >+ } > } > return true; > } >@@ -263,29 +263,6 @@ > fMatches = matches; > } > >- public int getStartPosition() { >- return fHunk.getStart(getConfiguration().isReversed()) + fShift; >- } >- >- public String getLabel() { >- return getHunk().getDescription(); >- } >- >- public InputStream getOriginalContents() { >- String contents = getContents(false, false); >- return asInputStream(contents); >- } >- >- public InputStream asInputStream(String contents) { >- String charSet = getCharset(); >- return FileDiffResult.asInputStream(contents, charSet); >- } >- >- public InputStream getPatchedContents() { >- String contents = getContents(true, false); >- return asInputStream(contents); >- } >- > public String getCharset() { > return fDiffResult.getCharset(); > } >Index: src/org/eclipse/compare/internal/core/patch/Hunk.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/Hunk.java,v >retrieving revision 1.2 >diff -u -r1.2 Hunk.java >--- src/org/eclipse/compare/internal/core/patch/Hunk.java 9 Sep 2008 10:19:37 -0000 1.2 >+++ src/org/eclipse/compare/internal/core/patch/Hunk.java 10 Feb 2009 13:32:16 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2008 IBM Corporation and others. >+ * Copyright (c) 2000, 2009 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 >@@ -10,16 +10,18 @@ > *******************************************************************************/ > package org.eclipse.compare.internal.core.patch; > >+import java.io.InputStream; > import java.util.ArrayList; > import java.util.List; > >+import org.eclipse.compare.patch.IHunk; > import org.eclipse.compare.patch.PatchConfiguration; > import org.eclipse.core.runtime.Assert; > > /** > * A Hunk describes a range of changed lines and some context lines. > */ >-public class Hunk { >+public class Hunk implements IHunk { > > private FileDiff fParent; > private int fOldStart, fOldLength; >@@ -461,4 +463,32 @@ > } > return result.toString(); > } >+ >+ public String getLabel() { >+ return getDescription(); >+ } >+ >+ public int getStartPosition() { >+ return getStart(false); >+ } >+ >+ public InputStream getOriginalContents() { >+ String contents = getContents(false, false); >+ return asInputStream(contents); >+ } >+ >+ public InputStream getPatchedContents() { >+ String contents = getContents(true, false); >+ return asInputStream(contents); >+ } >+ >+ private InputStream asInputStream(String contents) { >+ String charSet = getCharset(); >+ return FileDiffResult.asInputStream(contents, charSet); >+ } >+ >+ public String getCharset() { >+ return null; >+ } >+ > } >Index: src/org/eclipse/compare/patch/IFilePatch.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare.core/src/org/eclipse/compare/patch/IFilePatch.java,v >retrieving revision 1.2 >diff -u -r1.2 IFilePatch.java >--- src/org/eclipse/compare/patch/IFilePatch.java 12 Aug 2008 11:20:56 -0000 1.2 >+++ src/org/eclipse/compare/patch/IFilePatch.java 10 Feb 2009 13:32:16 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2007, 2008 IBM Corporation and others. >+ * Copyright (c) 2007, 2009 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 >@@ -83,4 +83,12 @@ > * @since 3.4 > */ > public long getAfterDate(); >+ >+ /** >+ * Returns all the hunks this file patch contains. >+ * >+ * @return array of hunks >+ * @since 3.5 >+ */ >+ public IHunk[] getHunks(); > } >Index: src/org/eclipse/compare/patch/PatchConfiguration.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare.core/src/org/eclipse/compare/patch/PatchConfiguration.java,v >retrieving revision 1.2 >diff -u -r1.2 PatchConfiguration.java >--- src/org/eclipse/compare/patch/PatchConfiguration.java 12 Aug 2008 11:20:56 -0000 1.2 >+++ src/org/eclipse/compare/patch/PatchConfiguration.java 10 Feb 2009 13:32:16 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2007, 2008 IBM Corporation and others. >+ * Copyright (c) 2007, 2009 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 >@@ -10,7 +10,9 @@ > *******************************************************************************/ > package org.eclipse.compare.patch; > >+import java.util.ArrayList; > import java.util.HashMap; >+import java.util.List; > > /** > * A patch configuration allows clients to set parameters that control how a >@@ -28,6 +30,7 @@ > private boolean fIgnoreWhitespace= false; > private boolean fReverse= false; > private HashMap properties = new HashMap(); >+ private List hunkFilters = new ArrayList(); > > /** > * Return whether the patch should be reversed when applied. >@@ -119,4 +122,37 @@ > public void setProperty(String key, Object value) { > properties.put(key, value); > } >+ >+ /** >+ * Adds a hunk filter. >+ * >+ * @param filter >+ * @since 3.5 >+ */ >+ public void addHunkFilter(IHunkFilter filter) { >+ hunkFilters.add(filter); >+ } >+ >+ /** >+ * Removes a hunk filter. >+ * >+ * @param filter >+ * @since 3.5 >+ */ >+ public void removeHunkFilter(IHunkFilter filter) { >+ hunkFilters.remove(filter); >+ } >+ >+ /** >+ * Return an array of hunk filters that have been added to this >+ * configuration. >+ * >+ * @return >+ * @since 3.5 >+ */ >+ public IHunkFilter[] getHunkFilters() { >+ return (IHunkFilter[]) hunkFilters.toArray(new IHunkFilter[hunkFilters >+ .size()]); >+ } >+ > } >Index: src/org/eclipse/compare/patch/IHunkFilter.java >=================================================================== >RCS file: src/org/eclipse/compare/patch/IHunkFilter.java >diff -N src/org/eclipse/compare/patch/IHunkFilter.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/compare/patch/IHunkFilter.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,29 @@ >+/******************************************************************************* >+ * Copyright (c) 2008, 2009 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.compare.patch; >+ >+/** >+ * Filter that is used to determine if a hunk should be applied or not >+ * >+ * @since 3.5 >+ */ >+public interface IHunkFilter { >+ >+ /** >+ * Returns true if the given hunk should be applied >+ * >+ * @param hunk >+ * the hunk >+ * @return true if the given hunk should be applied >+ */ >+ public boolean select(IHunk hunk); >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 183238
:
125240
|
125371
|
125770
|
125776
|
125789