Java源码示例:org.tigris.subversion.svnclientadapter.SVNDiffSummary

示例1
@NbBundle.Messages({
    "LBL_DiffRevisions.status.added=Added",
    "LBL_DiffRevisions.status.removed=Removed",
    "LBL_DiffRevisions.status.modified=Modified",
    "LBL_DiffRevisions.status.uptodate=Normal"
})
private static String toStatusText (SVNDiffSummary.SVNDiffKind diffKind) {
    if (diffKind == SVNDiffSummary.SVNDiffKind.DELETED) {
        return Bundle.LBL_DiffRevisions_status_removed();
    } else if (diffKind == SVNDiffSummary.SVNDiffKind.ADDED) {
        return Bundle.LBL_DiffRevisions_status_added();
    } else if (diffKind == SVNDiffSummary.SVNDiffKind.MODIFIED) {
        return Bundle.LBL_DiffRevisions_status_modified();
    } else {
        return Bundle.LBL_DiffRevisions_status_uptodate();
    }
}
 
示例2
private SVNDiffSummary[] getDiffSummaryWithSubfolders(SVNDiffSummary[] diffSummary) {
	ArrayList paths = new ArrayList();
	ArrayList diffs = new ArrayList();
	for (int i = 0; i < diffSummary.length; i++) {
		paths.add(diffSummary[i].getPath());
		diffs.add(diffSummary[i]);
	}
	for (int i = 0; i < diffSummary.length; i++) {
		File file = new File(diffSummary[i].getPath());
		while (file.getParentFile() != null) {
			file = file.getParentFile();
			String path = file.getPath();
			path = path.replaceAll("\\\\", "/"); //$NON-NLS-1$ //$NON-NLS-2$
			if (!paths.contains(path)) {
				paths.add(path);
				SVNDiffSummary folder = new SVNDiffSummary(path, SVNDiffKind.NORMAL, false, SVNNodeKind.DIR.toInt());
				diffs.add(folder);
			}
		}
	}
	diffSummary = new SVNDiffSummary[diffs.size()];
	diffs.toArray(diffSummary);
	return diffSummary;
}
 
示例3
private SVNDiffSummary[] getDiffSummaryWithSubfolders(SVNDiffSummary[] diffSummary) {
	ArrayList paths = new ArrayList();
	ArrayList diffs = new ArrayList();
	for (int i = 0; i < diffSummary.length; i++) {
		paths.add(diffSummary[i].getPath());
		diffs.add(diffSummary[i]);
	}
	for (int i = 0; i < diffSummary.length; i++) {
		File file = new File(diffSummary[i].getPath());
		while (file.getParentFile() != null) {
			file = file.getParentFile();
			String path = file.getPath();
			path = path.replaceAll("\\\\", "/");
			if (!paths.contains(path)) {
				paths.add(path);
				SVNDiffSummary folder = new SVNDiffSummary(path, SVNDiffKind.NORMAL, false, SVNNodeKind.DIR.toInt());
				diffs.add(folder);
			}
		}
	}
	diffSummary = new SVNDiffSummary[diffs.size()];
	diffs.toArray(diffSummary);
	return diffSummary;
}
 
示例4
private SVNDiffSummary[] getDiffSummaryWithSubfolders(SVNDiffSummary[] diffSummary) {
	ArrayList paths = new ArrayList();
	ArrayList diffs = new ArrayList();
	for (int i = 0; i < diffSummary.length; i++) {
		paths.add(diffSummary[i].getPath());
		diffs.add(diffSummary[i]);
	}
	for (int i = 0; i < diffSummary.length; i++) {
		File file = new File(diffSummary[i].getPath());
		while (file.getParentFile() != null) {
			file = file.getParentFile();
			String path = file.getPath();
			path = path.replaceAll("\\\\", "/"); //$NON-NLS-1$ //$NON-NLS-2$
			if (!paths.contains(path)) {
				paths.add(path);
				SVNDiffSummary folder = new SVNDiffSummary(path, SVNDiffKind.NORMAL, false, SVNNodeKind.DIR.toInt());
				diffs.add(folder);
			}
		}
	}
	diffSummary = new SVNDiffSummary[diffs.size()];
	diffs.toArray(diffSummary);
	return diffSummary;
}
 
