use of org.zmlx.hg4idea.HgNameWithHashInfo in project intellij-community by JetBrains.
the class HgCompareWithBranchAction method noBranchesToCompare.
@Override
protected boolean noBranchesToCompare(@NotNull HgRepository repository) {
final Map<String, LinkedHashSet<Hash>> branches = repository.getBranches();
if (branches.size() > 1)
return false;
final Hash currentRevisionHash = getCurrentHash(repository);
final Collection<HgNameWithHashInfo> other_bookmarks = getOtherBookmarks(repository, currentRevisionHash);
if (!other_bookmarks.isEmpty())
return false;
// if only one heavy branch and no other bookmarks -> check that current revision is not "main" branch head
return currentRevisionHash.equals(getHeavyBranchMainHash(repository, repository.getCurrentBranch()));
}
use of org.zmlx.hg4idea.HgNameWithHashInfo in project intellij-community by JetBrains.
the class HgQGotoFromLogAction method actionPerformed.
protected void actionPerformed(@NotNull final HgRepository repository, @NotNull final VcsFullCommitDetails commit) {
final Project project = repository.getProject();
List<Hash> parents = commit.getParents();
final Hash parentHash = parents.isEmpty() ? null : parents.get(0);
final HgNameWithHashInfo parentPatchName = ContainerUtil.find(repository.getMQAppliedPatches(), new Condition<HgNameWithHashInfo>() {
@Override
public boolean value(HgNameWithHashInfo info) {
return info.getHash().equals(parentHash);
}
});
new Task.Backgroundable(repository.getProject(), parentPatchName != null ? HgVcsMessages.message("hg4idea.mq.progress.goto", parentPatchName) : HgVcsMessages.message("hg4idea.mq.progress.pop")) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
if (parentPatchName != null) {
new HgQGotoCommand(repository).executeInCurrentThread(parentPatchName.getName());
} else {
new HgQPopCommand(repository).executeInCurrentThread();
}
}
@Override
public void onSuccess() {
HgShowUnAppliedPatchesAction.showUnAppliedPatches(project, repository);
}
}.queue();
}
use of org.zmlx.hg4idea.HgNameWithHashInfo in project intellij-community by JetBrains.
the class HgLogProvider method readAllRefs.
@NotNull
private Set<VcsRef> readAllRefs(@NotNull VirtualFile root) throws VcsException {
if (myProject.isDisposed()) {
return Collections.emptySet();
}
HgRepository repository = myRepositoryManager.getRepositoryForRoot(root);
if (repository == null) {
LOG.error("Repository not found for root " + root);
return Collections.emptySet();
}
repository.update();
Map<String, LinkedHashSet<Hash>> branches = repository.getBranches();
Set<String> openedBranchNames = repository.getOpenedBranches();
Collection<HgNameWithHashInfo> bookmarks = repository.getBookmarks();
Collection<HgNameWithHashInfo> tags = repository.getTags();
Collection<HgNameWithHashInfo> localTags = repository.getLocalTags();
Collection<HgNameWithHashInfo> mqAppliedPatches = repository.getMQAppliedPatches();
Set<VcsRef> refs = new HashSet<>(branches.size() + bookmarks.size());
for (Map.Entry<String, LinkedHashSet<Hash>> entry : branches.entrySet()) {
String branchName = entry.getKey();
boolean opened = openedBranchNames.contains(branchName);
for (Hash hash : entry.getValue()) {
refs.add(myVcsObjectsFactory.createRef(hash, branchName, opened ? HgRefManager.BRANCH : HgRefManager.CLOSED_BRANCH, root));
}
}
for (HgNameWithHashInfo bookmarkInfo : bookmarks) {
refs.add(myVcsObjectsFactory.createRef(bookmarkInfo.getHash(), bookmarkInfo.getName(), HgRefManager.BOOKMARK, root));
}
String currentRevision = repository.getCurrentRevision();
if (currentRevision != null) {
// null => fresh repository
refs.add(myVcsObjectsFactory.createRef(myVcsObjectsFactory.createHash(currentRevision), HEAD_REFERENCE, HgRefManager.HEAD, root));
}
String tipRevision = repository.getTipRevision();
if (tipRevision != null) {
// null => fresh repository
refs.add(myVcsObjectsFactory.createRef(myVcsObjectsFactory.createHash(tipRevision), TIP_REFERENCE, HgRefManager.TIP, root));
}
for (HgNameWithHashInfo tagInfo : tags) {
refs.add(myVcsObjectsFactory.createRef(tagInfo.getHash(), tagInfo.getName(), HgRefManager.TAG, root));
}
for (HgNameWithHashInfo localTagInfo : localTags) {
refs.add(myVcsObjectsFactory.createRef(localTagInfo.getHash(), localTagInfo.getName(), HgRefManager.LOCAL_TAG, root));
}
for (HgNameWithHashInfo mqPatchRef : mqAppliedPatches) {
refs.add(myVcsObjectsFactory.createRef(mqPatchRef.getHash(), mqPatchRef.getName(), HgRefManager.MQ_APPLIED_TAG, root));
}
return refs;
}
use of org.zmlx.hg4idea.HgNameWithHashInfo in project intellij-community by JetBrains.
the class HgBranchUtil method getCommonBookmarks.
@NotNull
public static List<String> getCommonBookmarks(@NotNull Collection<HgRepository> repositories) {
Collection<String> commonBookmarkNames = null;
for (HgRepository repository : repositories) {
Collection<HgNameWithHashInfo> bookmarksInfo = repository.getBookmarks();
Collection<String> names = HgUtil.getSortedNamesWithoutHashes(bookmarksInfo);
if (commonBookmarkNames == null) {
commonBookmarkNames = names;
} else {
commonBookmarkNames = ContainerUtil.intersection(commonBookmarkNames, names);
}
}
if (commonBookmarkNames != null) {
ArrayList<String> common = new ArrayList<>(commonBookmarkNames);
Collections.sort(common);
return common;
} else {
return Collections.emptyList();
}
}
use of org.zmlx.hg4idea.HgNameWithHashInfo in project intellij-community by JetBrains.
the class HgQRenameCommand method execute.
public void execute(@NotNull final Hash patchHash) {
final Project project = myRepository.getProject();
HgNameWithHashInfo patchInfo = ContainerUtil.find(myRepository.getMQAppliedPatches(), new Condition<HgNameWithHashInfo>() {
@Override
public boolean value(HgNameWithHashInfo info) {
return info.getHash().equals(patchHash);
}
});
if (patchInfo == null) {
LOG.error("Could not find patch " + patchHash.toString());
return;
}
final String oldName = patchInfo.getName();
final String newName = Messages.showInputDialog(project, String.format("Enter a new name for %s patch:", oldName), "Rename Patch", Messages.getQuestionIcon(), "", new HgPatchReferenceValidator(myRepository));
if (newName != null) {
performPatchRename(myRepository, oldName, newName);
}
}
Aggregations