use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.
the class SvnChangeList method patchChange.
private void patchChange(Change change, final String path) {
final SVNURL becameUrl;
SVNURL wasUrl;
try {
becameUrl = SVNURL.parseURIEncoded(SVNPathUtil.append(myRepositoryRoot, path));
wasUrl = becameUrl;
if (change instanceof ExternallyRenamedChange && change.getBeforeRevision() != null) {
String originUrl = ((ExternallyRenamedChange) change).getOriginUrl();
if (originUrl != null) {
// use another url for origin
wasUrl = SVNURL.parseURIEncoded(SVNPathUtil.append(myRepositoryRoot, originUrl));
}
}
} catch (SVNException e) {
// nothing to do
LOG.info(e);
return;
}
final FilePath filePath = ChangesUtil.getFilePath(change);
final Change additional = new Change(createPropertyRevision(filePath, change.getBeforeRevision(), wasUrl), createPropertyRevision(filePath, change.getAfterRevision(), becameUrl));
change.addAdditionalLayerElement(SvnChangeProvider.PROPERTY_LAYER, additional);
}
use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.
the class HgCheckinEnvironment method addFile.
private void addFile(Map<HgRepository, Set<HgFile>> result, ContentRevision contentRevision) {
FilePath filePath = contentRevision.getFile();
// try to find repository from hgFile from change: to be able commit sub repositories as expected
HgRepository repo = HgUtil.getRepositoryForFile(myProject, contentRevision instanceof HgCurrentBinaryContentRevision ? ((HgCurrentBinaryContentRevision) contentRevision).getRepositoryRoot() : ChangesUtil.findValidParentAccurately(filePath));
if (repo == null) {
return;
}
Set<HgFile> hgFiles = result.get(repo);
if (hgFiles == null) {
hgFiles = new HashSet<>();
result.put(repo, hgFiles);
}
hgFiles.add(new HgFile(repo.getRoot(), filePath));
}
use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.
the class HgLogProvider method getCommitsMatchingFilter.
@NotNull
@Override
public List<TimedVcsCommit> getCommitsMatchingFilter(@NotNull final VirtualFile root, @NotNull VcsLogFilterCollection filterCollection, int maxCount) throws VcsException {
List<String> filterParameters = ContainerUtil.newArrayList();
// branch filter and user filter may be used several times without delimiter
VcsLogBranchFilter branchFilter = filterCollection.getBranchFilter();
if (branchFilter != null) {
HgRepository repository = myRepositoryManager.getRepositoryForRoot(root);
if (repository == null) {
LOG.error("Repository not found for root " + root);
return Collections.emptyList();
}
Collection<String> branchNames = repository.getBranches().keySet();
Collection<String> bookmarkNames = HgUtil.getNamesWithoutHashes(repository.getBookmarks());
Collection<String> predefinedNames = ContainerUtil.list(TIP_REFERENCE);
boolean atLeastOneBranchExists = false;
for (String branchName : ContainerUtil.concat(branchNames, bookmarkNames, predefinedNames)) {
if (branchFilter.matches(branchName)) {
filterParameters.add(HgHistoryUtil.prepareParameter("branch", branchName));
atLeastOneBranchExists = true;
}
}
if (branchFilter.matches(HEAD_REFERENCE)) {
filterParameters.add(HgHistoryUtil.prepareParameter("branch", "."));
filterParameters.add("-r");
//all ancestors for current revision;
filterParameters.add("::.");
atLeastOneBranchExists = true;
}
if (!atLeastOneBranchExists) {
// no such branches => filter matches nothing
return Collections.emptyList();
}
}
if (filterCollection.getUserFilter() != null) {
filterParameters.add("-r");
String authorFilter = StringUtil.join(ContainerUtil.map(ContainerUtil.map(filterCollection.getUserFilter().getUsers(root), VcsUserUtil::toExactString), UserNameRegex.EXTENDED_INSTANCE), "|");
filterParameters.add("user('re:" + authorFilter + "')");
}
if (filterCollection.getDateFilter() != null) {
StringBuilder args = new StringBuilder();
final SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm");
filterParameters.add("-d");
VcsLogDateFilter filter = filterCollection.getDateFilter();
if (filter.getAfter() != null) {
if (filter.getBefore() != null) {
args.append(dateFormatter.format(filter.getAfter())).append(" to ").append(dateFormatter.format(filter.getBefore()));
} else {
args.append('>').append(dateFormatter.format(filter.getAfter()));
}
} else if (filter.getBefore() != null) {
args.append('<').append(dateFormatter.format(filter.getBefore()));
}
filterParameters.add(args.toString());
}
if (filterCollection.getTextFilter() != null) {
String textFilter = filterCollection.getTextFilter().getText();
if (filterCollection.getTextFilter().isRegex()) {
filterParameters.add("-r");
filterParameters.add("grep(r'" + textFilter + "')");
} else if (filterCollection.getTextFilter().matchesCase()) {
filterParameters.add("-r");
filterParameters.add("grep(r'" + StringUtil.escapeChars(textFilter, UserNameRegex.EXTENDED_REGEX_CHARS) + "')");
} else {
filterParameters.add(HgHistoryUtil.prepareParameter("keyword", textFilter));
}
}
if (filterCollection.getStructureFilter() != null) {
for (FilePath file : filterCollection.getStructureFilter().getFiles()) {
filterParameters.add(file.getPath());
}
}
return HgHistoryUtil.readAllHashes(myProject, root, Consumer.EMPTY_CONSUMER, filterParameters);
}
use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.
the class HgHistoryUtil method getOriginalHgFile.
public static HgFile getOriginalHgFile(Project project, VirtualFile root) {
HgFile hgFile = new HgFile(root, VcsUtil.getFilePath(root.getPath()));
if (project.isDisposed()) {
return hgFile;
}
FilePath originalFileName = HgUtil.getOriginalFileName(hgFile.toFilePath(), ChangeListManager.getInstance(project));
return new HgFile(hgFile.getRepo(), originalFileName);
}
use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.
the class HgHistoryProvider method getHistory.
public static List<HgFileRevision> getHistory(@NotNull FilePath filePath, @NotNull VirtualFile vcsRoot, @NotNull Project project, @Nullable HgRevisionNumber revisionNumber, int limit) {
/* The standard way to get history following renames is to call hg log --follow. However:
1. It is broken in case of uncommitted rename (i.e. if the file is currently renamed in the working dir):
in this case we use a special python template "follow(path)" which handles this case.
2. We don't use this python "follow(path)" function for all cases, because it is fully supported only since hg 2.6,
and it is a bit slower and possibly less reliable than plain --follow parameter.
3. It doesn't work with "-r": in this case --follow is simply ignored (hg commit 24208:8b4b9ee6001a).
As a workaround we could use the same follow(path) python, but this function requires current name of the file,
which is unknown in case of "-r", and identifying it would be very slow.
As a result we don't follow renames in annotate called from diff or from an old revision, which we can survive.
*/
FilePath originalFilePath = HgUtil.getOriginalFileName(filePath, ChangeListManager.getInstance(project));
if (revisionNumber == null && !filePath.isDirectory() && !filePath.equals(originalFilePath)) {
// uncommitted renames detected
return getHistoryForUncommittedRenamed(originalFilePath, vcsRoot, project, limit);
}
final HgLogCommand logCommand = new HgLogCommand(project);
logCommand.setFollowCopies(!filePath.isDirectory());
logCommand.setIncludeRemoved(true);
List<String> args = new ArrayList<>();
if (revisionNumber != null) {
args.add("--rev");
args.add("reverse(0::" + revisionNumber.getChangeset() + ")");
}
return logCommand.execute(new HgFile(vcsRoot, filePath), limit, false, args);
}
Aggregations