@NotNull
  public static List<VcsCommitMetadata> loadMetadata(
      @NotNull final Project project,
      @NotNull final VirtualFile root,
      int limit,
      @NotNull List<String> parameters)
      throws VcsException {

    final VcsLogObjectsFactory factory = getObjectsFactoryWithDisposeCheck(project);
    if (factory == null) {
      return Collections.emptyList();
    }
    HgVcs hgvcs = HgVcs.getInstance(project);
    assert hgvcs != null;
    HgVersion version = hgvcs.getVersion();
    List<String> templateList = HgBaseLogParser.constructDefaultTemplate(version);
    templateList.add("{desc}");
    String[] templates = ArrayUtil.toStringArray(templateList);
    HgCommandResult result =
        getLogResult(
            project, root, version, limit, parameters, HgChangesetUtil.makeTemplate(templates));
    HgBaseLogParser<VcsCommitMetadata> baseParser =
        new HgBaseLogParser<VcsCommitMetadata>() {

          @Override
          protected VcsCommitMetadata convertDetails(
              @NotNull String rev,
              @NotNull String changeset,
              @NotNull SmartList<HgRevisionNumber> parents,
              @NotNull Date revisionDate,
              @NotNull String author,
              @NotNull String email,
              @NotNull List<String> attributes) {
            String message = parseAdditionalStringAttribute(attributes, MESSAGE_INDEX);
            int subjectIndex = message.indexOf('\n');
            String subject = subjectIndex == -1 ? message : message.substring(0, subjectIndex);
            List<Hash> parentsHash = new SmartList<Hash>();
            for (HgRevisionNumber parent : parents) {
              parentsHash.add(factory.createHash(parent.getChangeset()));
            }
            return factory.createCommitMetadata(
                factory.createHash(changeset),
                parentsHash,
                revisionDate.getTime(),
                root,
                subject,
                author,
                email,
                message,
                author,
                email,
                revisionDate.getTime());
          }
        };
    return getCommitRecords(project, result, baseParser);
  }