示例5
/**
 * {@inheritDoc}
 */
@Override
public List<SvnDiff> diff(final URL url, long fromRevision, long toRevision) throws SvnClientException {
	final List<SvnDiff> list = new ArrayList<>();
	try {
		final SVNDiffSummary[] diffSummarize = client.diffSummarize(toSVNUrl(url), new Number(fromRevision),
				toSVNUrl(url), new Number(toRevision), Depth.infinity, true);
		for (final SVNDiffSummary svnDiffSummary : diffSummarize) {
			final SvnDiffAction action;
			if (svnDiffSummary.getDiffKind() == SVNDiffKind.ADDED) {
				action = SvnDiffAction.ADDED;
			} else if (svnDiffSummary.getDiffKind() == SVNDiffKind.DELETED) {
				action = SvnDiffAction.DELETED;
			} else if (svnDiffSummary.getDiffKind() == SVNDiffKind.MODIFIED) {
				action = SvnDiffAction.MODIFIED;
			} else if (svnDiffSummary.getDiffKind() == SVNDiffKind.NORMAL) {
				if (svnDiffSummary.propsChanged()) {
					action = SvnDiffAction.PROPERTY_CHANGED;
				} else {
					throw LogUtil
							.throwing(new SvnClientException("Unknown state of SVNDiffSummary " + svnDiffSummary));
				}
			} else {
				throw LogUtil
						.throwing(new SvnClientException("Unknown SvnDiffAction " + svnDiffSummary.getDiffKind()));
			}
			list.add(new SvnDiff(action, new URL(convertURLToString(url) + '/' + svnDiffSummary.getPath())));
		}
	} catch (MalformedURLException | SVNClientException e) {
		throw new SvnClientException(e);
	}
	return list;
}
 
示例6
@Override
@NbBundle.Messages({
    "MSG_Error.diffSummaryWithCLI.CLIforced=Diffing between revision trees is not supported with commandline client.",
    "MSG_Error.diffSummaryWithCLI=Diffing between revision trees is not supported with commandline client.\nPlease switch to SVNKit or JavaHL."
})
public SVNDiffSummary[] diffSummarize(SVNUrl arg0, SVNRevision arg1, SVNUrl arg2, SVNRevision arg3, int arg4, boolean arg5) throws SVNClientException {
    throw new SVNClientException(SvnModuleConfig.getDefault().isForcedCommandlineClient()
            ? Bundle.MSG_Error_diffSummaryWithCLI_CLIforced()
            : Bundle.MSG_Error_diffSummaryWithCLI());
}
 
示例7
private Setup createSetup (SVNDiffSummary summary, File file, SVNUrl leftUrl, SVNRevision leftRevision,
        SVNUrl rightUrl, String rightRevision) {
    FileInformation fi = null;
    Setup localSetup = wcSetups.get(file);
    boolean deleted = summary.getDiffKind() == SVNDiffKind.DELETED;
    boolean added = summary.getDiffKind() == SVNDiffKind.ADDED;
    if (localSetup != null) {
        // local file, diffing WC
        fi = cache.getStatus(file);
        if (added && (fi.getStatus() & FileInformation.STATUS_IN_REPOSITORY) == 0) {
            // don't override added status with modified
            fi = null;
        } else {
            deleted = (fi.getStatus() & (FileInformation.STATUS_VERSIONED_DELETEDLOCALLY
                    | FileInformation.STATUS_VERSIONED_REMOVEDLOCALLY)) != 0;
            added = (fi.getStatus() & (FileInformation.STATUS_VERSIONED_ADDEDLOCALLY
                    | FileInformation.STATUS_NOTVERSIONED_NEWLOCALLY)) != 0;
        }
    }
    if (fi == null) {
        fi = new RevisionsFileInformation(summary);
    }
    wcSetups.remove(file);
    Setup setup = new Setup(file, repositoryUrl,
            leftUrl, added ? null : leftRevision.toString(),
            SVNUrlUtils.getRelativePath(repositoryUrl, leftUrl) + "@" + leftRevision,
            rightUrl, deleted ? null : rightRevision,
            Setup.REVISION_CURRENT.equals(rightRevision)
            ? file.getName() + "@" + rightRevision
            : SVNUrlUtils.getRelativePath(repositoryUrl, rightUrl) + "@" + rightRevision,
            fi);
    setup.setNode(new DiffNode(setup, new SvnFileNode(file), FileInformation.STATUS_ALL));
    return setup;
}
 
