use of org.zmlx.hg4idea.repo.HgRepository in project intellij-community by JetBrains.
the class HgPusher method push.
@Override
public void push(@NotNull Map<HgRepository, PushSpec<HgPushSource, HgTarget>> pushSpecs, @Nullable VcsPushOptionValue vcsPushOptionValue, boolean force) {
for (Map.Entry<HgRepository, PushSpec<HgPushSource, HgTarget>> entry : pushSpecs.entrySet()) {
HgRepository repository = entry.getKey();
PushSpec<HgPushSource, HgTarget> hgSpec = entry.getValue();
HgTarget destination = hgSpec.getTarget();
HgPushSource source = hgSpec.getSource();
Project project = repository.getProject();
final HgPushCommand pushCommand = new HgPushCommand(project, repository.getRoot(), destination.myTarget);
// set always true, because it just allow mercurial to create a new one if needed
pushCommand.setIsNewBranch(true);
pushCommand.setForce(force);
String branchName = source.getBranch();
if (branchName.equals(repository.getCurrentBookmark())) {
if (vcsPushOptionValue == HgVcsPushOptionValue.Current) {
pushCommand.setBookmarkName(branchName);
} else {
pushCommand.setRevision(branchName);
}
} else {
pushCommand.setBranchName(branchName);
}
pushSynchronously(project, pushCommand);
}
}
use of org.zmlx.hg4idea.repo.HgRepository in project intellij-community by JetBrains.
the class HgUtil method sortByHgRoots.
@NotNull
public static Map<VirtualFile, Collection<VirtualFile>> sortByHgRoots(@NotNull Project project, @NotNull Collection<VirtualFile> files) {
Map<VirtualFile, Collection<VirtualFile>> sorted = new HashMap<>();
HgRepositoryManager repositoryManager = getRepositoryManager(project);
for (VirtualFile file : files) {
HgRepository repo = repositoryManager.getRepositoryForFile(file);
if (repo == null) {
continue;
}
Collection<VirtualFile> filesForRoot = sorted.get(repo.getRoot());
if (filesForRoot == null) {
filesForRoot = new HashSet<>();
sorted.put(repo.getRoot(), filesForRoot);
}
filesForRoot.add(file);
}
return sorted;
}
use of org.zmlx.hg4idea.repo.HgRepository in project intellij-community by JetBrains.
the class HgEncodingTest method testCommitUtfMessage.
//test for default EncodingProject settings
public void testCommitUtfMessage() throws HgCommandException, VcsException {
cd(myRepository);
echo("file.txt", "lalala");
HgRepository hgRepo = HgRepositoryImpl.getInstance(myRepository, myProject, myProject);
HgCommitCommand commitCommand = new HgCommitCommand(myProject, hgRepo, "сообщение");
commitCommand.executeInCurrentThread();
}
use of org.zmlx.hg4idea.repo.HgRepository in project intellij-community by JetBrains.
the class HgEncodingTest method testUtfMessageInHistoryWithSpecialCharacters.
//test SpecialCharacters in commit message for default EncodingProject settings
public void testUtfMessageInHistoryWithSpecialCharacters() throws HgCommandException, VcsException {
cd(myRepository);
String fileName = "file.txt";
echo(fileName, "lalala");
Charset charset = HgEncodingUtil.getDefaultCharset(myProject);
String comment = "öäüß";
HgRepository hgRepo = HgRepositoryImpl.getInstance(myRepository, myProject, myProject);
HgCommitCommand commitCommand = new HgCommitCommand(myProject, hgRepo, comment);
commitCommand.executeInCurrentThread();
HgLogCommand logCommand = new HgLogCommand(myProject);
myRepository.refresh(false, true);
VirtualFile file = myRepository.findChild(fileName);
assert file != null;
List<HgFileRevision> revisions = logCommand.execute(new HgFile(myProject, file), 1, false);
HgFileRevision rev = revisions.get(0);
assertEquals(new String(comment.getBytes(charset)), rev.getCommitMessage());
}
use of org.zmlx.hg4idea.repo.HgRepository in project intellij-community by JetBrains.
the class HgPlatformTest method updateRepoConfig.
protected static void updateRepoConfig(@NotNull Project project, @Nullable VirtualFile repo) {
HgRepository hgRepository = HgUtil.getRepositoryManager(project).getRepositoryForRoot(repo);
assertNotNull(hgRepository);
hgRepository.updateConfig();
}
Aggregations