Esempio n. 2
0
  @BeforeMethod
  protected void setUp(final Method testMethod) throws Exception {
    // setting hg executable
    String exec = System.getenv(HG_EXECUTABLE_PATH);
    if (exec != null) {
      myClientBinaryPath = new File(exec);
    }
    if (exec == null || !myClientBinaryPath.exists()) {
      final File pluginRoot = new File(PluginPathManager.getPluginHomePath(HgVcs.VCS_NAME));
      myClientBinaryPath = new File(pluginRoot, "testData/bin");
    }
    HgVcs.setTestHgExecutablePath(myClientBinaryPath.getPath());

    myMainRepo = initRepositories();
    myProjectDir = new File(myMainRepo.getDirFixture().getTempDirPath());

    UIUtil.invokeAndWaitIfNeeded(
        new Runnable() {
          @Override
          public void run() {
            try {
              initProject(myProjectDir, testMethod.getName());
              activateVCS(HgVcs.VCS_NAME);
            } catch (Exception e) {
              e.printStackTrace();
            }
          }
        });

    myChangeListManager = new HgTestChangeListManager(myProject);
    myTraceClient = true;
    doActionSilently(VcsConfiguration.StandardConfirmation.ADD);
    doActionSilently(VcsConfiguration.StandardConfirmation.REMOVE);
  }
 /**
  * Get & parse hg log detailed output with commits, their parents and their changes. For null
  * destination return log command result
  *
  * <p>
  *
  * <p>Warning: this is method is efficient by speed, but don't query too much, because the whole
  * log output is retrieved at once, and it can occupy too much memory. The estimate is ~600Kb for
  * 1000 commits.
  */
 @NotNull
 public static List<? extends VcsFullCommitDetails> history(
     @NotNull final Project project,
     @NotNull final VirtualFile root,
     int limit,
     @NotNull List<String> parameters)
     throws VcsException {
   HgVcs hgvcs = HgVcs.getInstance(project);
   assert hgvcs != null;
   final HgVersion version = hgvcs.getVersion();
   String[] templates = HgBaseLogParser.constructFullTemplateArgument(true, version);
   HgCommandResult result =
       getLogResult(
           project, root, version, limit, parameters, HgChangesetUtil.makeTemplate(templates));
   return createFullCommitsFromResult(project, root, result, version, false);
 }
 private void doTest() throws HgCommandException, VcsException {
   CachingCommittedChangesProvider provider = myVcs.getCachingCommittedChangesProvider();
   assert provider != null;
   //noinspection unchecked
   List<CommittedChangeList> revisions =
       provider.getCommittedChanges(
           mySettings, new HgRepositoryLocation(myRepository.getUrl(), myRepository), -1);
   assertTrue(!revisions.isEmpty());
 }
  @NotNull
  public static List<TimedVcsCommit> readAllHashes(
      @NotNull Project project,
      @NotNull VirtualFile root,
      @NotNull final Consumer<VcsUser> userRegistry,
      @NotNull List<String> params)
      throws VcsException {

    final VcsLogObjectsFactory factory = getObjectsFactoryWithDisposeCheck(project);
    if (factory == null) {
      return Collections.emptyList();
    }
    HgVcs hgvcs = HgVcs.getInstance(project);
    assert hgvcs != null;
    HgVersion version = hgvcs.getVersion();
    String[] templates = ArrayUtil.toStringArray(HgBaseLogParser.constructDefaultTemplate(version));
    HgCommandResult result =
        getLogResult(project, root, version, -1, params, HgChangesetUtil.makeTemplate(templates));
    return getCommitRecords(
        project,
        result,
        new HgBaseLogParser<TimedVcsCommit>() {

          @Override
          protected TimedVcsCommit convertDetails(
              @NotNull String rev,
              @NotNull String changeset,
              @NotNull SmartList<HgRevisionNumber> parents,
              @NotNull Date revisionDate,
              @NotNull String author,
              @NotNull String email,
              @NotNull List<String> attributes) {
            List<Hash> parentsHash = new SmartList<Hash>();
            for (HgRevisionNumber parent : parents) {
              parentsHash.add(factory.createHash(parent.getChangeset()));
            }
            userRegistry.consume(factory.createUser(author, email));
            return factory.createTimedCommit(
                factory.createHash(changeset), parentsHash, revisionDate.getTime());
          }
        });
  }
 @Override
 protected void showAffectedPaths(int lineNum) {
   if (lineNum >= 0 && lineNum < myLines.size()) {
     HgAnnotationLine line = myLines.get(lineNum);
     VirtualFile file = myFile.toFilePath().getVirtualFile();
     if (line != null && file != null) {
       ShowAllAffectedGenericAction.showSubmittedFiles(
           myProject, line.getVcsRevisionNumber(), file, HgVcs.getKey());
     }
   }
 }
 public HgExecutableValidator(Project project) {
   super(project, HgVcs.NOTIFICATION_GROUP_ID);
   myVcs = HgVcs.getInstance(project);
   setMessagesAndTitles(
       HgVcsMessages.message("hg4idea.executable.notification.title"),
       HgVcsMessages.message("hg4idea.executable.notification.description"),
       HgVcsMessages.message("hg4idea.executable.dialog.title"),
       HgVcsMessages.message("hg4idea.executable.dialog.description"),
       HgVcsMessages.message("hg4idea.executable.dialog.error"),
       HgVcsMessages.message("hg4idea.executable.filechooser.title"),
       HgVcsMessages.message("hg4idea.executable.filechooser.description"));
 }
 @Override
 public void setUp() throws Exception {
   super.setUp();
   myVcs = HgVcs.getInstance(myProject);
   assert myVcs != null;
   mySettings = new ChangeBrowserSettings();
   cd(myRepository);
   touch("f2.txt");
   hg("add");
   hg("commit -m add");
   java.util.Calendar now = java.util.Calendar.getInstance();
   now.add(YEAR, 1);
   dateBefore = ChangeBrowserSettings.DATE_FORMAT.format(now.getTime());
   now.set(YEAR, 1970);
   dateAfter = ChangeBrowserSettings.DATE_FORMAT.format(now.getTime());
 }
Esempio n. 9
0
 private VcsHistorySession getHistorySession(String relativePath) throws VcsException {
   return HgVcs.getInstance(myProject)
       .getVcsHistoryProvider()
       .createSessionFor(VcsUtil.getFilePath(new File(myProjectDir, relativePath), false));
 }
 @Override
 public VcsKey getVcsKey() {
   return HgVcs.getKey();
 }
 @Override
 protected void saveCurrentExecutable(String executable) {
   myVcs.getGlobalSettings().setHgExecutable(executable);
 }
 @Override
 public boolean isExecutableValid(String executable) {
   return new HgVersionCommand().isValid(executable, myVcs.getGlobalSettings().isRunViaBash());
 }
 @Override
 protected Configurable getConfigurable(Project project) {
   return myVcs == null ? null : myVcs.getConfigurable();
 }
 @Override
 protected String getCurrentExecutable() {
   return myVcs.getHgExecutable();
 }