Package org.eclipse.jgit.internal.storage.file

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


    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

   */
  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

    if (meta == null)
      return;
    final LockFile lock = new LockFile(new File(meta, "FETCH_HEAD"), //$NON-NLS-1$
        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

  }

  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

    } else {
      out = Constants.encode(text);
    }

    final LockFile lf = new LockFile(getFile(), fs);
    if (!lf.lock())
      throw new LockFailedException(getFile());
    try {
      lf.setNeedSnapshot(true);
      lf.write(out);
      if (!lf.commit())
View Full Code Here

    writeTrashFile("file.txt", "content2");
    git.add().addFilepattern("file.txt").call();
    assertNotNull(git.commit().setMessage("edit file").call());

    LockFile lf = new LockFile(db.getIndexFile(), db.getFS());
    assertTrue(lf.lock());
    try {
      git.checkout().setName(commit1.name()).call();
      fail("JGitInternalException not thrown");
    } catch (JGitInternalException e) {
      assertTrue(e.getCause() instanceof LockFailedException);
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

    } else {
      out = Constants.encode(text);
    }

    final LockFile lf = new LockFile(getFile(), fs);
    if (!lf.lock())
      throw new LockFailedException(getFile());
    try {
      lf.setNeedSnapshot(true);
      lf.write(out);
      if (!lf.commit())
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.