示例8
private void cacheSummaries (SVNDiffSummary[] diffSummaries, SVNUrl leftUrl,
        SVNRevision leftRevision, SVNRevision rightRevision) {
    String revisionString = "@" + leftRevision + ":" + rightRevision;
    Map<String, List<SVNDiffSummary>> sums = new LinkedHashMap<>();
    sums.put("", new ArrayList<SVNDiffSummary>(diffSummaries.length));
    for (SVNDiffSummary s : diffSummaries) {
        String path = s.getPath();
        do {
            List<SVNDiffSummary> list = sums.get(path);
            if (list == null) {
                list = new ArrayList<>();
                sums.put(path, list);
            }
            String suffix = s.getPath().substring(path.length());
            if (suffix.startsWith("/")) {
                suffix = suffix.substring(1);
            }
            list.add(new SVNDiffSummary(suffix, s.getDiffKind(), s.propsChanged(), s.getNodeKind()));
            int index = path.lastIndexOf("/");
            if (index > -1) {
                path = path.substring(0, index);
            } else if (!path.isEmpty()) {
                path = "";
            } else {
                path = null;
            }
        } while (path != null);
    }
    for (Map.Entry<String, List<SVNDiffSummary>> e : sums.entrySet()) {
        SVNDiffSummary[] summaryArray = e.getValue().toArray(new SVNDiffSummary[e.getValue().size()]);
        String key;
        if (e.getKey().isEmpty()) {
            key = leftUrl.toString();
        } else {
            key = leftUrl.toString() + "/" + e.getKey();
        }
        key += revisionString;
        diffSummaryCache.put(key, summaryArray);
    }
}
 
示例9
private SVNDiffSummary[] getCachedSummaries (SVNUrl url, SVNRevision leftRevision, SVNRevision rightRevision) {
    String revisionString = "@" + leftRevision + ":" + rightRevision;
    boolean direct = true;
    while (url != null) {
        SVNDiffSummary[] sums = diffSummaryCache.get(url.toString() + revisionString);
        if (sums != null) {
            return direct ? sums : new SVNDiffSummary[0];
        }
        direct = false;
        url = url.getParent();
    }
    return null;
}
 
示例10
private static int toStatus (SVNDiffSummary.SVNDiffKind diffKind) {
    if (diffKind == SVNDiffSummary.SVNDiffKind.ADDED) {
        return FileInformation.STATUS_VERSIONED_ADDEDLOCALLY;
    } else if (diffKind == SVNDiffSummary.SVNDiffKind.DELETED) {
        return FileInformation.STATUS_VERSIONED_REMOVEDLOCALLY;
    } else if (diffKind == SVNDiffSummary.SVNDiffKind.MODIFIED) {
        return FileInformation.STATUS_VERSIONED_MODIFIEDLOCALLY;
    } else {
        return FileInformation.STATUS_VERSIONED_UPTODATE;
    }
}
 
