/** * Update the listed files from the repository * * @param client The client to use to perform the update with * @param listener The listener to receive notifications of updated files * @param theFiles The set of files to update * @param force Whether to do a forced "clean copy" update (override local changes) * @return UpdateServerResponse with information about the update * @throws CommandAbortedException * @throws CommandException * @throws AuthenticationException * @throws InvalidCvsRootException */ synchronized UpdateServerResponse doUpdateFiles( BlueJCvsClient client, UpdateListener listener, Set theFiles, boolean force) throws CommandAbortedException, CommandException, AuthenticationException { UpdateCommand command = new UpdateCommand(); command.setFiles(listToFileArray(theFiles)); command.setCleanCopy(force); command.setRecursive(false); command.setBuildDirectories(true); command.setPruneDirectories(true); UpdateServerResponse updateServerResponse = new UpdateServerResponse(listener, client); client.getEventManager().addCVSListener(updateServerResponse); client.setLocalPath(projectPath.getAbsolutePath()); printCommand(command, client); setupConnection(client); try { adminHandler.setMildManneredMode(true); client.executeCommand(command, globalOptions); updateServerResponse.waitForExecutionToFinish(); } finally { // restore previous excludes setting client.getEventManager().removeCVSListener(updateServerResponse); disconnect(client); adminHandler.setMildManneredMode(false); } updateServerResponse.setConflictMap(client.getConflictFiles()); return updateServerResponse; }
/** * Get status of all the given files. Returns a List of TeamStatusInfo. * * @param files The files whose status to retrieve * @param remoteDirs These are the directories which we know are in the repository. Any file in * the files list which does not exist locally but for which the containing directory is in * the repository, should have that directory listed here. * @throws CommandAbortedException * @throws CommandException * @throws AuthenticationException * @throws InvalidCvsRootException */ public synchronized StatusServerResponse getStatus(Client client, Set files, Set remoteDirs) throws CommandAbortedException, CommandException, AuthenticationException { // setupConnection(); // Client client = getClient(); setupConnection(client); // Now we can use the cvs "status" command to get status on the // remaining files. StatusCommand statusCommand = new StatusCommand(); statusCommand.setFiles(listToFileArray(files)); StatusServerResponse statusServerResponse = new StatusServerResponse(); client.getEventManager().addCVSListener(statusServerResponse); client.setLocalPath(projectPath.getAbsolutePath()); printCommand(statusCommand, client); adminHandler.setMildManneredMode(true); try { client.executeCommand(statusCommand, globalOptions); statusServerResponse.waitForExecutionToFinish(); } finally { adminHandler.setMildManneredMode(false); client.getEventManager().removeCVSListener(statusServerResponse); disconnect(client); } return statusServerResponse; }
/** * Remove the files in an array of Files from the repository. * * @param files the files to remove. * @throws CommandException * @throws CommandAbortedException * @throws AuthenticationException * @throws InvalidCvsRootException */ BasicServerResponse removeFromRepository(Client client, Collection files) throws CommandException, CommandAbortedException, AuthenticationException { BasicServerResponse basicServerResponse = new BasicServerResponse(); if (files.size() < 1) { basicServerResponse.commandTerminated(null); return basicServerResponse; } setupConnection(client); // setupConnection(); // Client client = getClient(); RemoveCommand removeCommand = new RemoveCommand(); removeCommand.setFiles(listToFileArray(files)); client.getEventManager().addCVSListener(basicServerResponse); client.setLocalPath(projectPath.getAbsolutePath()); printCommand(removeCommand, client); try { adminHandler.setMildManneredMode(true); client.executeCommand(removeCommand, globalOptions); basicServerResponse.waitForExecutionToFinish(); } finally { client.getEventManager().removeCVSListener(basicServerResponse); disconnect(client); adminHandler.setMildManneredMode(false); } return basicServerResponse; }
/** * Find the remote directories which also exist locally, but are not locally under version * control. */ public synchronized Set getRemoteDirs(Client client) throws AuthenticationException, CommandException { adminHandler.setMildManneredMode(true); Set remoteDirs = new HashSet(); try { getRemoteFiles(client, null, projectPath, remoteDirs, true); } finally { adminHandler.setMildManneredMode(false); } return remoteDirs; }
/** * Get a list of files which are in the repository, but which are not in the local project. This * includes both files which have been locally deleted, and files which have been added to the * repository from another location. * * @param remoteDirs This set will have all remote directories which are found added to it. * @throws InvalidCvsRootException * @throws AuthenticationException * @throws CommandException */ public synchronized List getRemoteFiles(Client client, Set remoteDirs) throws AuthenticationException, CommandException { List files = new LinkedList(); adminHandler.setMildManneredMode(true); try { getRemoteFiles(client, files, projectPath, remoteDirs, false); } finally { adminHandler.setMildManneredMode(false); } return files; }
/** * Set the revision of a versioned file to the given revision, without altering the file contents. * (This is a way to "update" but keep the current file contents. The server doesn't need to be * contacted). */ public synchronized void setFileVersion(File file, String revision) throws IOException { Entry cvsEntry = adminHandler.getEntry(file); if (cvsEntry != null) { cvsEntry.setRevision(revision); } else { cvsEntry = new Entry(); cvsEntry.setName(file.getName()); cvsEntry.setRevision(revision); } adminHandler.setEntry(file, cvsEntry); }
/** * Get the locally deleted files (files which are under version control, and which existed * locally, but which have been deleted locally). * * @param set The set to store the locally deleted files in * @param dir The directory to look for deleted files in (non-recursively) * @throws IOException */ public void getLocallyDeletedFiles(Set set, File dir) throws IOException { Iterator i = adminHandler.getEntries(dir); while (i.hasNext()) { Entry entry = (Entry) i.next(); File file = new File(dir, entry.getName()); if (!file.exists() && !entry.isDirectory()) { set.add(new File(dir, entry.getName())); } } }
/** Prepare a newly created directory for version control. */ public void prepareCreateDir(File dir) { adminHandler.prepareCreateDir(dir); }
/* * (non-Javadoc) * @see bluej.groupwork.Repository#prepareDeleteDir(java.io.File) */ public boolean prepareDeleteDir(File dir) { /* Move the CVS metadata into a new location */ adminHandler.prepareDeleteDir(dir); return true; }
/** Check whether a directory is under CVS control. */ boolean isDirectoryUnderCVS(File dir) { String apath = adminHandler.getMetaDataPath(dir.getAbsolutePath()); dir = new File(apath); return (new File(dir, "CVS").isDirectory()); }