Examples of HgStatusCommand


Examples of org.apache.maven.scm.provider.hg.command.status.HgStatusCommand

        // Get files that will be committed (if not specified in fileSet)
        List<ScmFile> commitedFiles = new ArrayList<ScmFile>();
        List<File> files = fileSet.getFileList();
        if ( files.isEmpty() )
        { //Either commit all changes
            HgStatusCommand statusCmd = new HgStatusCommand();
            statusCmd.setLogger( getLogger() );
            StatusScmResult status = statusCmd.executeStatusCommand( repo, fileSet );
            List<ScmFile> statusFiles = status.getChangedFiles();
            for ( ScmFile file : statusFiles )
            {
                if ( file.getStatus() == ScmFileStatus.ADDED || file.getStatus() == ScmFileStatus.DELETED ||
                    file.getStatus() == ScmFileStatus.MODIFIED )
View Full Code Here

Examples of org.apache.maven.scm.provider.hg.command.status.HgStatusCommand

    /** {@inheritDoc} */
    public StatusScmResult status( ScmProviderRepository repository, ScmFileSet fileSet,
                                   CommandParameters parameters )
        throws ScmException
    {
        HgStatusCommand command = new HgStatusCommand();

        command.setLogger( getLogger() );

        return (StatusScmResult) command.execute( repository, fileSet, parameters );
    }
View Full Code Here

Examples of org.apache.maven.scm.provider.hg.command.status.HgStatusCommand

        // Get files that will be committed (if not specified in fileSet)
        List<ScmFile> commitedFiles = new ArrayList<ScmFile>();
        List<File> files = fileSet.getFileList();
        if ( files.isEmpty() )
        { //Either commit all changes
            HgStatusCommand statusCmd = new HgStatusCommand();
            statusCmd.setLogger( getLogger() );
            StatusScmResult status = statusCmd.executeStatusCommand( repo, fileSet );
            List<ScmFile> statusFiles = status.getChangedFiles();
            for ( ScmFile file : statusFiles )
            {
                if ( file.getStatus() == ScmFileStatus.ADDED || file.getStatus() == ScmFileStatus.DELETED
                    || file.getStatus() == ScmFileStatus.MODIFIED )
View Full Code Here

Examples of org.apache.maven.scm.provider.hg.command.status.HgStatusCommand

    /** {@inheritDoc} */
    public StatusScmResult status( ScmProviderRepository repository, ScmFileSet fileSet,
                                   CommandParameters parameters )
        throws ScmException
    {
        HgStatusCommand command = new HgStatusCommand();

        command.setLogger( getLogger() );

        return (StatusScmResult) command.execute( repository, fileSet, parameters );
    }
View Full Code Here

Examples of org.apache.maven.scm.provider.hg.command.status.HgStatusCommand

        // Get files that will be committed (if not specified in fileSet)
        List<ScmFile> commitedFiles = new ArrayList<ScmFile>();
        List<File> files = fileSet.getFileList();
        if ( files.isEmpty() )
        { //Either commit all changes
            HgStatusCommand statusCmd = new HgStatusCommand();
            statusCmd.setLogger( getLogger() );
            StatusScmResult status = statusCmd.executeStatusCommand( repo, fileSet );
            List<ScmFile> statusFiles = status.getChangedFiles();
            for ( ScmFile file : statusFiles )
            {
                if ( file.getStatus() == ScmFileStatus.ADDED || file.getStatus() == ScmFileStatus.DELETED ||
                    file.getStatus() == ScmFileStatus.MODIFIED )
View Full Code Here

Examples of org.tmatesoft.hg.core.HgStatusCommand

    if (!hgRepo.init(cmdLineOpts.findRepository())) {
      System.err.printf("Can't find repository in: %s\n", hgRepo.getRepository().getLocation());
      return;
    }
    //
    HgStatusCommand cmd = hgRepo.createStatusCommand();
    if (cmdLineOpts.getBoolean("-A", "--all")) {
      cmd.all();
    } else {
      // default: mardu
      cmd.modified(cmdLineOpts.getBoolean(true, "-m", "--modified"));
      cmd.added(cmdLineOpts.getBoolean(true, "-a", "--added"));
      cmd.removed(cmdLineOpts.getBoolean(true, "-r", "--removed"));
      cmd.deleted(cmdLineOpts.getBoolean(true, "-d", "--deleted"));
      cmd.unknown(cmdLineOpts.getBoolean(true, "-u", "--unknonwn"));
      cmd.clean(cmdLineOpts.getBoolean("-c", "--clean"));
      cmd.ignored(cmdLineOpts.getBoolean("-i", "--ignored"));
    }
//    cmd.subrepo(cmdLineOpts.getBoolean("-S", "--subrepos"))
    final boolean noStatusPrefix = cmdLineOpts.getBoolean("-n", "--no-status");
    final boolean showCopies = cmdLineOpts.getBoolean("-C", "--copies");
    class StatusHandler implements HgStatusHandler {
     
      final EnumMap<HgStatus.Kind, List<Path>> data = new EnumMap<HgStatus.Kind, List<Path>>(HgStatus.Kind.class);
      final Map<Path, Path> copies = showCopies ? new HashMap<Path,Path>() : null;
     
      public void status(HgStatus s) {
        List<Path> l = data.get(s.getKind());
        if (l == null) {
          l = new LinkedList<Path>();
          data.put(s.getKind(), l);
        }
        l.add(s.getPath());
        if (s.isCopy() && showCopies) {
          copies.put(s.getPath(), s.getOriginalPath());
        }
      }
     
      public void error(Path file, Outcome s) {
        System.out.printf("FAILURE: %s %s\n", s.getMessage(), file);
        s.getException().printStackTrace(System.out);
      }
     
      public void dump() {
        sortAndPrint('M', data.get(Kind.Modified), null);
        sortAndPrint('A', data.get(Kind.Added), copies);
        sortAndPrint('R', data.get(Kind.Removed), null);
        sortAndPrint('?', data.get(Kind.Unknown), null);
        sortAndPrint('I', data.get(Kind.Ignored), null);
        sortAndPrint('C', data.get(Kind.Clean), null);
        sortAndPrint('!', data.get(Kind.Missing), null);
      }

      private void sortAndPrint(char prefix, List<Path> ul, Map<Path, Path> copies) {
        if (ul == null) {
          return;
        }
        ArrayList<Path> sortList = new ArrayList<Path>(ul);
        Collections.sort(sortList);
        for (Path s : sortList)  {
          if (!noStatusPrefix) {
            System.out.print(prefix);
            System.out.print(' ');
          }
          System.out.println(s);
          if (copies != null && copies.containsKey(s)) {
            System.out.println("  " + copies.get(s));
          }
        }
      }
    };

    StatusHandler statusHandler = new StatusHandler();
    int changeRev = cmdLineOpts.getSingleInt(BAD_REVISION, "--change");
    if (changeRev != BAD_REVISION) {
      cmd.change(changeRev);
    } else {
      List<String> revisions = cmdLineOpts.getList("--rev");
      int size = revisions.size();
      if (size > 1) {
        cmd.base(Integer.parseInt(revisions.get(size - 2))).revision(Integer.parseInt(revisions.get(size - 1)));
      } else if (size > 0) {
        cmd.base(Integer.parseInt(revisions.get(0)));
      }
    }
    cmd.execute(statusHandler);
    statusHandler.dump();
  }
View Full Code Here

Examples of org.tmatesoft.hg.core.HgStatusCommand

    errorCollector.assertTrue(r.isOk());
    Nodeid c1 = cmd.getCommittedRevision();
   
    // check that modified files are no longer reported as such
    TestStatus.StatusCollector status = new TestStatus.StatusCollector();
    new HgStatusCommand(hgRepo).all().execute(status);
    errorCollector.assertTrue(status.getErrors().isEmpty());
    errorCollector.assertTrue(status.get(Kind.Modified).isEmpty());
    errorCollector.assertEquals(1, status.get(dfB.getPath()).size());
    errorCollector.assertTrue(status.get(dfB.getPath()).contains(Kind.Clean));
   
View Full Code Here

Examples of org.tmatesoft.hg.core.HgStatusCommand

    assertFalse(newFileNode.exists());
    HgCommitCommand cmd = new HgCommitCommand(hgRepo).message("FIRST");
    Outcome r = cmd.execute();
    errorCollector.assertTrue(r.isOk());
    TestStatus.StatusCollector status = new TestStatus.StatusCollector();
    new HgStatusCommand(hgRepo).all().execute(status);
    errorCollector.assertTrue(status.getErrors().isEmpty());
    errorCollector.assertTrue(status.get(Kind.Added).isEmpty());
    errorCollector.assertTrue(status.get(newFileNode.getPath()).contains(Kind.Clean));
    //
    errorCollector.assertTrue(newFileNode.exists());
View Full Code Here

Examples of org.tmatesoft.hg.core.HgStatusCommand

    RepoUtils.modifyFileAppend(modifiedFile, " 1 \n");
    //
    new HgAddRemoveCommand(hgRepo).add(newFilePath).remove(dfD.getPath()).execute();
    //
    TestStatus.StatusCollector status = new TestStatus.StatusCollector();
    new HgStatusCommand(hgRepo).all().execute(status);
    assertTrue(status.getErrors().isEmpty());
    assertTrue(status.get(Kind.Added).contains(newFilePath));
    assertTrue(status.get(Kind.Modified).contains(dfB.getPath()));
    assertTrue(status.get(Kind.Removed).contains(dfD.getPath()));
    assertEquals(DEFAULT_BRANCH_NAME, hgRepo.getWorkingCopyBranchName());
    //
    final int lastClogRevision = hgRepo.getChangelog().getLastRevision();
    final int lastManifestRev = hgRepo.getManifest().getLastRevision();
    CommitFacility cf = new CommitFacility(Internals.getInstance(hgRepo), lastClogRevision);
    cf.add(hgRepo.getFileNode("xx"), new FileContentSupplier(hgRepo, newFile));
    cf.add(dfB, new FileContentSupplier(hgRepo, modifiedFile));
    cf.forget(dfD);
    cf.branch("another-branch");
    Transaction tr = newTransaction(hgRepo);
    Nodeid commitRev = cf.commit("Commit to fail",  tr);
    tr.rollback();
    //
    errorCollector.assertEquals(lastClogRevision, hgRepo.getChangelog().getLastRevision());
    errorCollector.assertEquals(lastManifestRev, hgRepo.getManifest().getLastRevision());
    errorCollector.assertEquals(DEFAULT_BRANCH_NAME, DirstateReader.readBranch(Internals.getInstance(hgRepo)));
    errorCollector.assertFalse(hgRepo.getChangelog().isKnown(commitRev));
    errorCollector.assertFalse(hgRepo.getFileNode("xx").exists());
    // check dirstate
    status = new TestStatus.StatusCollector();
    new HgStatusCommand(hgRepo).all().execute(status);
    errorCollector.assertTrue(status.getErrors().isEmpty());
    errorCollector.assertTrue(status.get(Kind.Added).contains(newFilePath));
    errorCollector.assertTrue(status.get(Kind.Modified).contains(dfB.getPath()));
    errorCollector.assertTrue(status.get(Kind.Removed).contains(dfD.getPath()));
   
View Full Code Here

Examples of org.tmatesoft.hg.core.HgStatusCommand

  public void testStatusCommand() throws Exception {
    repo = Configuration.get().find("status-subrepo");
    statusParser = new StatusOutputParser();
    eh = new ExecHelper(statusParser, repo.getWorkingDir());
    TestStatus.StatusReporter sr = new TestStatus.StatusReporter(errorCollector, statusParser);
    HgStatusCommand cmd = new HgStatusCommand(repo).all();
    TestStatus.StatusCollector sc;

    eh.run("hg", "status", "-A", "-S");
    cmd.subrepo(true);
    cmd.execute(sc = new TestStatus.StatusCollector());
    sr.report("status -A -S", sc);
   
    eh.run("hg", "status", "-A", "-S");
    cmd.subrepo(false);
    cmd.execute(sc = new TestStatus.StatusCollector());
    sr.report("status -A", sc);
   
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.