示例11
private SVNDiffSummary[] getDiffSummary(RemoteResourceStatus[] statuses, ISVNLocalResource resource) {
	List diffSummaryList = new ArrayList();
	int rootPathLength = resource.getResource().getLocation().toString().length() + 1;
	for (int i = 0; i < statuses.length; i++) {
		if (statuses[i].getFile() != null && !statuses[i].getNodeKind().equals(SVNNodeKind.DIR)) {
			SVNStatusKind textStatus = statuses[i].getTextStatus();
			boolean propertyChanges = !statuses[i].getPropStatus().equals(SVNStatusKind.NORMAL) && !statuses[i].getPropStatus().equals(SVNStatusKind.NONE);
			boolean localChanges = false;
			if (textStatus.equals(SVNStatusKind.NONE) && propertyChanges && statuses[i].getNodeKind().equals(SVNNodeKind.FILE)) {
				IFile file = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(new Path(statuses[i].getPath()));
				if (file != null) {
					ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(file);
					try {
						LocalResourceStatus localStatus = svnResource.getStatus();
						if (localStatus != null) {
							localChanges = localStatus.isAdded() || localStatus.isDirty();
						}
					} catch (SVNException e) {}
				}
			}
			if (!textStatus.equals(SVNStatusKind.NONE) || !propertyChanges || localChanges) {
				SVNDiffKind diffKind = null;
				if (statuses[i].getTextStatus().equals(SVNStatusKind.ADDED)) diffKind = SVNDiffKind.ADDED;
				else if (statuses[i].getTextStatus().equals(SVNStatusKind.DELETED)) diffKind = SVNDiffKind.DELETED;
				else diffKind = SVNDiffKind.MODIFIED;
				SVNDiffSummary diffSummary = new SVNDiffSummary(statuses[i].getPath().substring(rootPathLength).replaceAll("\\\\", "/"), diffKind, propertyChanges, statuses[i].getNodeKind().toInt()); //$NON-NLS-1$ //$NON-NLS-2$
				diffSummaryList.add(diffSummary);
			}
		}
	}
	SVNDiffSummary[] diffSummaries = new SVNDiffSummary[diffSummaryList.size()];
	diffSummaryList.toArray(diffSummaries);
	return diffSummaries;
}
 
示例12
private SVNDiffSummary[] diffSummarize(String target1,
		SVNRevision revision1, String target2, SVNRevision revision2,
		int depth, boolean ignoreAncestry) throws SVNClientException {
	try {
		notificationHandler.setCommand(ISVNNotifyListener.Command.DIFF);

		if (revision1 == null)
			revision1 = SVNRevision.HEAD;
		if (revision2 == null)
			revision2 = SVNRevision.HEAD;

		String commandLine = "diff --summarize";
		Depth d = JhlConverter.depth(depth);
		commandLine += depthCommandLine(d);
		if (ignoreAncestry)
			commandLine += " --ignoreAncestry";
		commandLine += " " + target1 + "@" + revision1 + " " + target2
				+ "@" + revision2;
		notificationHandler.logCommandLine(commandLine);
		notificationHandler.setBaseDir();
		JhlDiffSummaryReceiver callback = new JhlDiffSummaryReceiver();
		svnClient.diffSummarize(target1, JhlConverter.convert(revision1),
				target2, JhlConverter.convert(revision2), d, null,
				ignoreAncestry, callback);
		return callback.getDiffSummary();
	} catch (ClientException e) {
		notificationHandler.logException(e);
		throw new SVNClientException(e);
	}
}
 
示例13
private SVNDiffSummary[] diffSummarize(String target,
		SVNRevision pegRevision, SVNRevision startRevision,
		SVNRevision endRevision, int depth, boolean ignoreAncestry)
		throws SVNClientException {
	try {
		notificationHandler.setCommand(ISVNNotifyListener.Command.DIFF);

		if (pegRevision == null)
			pegRevision = SVNRevision.HEAD;
		if (startRevision == null)
			startRevision = SVNRevision.HEAD;
		if (endRevision == null)
			endRevision = SVNRevision.HEAD;

		String commandLine = "diff --summarize";
		Depth d = JhlConverter.depth(depth);
		commandLine += depthCommandLine(d);
		if (ignoreAncestry)
			commandLine += " --ignoreAncestry";
		commandLine += " -r " + startRevision + ":" + endRevision + " "
				+ target;
		notificationHandler.logCommandLine(commandLine);
		notificationHandler.setBaseDir();
		JhlDiffSummaryReceiver callback = new JhlDiffSummaryReceiver();
		svnClient.diffSummarize(target, JhlConverter.convert(pegRevision),
				JhlConverter.convert(startRevision),
				JhlConverter.convert(endRevision), d, null, ignoreAncestry,
				callback);
		return callback.getDiffSummary();
	} catch (ClientException e) {
		notificationHandler.logException(e);
		throw new SVNClientException(e);
	}
}
 
示例14
public SVNDiffSummary[] diffSummarize(File path, SVNRevision pegRevision,
		SVNRevision startRevision, SVNRevision endRevision, int depth,
		boolean ignoreAncestry) throws SVNClientException {
	String target = fileToSVNPath(path, false);
	return this.diffSummarize(target, pegRevision, startRevision,
			endRevision, depth, ignoreAncestry);
}
 
