public void testDeleteCheckedoutFileUptodateParent() throws IOException, SecurityException, NoSuchMethodException, IllegalAccessException, IllegalAccessException, IllegalArgumentException, IllegalArgumentException, InvocationTargetException { File parent = new File(testRoot, "parent"); parent.mkdirs(); // create uptodate file and folder File file = new File(parent, "file"); file.createNewFile(); add(parent, file); refreshImmediatelly(parent); refreshImmediatelly(file); ensureMutable(file); refreshImmediatelly(file); FileInformation info = cache.getInfo(file); assertEquals(FileInformation.STATUS_VERSIONED_CHECKEDOUT, info.getStatus()); info = cache.getInfo(parent); assertEquals(FileInformation.STATUS_VERSIONED_UPTODATE, info.getStatus()); // delete file assertTrue(delete(file)); refreshImmediatelly(file); refreshImmediatelly(parent); // test assertFalse(file.exists()); // file is deleted info = cache.getInfo(file); assertEquals( FileInformation.STATUS_UNKNOWN, info.getStatus()); // chache keeps track of it as unknown info = cache.getInfo(parent); assertEquals(FileInformation.STATUS_VERSIONED_CHECKEDOUT, info.getStatus()); }
public void testDeleteViewPrivate() throws IOException, SecurityException, NoSuchMethodException, IllegalAccessException, IllegalAccessException, IllegalArgumentException, IllegalArgumentException, InvocationTargetException { File file = new File(testRoot, "file"); file.createNewFile(); refreshImmediatelly(file); // create notmanaged file FileInformation info = cache.getInfo(file); assertEquals(FileInformation.STATUS_NOTVERSIONED_NEWLOCALLY, info.getStatus()); // test assertFalse(delete(file)); // interceptor refused to handle the file // // however, let's call delete on the interceptor // interceptorDelete(file); // refreshImmediatelly(file); // // // test // assertFalse(file.exists()); // file is deleted // info = cache.getInfo(file); // assertEquals(FileInformation.STATUS_UNKNOWN, info.getStatus()); // chache keeps // track of it as unknown }
private void refreshImmediatelly(File file) throws SecurityException, NoSuchMethodException, IllegalAccessException, IllegalAccessException, IllegalArgumentException, IllegalArgumentException, InvocationTargetException { FileUtil.refreshFor(file.getParentFile()); Method m = cache.getClass().getDeclaredMethod("refresh", new Class[] {File.class, boolean.class}); m.setAccessible(true); m.invoke(cache, new Object[] {file, true}); }
private void setLocalDirectory(Client client, File[] files) throws IllegalCommandException { if (files.length == 0) { return; } File commonParent; if (files[0].isDirectory()) { // XXX it does not work for checkout commonParent = files[0]; } else { commonParent = files[0].getParentFile(); } for (int i = 1; i < files.length; i++) { if (!Utils.isParentOrEqual(commonParent, files[i])) { for (; ; ) { commonParent = commonParent.getParentFile(); if (commonParent == null) throw new IllegalCommandException("Files do not have common parent!"); // NOI18N if (Utils.isParentOrEqual(commonParent, files[i])) { break; } } } } // we must not run commands from within folders that are not yet in CVS, try to find the closest // uptodate parent FileStatusCache cache = CvsVersioningSystem.getInstance().getStatusCache(); for (File versionedCommonParent = commonParent; versionedCommonParent != null; versionedCommonParent = versionedCommonParent.getParentFile()) { FileInformation info = cache.getStatus(versionedCommonParent); if (info.getStatus() == FileInformation.STATUS_VERSIONED_UPTODATE) { commonParent = versionedCommonParent; break; } } client.setLocalPath(commonParent.getAbsolutePath()); }
public void testMoveFromNotManagedFileToNotManaged() throws IOException, SecurityException, NoSuchMethodException, IllegalAccessException, IllegalAccessException, IllegalArgumentException, IllegalArgumentException, InvocationTargetException { File from = File.createTempFile("fromfile", null); from.createNewFile(); File to = File.createTempFile("tofile", null); refreshImmediatelly(to); refreshImmediatelly(from); FileInformation info = cache.getInfo(from); assertEquals(FileInformation.STATUS_NOTVERSIONED_NOTMANAGED, info.getStatus()); info = cache.getInfo(to); assertEquals(FileInformation.STATUS_NOTVERSIONED_NOTMANAGED, info.getStatus()); assertFalse(move(from, to)); // interceptor refused to handle the file // however, let's call move on the interceptor interceptorMove(from, to); refreshImmediatelly(to); refreshImmediatelly(from); // test assertFalse(from.exists()); // from is gone assertTrue(to.exists()); // to was created info = cache.getInfo(from); assertEquals( FileInformation.STATUS_NOTVERSIONED_NOTMANAGED, info.getStatus()); // once notmanaged, stays notmanaged info = cache.getInfo(to); assertEquals( FileInformation.STATUS_NOTVERSIONED_NOTMANAGED, info.getStatus()); // --------------- "" ------------- }
public void testMoveFromViewPrivateFileToViewPrivateFolder() throws IOException, SecurityException, NoSuchMethodException, IllegalAccessException, IllegalAccessException, IllegalArgumentException, IllegalArgumentException, InvocationTargetException { File fromParent = new File(testRoot, "fromparent"); fromParent.mkdirs(); File toParent = new File(testRoot, "toparent"); toParent.mkdirs(); // create uptodate file and folder File from = new File(fromParent, "fromfile"); from.createNewFile(); File to = new File(toParent, "tofile"); to.createNewFile(); add(fromParent, toParent); refreshImmediatelly(fromParent); refreshImmediatelly(toParent); refreshImmediatelly(to); refreshImmediatelly(from); FileInformation info; info = cache.getInfo(fromParent); assertEquals(FileInformation.STATUS_VERSIONED_UPTODATE, info.getStatus()); info = cache.getInfo(toParent); assertEquals(FileInformation.STATUS_VERSIONED_UPTODATE, info.getStatus()); info = cache.getInfo(from); assertEquals(FileInformation.STATUS_NOTVERSIONED_NEWLOCALLY, info.getStatus()); info = cache.getInfo(to); assertEquals(FileInformation.STATUS_NOTVERSIONED_NEWLOCALLY, info.getStatus()); // test assertFalse(move(from, to)); // interceptor refused to handle the file // however, let's call move on the interceptor interceptorMove(from, to); refreshImmediatelly(to); refreshImmediatelly(from); // test assertFalse(from.exists()); // from is gone assertTrue(to.exists()); // to was created info = cache.getInfo(from); assertEquals(FileInformation.STATUS_UNKNOWN, info.getStatus()); // cache keeps track as unknown info = cache.getInfo(to); assertEquals( FileInformation.STATUS_NOTVERSIONED_NEWLOCALLY, info.getStatus()); // --------------- "" ------------- }