Package org.eclipse.jgit.storage.file

Examples of org.eclipse.jgit.storage.file.LockFile.lock()


      // Fall through and write the file.
    }

    dst.getParentFile().mkdirs();
    LockFile lf = new LockFile(dst, FS.DETECTED);
    if (!lf.lock()) {
      throw new IOException("Cannot lock " + dst);
    }
    try {
      final OutputStream out = lf.getOutputStream();
      try {
View Full Code Here


        FileInputStream in = new FileInputStream(myWar);
        try {
          siteWar.getParentFile().mkdirs();

          LockFile lf = new LockFile(siteWar, FS.DETECTED);
          if (!lf.lock()) {
            throw new IOException("Cannot lock " + siteWar);
          }

          try {
            final OutputStream out = lf.getOutputStream();
View Full Code Here

   */
  public boolean lock() throws IOException {
    if (liveFile == null)
      throw new IOException(JGitText.get().dirCacheDoesNotHaveABackingFile);
    final LockFile tmp = new LockFile(liveFile, fs);
    if (tmp.lock()) {
      tmp.setNeedStatInformation(true);
      myLock = tmp;
      return true;
    }
    return false;
View Full Code Here

    RefUpdate updateRef = db.updateRef("refs/heads/master");
    updateRef.setNewObjectId(pid);
    LockFile lockFile1 = new LockFile(new File(db.getDirectory(),
        "refs/heads/master"), db.getFS());
    try {
      assertTrue(lockFile1.lock()); // precondition to test
      Result update = updateRef.update();
      assertEquals(Result.LOCK_FAILURE, update);
      assertEquals(opid, db.resolve("refs/heads/master"));
      LockFile lockFile2 = new LockFile(new File(db.getDirectory(),"refs/heads/master"),
          db.getFS());
View Full Code Here

      Result update = updateRef.update();
      assertEquals(Result.LOCK_FAILURE, update);
      assertEquals(opid, db.resolve("refs/heads/master"));
      LockFile lockFile2 = new LockFile(new File(db.getDirectory(),"refs/heads/master"),
          db.getFS());
      assertFalse(lockFile2.lock()); // was locked, still is
    } finally {
      lockFile1.unlock();
    }
  }
View Full Code Here

    // "someone" has branch X locked
    LockFile lockFile = new LockFile(new File(db.getDirectory(), toLock),
        db.getFS());
    try {
      assertTrue(lockFile.lock());

      // Now this is our test
      RefRename renameRef = db.renameRef(fromName, toName);
      Result result = renameRef.rename();
      assertEquals(Result.LOCK_FAILURE, result);
View Full Code Here

  }

  private void writeFile(final File p, final byte[] bin) throws IOException,
      ObjectWritingException {
    final LockFile lck = new LockFile(p, db.getFS());
    if (!lck.lock())
      throw new ObjectWritingException("Can't write " + p);
    try {
      lck.write(bin);
    } catch (IOException ioe) {
      throw new ObjectWritingException("Can't write " + p);
View Full Code Here

    final String head = db.getFullBranch();
    final ObjectId id = db.resolve(Constants.HEAD);
    if (!ObjectId.isId(head) && id != null) {
      final LockFile lf;
      lf = new LockFile(new File(db.getDirectory(), Constants.HEAD), db.getFS());
      if (!lf.lock())
        throw new IOException(MessageFormat.format(CLIText.get().cannotLock, Constants.HEAD));
      lf.write(id);
      if (!lf.commit())
        throw new IOException(CLIText.get().cannotDeatchHEAD);
    }
View Full Code Here

      @Override
      protected void writeFile(final String name, final byte[] content)
          throws IOException {
        final File file = new File(db.getDirectory(), name);
        final LockFile lck = new LockFile(file, db.getFS());
        if (!lck.lock())
          throw new ObjectWritingException(MessageFormat.format(CLIText.get().cantWrite, file));
        try {
          lck.write(content);
        } catch (IOException ioe) {
          throw new ObjectWritingException(MessageFormat.format(CLIText.get().cantWrite, file));
View Full Code Here

    if (meta == null)
      return;
    final LockFile lock = new LockFile(new File(meta, "FETCH_HEAD"),
        transport.local.getFS());
    try {
      if (lock.lock()) {
        final Writer w = new OutputStreamWriter(lock.getOutputStream());
        try {
          for (final FetchHeadRecord h : fetchHeadUpdates) {
            h.write(w);
            result.add(h);
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.