示例15
public static SVNDiffSummary.SVNDiffKind convert(DiffSummary.DiffKind d) {
	if (d == DiffSummary.DiffKind.added) {
		return SVNDiffSummary.SVNDiffKind.ADDED;
	} else if (d == DiffSummary.DiffKind.modified) {
		return SVNDiffSummary.SVNDiffKind.MODIFIED;
	} else if (d == DiffSummary.DiffKind.deleted) {
		return SVNDiffSummary.SVNDiffKind.DELETED;
	} else {
		return SVNDiffSummary.SVNDiffKind.NORMAL;
	}
}
 
示例16
@Override
public SVNDiffSummary[] diffSummarize(File file, SVNUrl svnurl, SVNRevision svnr, boolean bln) throws SVNClientException {
    throw new UnsupportedOperationException("Not supported yet.");
}
 
示例17
@Override
public SVNDiffSummary[] diffSummarize(SVNUrl arg0, SVNRevision arg1, SVNRevision arg2, SVNRevision arg3, int arg4, boolean arg5) throws SVNClientException {
    throw new UnsupportedOperationException("Not supported yet.");
}
 
示例18
public RevisionsFileInformation (SVNDiffSummary item) {
    super(toStatus(item.getDiffKind()), 0, item.getNodeKind() == SVNNodeKind.DIR.toInt());
    this.name = toStatusText(item.getDiffKind());
}
 
示例19
public void setDiffSummary(SVNDiffSummary[] diffSummary) {
	this.diffSummary = diffSummary;
}
 
示例20
private boolean include(SVNDiffSummary diff) {
	if (diff.getNodeKind() != SVNNodeKind.FILE.toInt() && (diff.getPath() == null || diff.getPath().length() == 0)) return false;
	if (diff.getDiffKind().equals(SVNDiffKind.ADDED) && nodeType == RIGHT) return false;
	if (diff.getDiffKind().equals(SVNDiffKind.DELETED) && nodeType == LEFT) return false;				
	return true;
}
 
示例21
public SVNLocalResourceSummaryNode(ISVNLocalResource svnResource, SVNDiffSummary[] diffSummary, String rootLocation) {
	super(svnResource.getIResource());
       this.svnResource = svnResource;
       this.diffSummary = diffSummary;
       this.rootLocation = rootLocation;
}
 
示例22
public SVNDiffSummary[] diffSummarize(SVNUrl url, SVNRevision pegRevision,
		SVNRevision startRevision, SVNRevision endRevision, int depth,
		boolean ignoreAncestry) throws SVNClientException {
	return this.diffSummarize(url.toString(), pegRevision, startRevision,
			endRevision, depth, ignoreAncestry);
}
 
示例23
public SVNDiffSummary[] diffSummarize(File target1, SVNRevision revision1,
		SVNUrl target2, SVNRevision revision2, int depth,
		boolean ignoreAncestry) throws SVNClientException {
	return diffSummarize(fileToSVNPath(target1, false), revision1,
			target2.toString(), revision2, depth, ignoreAncestry);
}
 
示例24
public SVNDiffSummary[] diffSummarize(SVNUrl target1,
		SVNRevision revision1, SVNUrl target2, SVNRevision revision2,
		int depth, boolean ignoreAncestry) throws SVNClientException {
	return diffSummarize(target1.toString(), revision1, target2.toString(),
			revision2, depth, ignoreAncestry);
}
 
示例25
public SVNDiffSummary[] diffSummarize(File path, SVNUrl toUrl,
		SVNRevision toRevision, boolean recurse) throws SVNClientException {
	return diffSummarize(path.getAbsolutePath(), SVNRevision.WORKING,
			toUrl.toString(), toRevision, Depth.infinity.ordinal(), true);
}
 
示例26
public static SVNDiffSummary convert(DiffSummary d) {
	return new SVNDiffSummary(d.getPath(), JhlConverter.convert(d.getDiffKind()),
			d.propsChanged(), d.getNodeKind().ordinal());
}
 
示例27
public SVNDiffSummary[] getDiffSummary() {
	SVNDiffSummary[] diffSummary = new SVNDiffSummary[summary.size()];
	summary.toArray(diffSummary);
	return diffSummary;
}