Package org.tmatesoft.hg.core

Examples of org.tmatesoft.hg.core.HgIOException


    File backup = new File(parentDir, f.getName() + ".hg4j.orig");
    if (backup.exists()) {
      backup.delete();
    }
    if (!f.renameTo(backup)) {
      throw new HgIOException(String.format("Failed to backup %s to %s", f.getName(), backup.getName()), backup);
    }
    if (!copy.renameTo(f)) {
      throw new HgIOException(String.format("Failed to bring on-write copy in place (%s to %s)", copy.getName(), f.getName()), copy);
    }
    f.setLastModified(lm);
    record(f, backup);
    return f;
  }
View Full Code Here


      RollbackEntry e = it.next();
      if (!e.success) {
        throw new HgInvalidStateException(String.format("Attempt to commit transaction without successful clearance of file %s", e.origin));
      }
      if (e.failure != null) {
        throw new HgIOException("Can't close transaction with a failure.", e.failure, e.origin);
      }
      if (!e.keepBackup && e.backup != null) {
        e.backup.delete();
      }
      it.remove();
View Full Code Here

      RollbackEntry e = it.next();
      e.origin.delete();
      if (e.backup != null) {
        if (!e.backup.renameTo(e.origin)) {
          String msg = String.format("Transaction rollback failed, could not rename backup %s back to %s", e.backup.getName(), e.origin.getName());
          throw new HgIOException(msg, e.origin);
        }
        // renameTo() doesn't update timestamp, while the rest of the code relies
        // on file timestamp to detect revlog changes. Rollback *is* a change,
        // even if it brings the old state.
        e.origin.setLastModified(System.currentTimeMillis());
View Full Code Here

    try {
      f.getParentFile().mkdirs();
      f.createNewFile();
      return f;
    } catch (IOException ex) {
      throw new HgIOException("Failed to create new file", ex, f);
    }
  }
View Full Code Here

        Nodeid nid = bookmarks.get(bm);
        fileWriter.write(String.format("%s %s\n", nid.toString(), bm));
      }
      fileWriter.flush();
    } catch (IOException ex) {
      throw new HgIOException("Failed to serialize bookmarks", ex, bookmarksFile);
    } finally {
      try {
        if (fileWriter != null) {
          fileWriter.close();
        }
View Full Code Here

      throw new IllegalArgumentException();
    }
  }

  public void serialize(final DataSerializer out) throws HgIOException, HgRuntimeException {
    final HgIOException failure[] = new HgIOException[1];
    try {
      // TODO #workingCopy API is very limiting, CancelledException is inconvenient,
      // and absence of HgIOException is very uncomfortable
      file.workingCopy(new ByteChannel() {
       
        public int write(ByteBuffer buffer) throws IOException {
          try {
            if (buffer.hasArray()) {
              out.write(buffer.array(), buffer.position(), buffer.remaining());
            }
            int rv = buffer.remaining();
            buffer.position(buffer.limit()); // pretend we've consumed the data
            return rv;
          } catch (HgIOException ex) {
            failure[0] = ex;
            IOException e = new IOException();
            ex.initCause(ex); // XXX Java 1.5
            throw e;
          }
        }
      });
    } catch (HgInvalidFileException ex) {
      if (failure[0] != null) {
        throw failure[0];
      }
      throw new HgIOException("Write failure", ex, new File(file.getRepo().getWorkingDir(), file.getPath().toString()));
    } catch (CancelledException ex) {
      throw new HgInvalidStateException("Our channel doesn't cancel here");
    }
  }
View Full Code Here

        sb.append("dotencode\n");
      }
      requiresStream.write(sb.toString().getBytes());
      requiresStream.close();
    } catch (IOException ex) {
      throw new HgIOException("Failed to initialize empty repo", ex, requiresFile);
    }
    if ((requiresFlags & STORE) != 0) {
      new File(repoDir, "store").mkdir(); // with that, hg verify says ok.
    }
  }
View Full Code Here

      serialize(dirstate);
      dirstate.close();
      tr.done(dirstateFile);
    } catch (IOException ex) {
      tr.failure(dirstateFile, ex);
      throw new HgIOException("Can't write down new directory state", ex, dirstateFile);
    }
  }
View Full Code Here

          hgRepo.getSessionContext().getLog().dump(getClass(), Warn, ex, "Failed get file access rights");
        }
      }
    } catch (IOException ex) {
      String msg = String.format("Failed to write file %s to the working directory", fname);
      throw new HgIOException(msg, ex, dest);
    }
  }
View Full Code Here

      while ((r = fis.read(buffer, 0, buffer.length)) > 0) {
        out.write(buffer, 0, r);
      }
     
    } catch (IOException ex) {
      throw new HgIOException("Failed to serialize bundle", bundleFile);
    } finally {
      new FileUtils(log, this).closeQuietly(fis, bundleFile);
    }
  }
View Full Code Here

TOP

Related Classes of org.tmatesoft.hg.core.HgIOException

Copyright © 2018 www.massapicom. 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.