tip reference moved as a separated static constant to HgUtil

This commit is contained in:
Nadya Zabrodina
2014-04-22 21:32:35 +04:00
parent 71cd276902
commit d86307edf8
3 changed files with 9 additions and 5 deletions
@@ -38,6 +38,8 @@ import org.zmlx.hg4idea.util.HgUtil;
import java.text.SimpleDateFormat;
import java.util.*;
import static org.zmlx.hg4idea.util.HgUtil.TIP_REFERENCE;
public class HgLogProvider implements VcsLogProvider {
private static final Logger LOG = Logger.getInstance(HgLogProvider.class);
@@ -47,8 +49,6 @@ public class HgLogProvider implements VcsLogProvider {
@NotNull private final VcsLogRefManager myRefSorter;
@NotNull private final VcsLogObjectsFactory myVcsObjectsFactory;
private static final String RECENT_HEAD = "tip";
public HgLogProvider(@NotNull Project project, @NotNull HgRepositoryManager repositoryManager, @NotNull VcsLogObjectsFactory factory) {
myProject = project;
myRepositoryManager = repositoryManager;
@@ -119,7 +119,7 @@ public class HgLogProvider implements VcsLogProvider {
}
String currentRevision = repository.getCurrentRevision();
if (currentRevision != null) { // null => fresh repository
refs.add(myVcsObjectsFactory.createRef(myVcsObjectsFactory.createHash(currentRevision), RECENT_HEAD, HgRefManager.HEAD, root));
refs.add(myVcsObjectsFactory.createRef(myVcsObjectsFactory.createHash(currentRevision), TIP_REFERENCE, HgRefManager.HEAD, root));
}
for (HgNameWithHashInfo tagInfo : tags) {
refs.add(myVcsObjectsFactory.createRef(tagInfo.getHash(), tagInfo.getName(), HgRefManager.TAG, root));
@@ -172,7 +172,7 @@ public class HgLogProvider implements VcsLogProvider {
boolean atLeastOneBranchExists = false;
for (String branchName : filterCollection.getBranchFilter().getBranchNames()) {
if (branchName.equals(RECENT_HEAD) || branchExists(repository, branchName)) {
if (branchName.equals(TIP_REFERENCE) || branchExists(repository, branchName)) {
filterParameters.add(prepareParameter("branch", branchName));
atLeastOneBranchExists = true;
}
@@ -31,6 +31,8 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Collection;
import static org.zmlx.hg4idea.util.HgUtil.TIP_REFERENCE;
public class HgCommonDialogWithChoices extends DialogWrapper {
@@ -119,7 +121,8 @@ public class HgCommonDialogWithChoices extends DialogWrapper {
HgRepository repo = hgRepositorySelectorComponent.getRepository();
branchSelector.setModel(new DefaultComboBoxModel(repo.getOpenedBranches().toArray()));
DefaultComboBoxModel tagComboBoxModel = new DefaultComboBoxModel(HgUtil.getNamesWithoutHashes(repo.getTags()).toArray());
tagComboBoxModel.addElement("tip"); //HgRepository does not store 'tip' tag because it is internal and not included in tags file
tagComboBoxModel
.addElement(TIP_REFERENCE); //HgRepository does not store 'tip' tag because it is internal and not included in tags file
tagSelector.setModel(tagComboBoxModel);
bookmarkSelector.setModel(new DefaultComboBoxModel(HgUtil.getNamesWithoutHashes(repo.getBookmarks()).toArray()));
update();
@@ -72,6 +72,7 @@ public abstract class HgUtil {
public static final int MANY_FILES = 100;
private static final Logger LOG = Logger.getInstance(HgUtil.class);
public static final String DOT_HG = ".hg";
public static final String TIP_REFERENCE = "tip";
public static File copyResourceToTempFile(String basename, String extension) throws IOException {
final InputStream in = HgUtil.class.getClassLoader().getResourceAsStream("python/" + basename + extension);