String repositoryURL = "svn:
SVNURL repositoryURL = null; try { repositoryURL = SVNURL.parseURIEncoded("svn: } catch (SVNException e) { }
    public static void main(String[] args) {        /*         * Default values:         */        /*         * Assuming that 'svn://localhost/rep' is an existing          * repository path         */        String repositoryURL = "svn://localhost/testRep";        String name = "userName";        String password = "userPassword";        String myWorkingCopyPath = "/MyWorkingCopy";        String importDir = "/importDir";        String importFile = importDir + "/importFile.txt";        String importFileText = "This unversioned file is imported into a repository";                String newDir = "/newDir";        String newFile = newDir + "/newFile.txt";        String fileText = "This is a new file added to the working copy";        if (args != null) {            /*             * Obtains a URL that represents an already existing repository             */            repositoryURL = (args.length >= 1) ? args[0] : repositoryURL;            /*             * Obtains a path to be a working copy root directory             */            myWorkingCopyPath = (args.length >= 2) ? args[1] : myWorkingCopyPath;            /*             * Obtains an account name              */            name = (args.length >= 3) ? args[2] : name;            /*             * Obtains a password             */            password = (args.length >= 4) ? args[3] : password;        }        /*         * That's where a new directory will be created         */        String url = repositoryURL + "/MyRepos";        /*         * That's where '/MyRepos' will be copied to (branched)         */        String copyURL = repositoryURL + "/MyReposCopy";        /*         * That's where a local directory will be imported into.         * Note that it's not necessary that the '/importDir' directory must already         * exist - the SVN repository will take care of creating it.          */        String importToURL = url + importDir;                      /*         * Initializes the library (it must be done before ever using the         * library itself)         */        setupLibrary();                myCommitEventHandler = new CommitEventHandler();                myUpdateEventHandler = new UpdateEventHandler();                myWCEventHandler = new WCEventHandler();                /*         * Creates default run-time configuration options. Default options created         * in this way use the Subversion run-time configuration area (for instance,         * on Windows platform it can be found in the         * 'Documents and Settings\UserName\%APPDATA%\Subversion directory).          *          * readonly = true - not to save  any configuration changes that can be done          * during the program run to a config file (config settings will only          * be read to initialize; to enable changes the readonly flag should be set         * to false).         *          * SVNWCUtil is a utility class that creates default options.         */        ISVNOptions options = SVNWCUtil.createDefaultOptions(true);                /*         * Creates an instance of SVNClientManager providing authentication         * information (name, password) and run-time configuration options         */        ourClientManager = SVNClientManager.newInstance(options, name, password);                /*         * Sets a custom event handler for operations handled by an SVNCommitClient          * instance         */        ourClientManager.getCommitClient().setEventHandler(myCommitEventHandler);                /*         * Sets a custom event handler for operations handled by an SVNUpdateClient          * instance         */        ourClientManager.getUpdateClient().setEventHandler(myUpdateEventHandler);        /*         * Sets a custom event handler for operations handled by an SVNWCClient          * instance         */        ourClientManager.getWCClient().setEventHandler(myWCEventHandler);        long committedRevision = -1;        System.out.println("Making a new directory at '" + url + "'...");        try{            /*             * creating a new version comtrolled directory in a repository and              * displaying what revision the repository was committed to             */            committedRevision = makeDirectory(url, "making a new directory at '" + url + "'").getNewRevision();        }catch(SVNException svne){            error("error while making a new directory at '" + url + "'", svne);        }        System.out.println("Committed to revision " + committedRevision);        System.out.println();        File anImportDir = new File(importDir);        File anImportFile = new File(anImportDir, SVNPathUtil.tail(importFile));        /*         * creating a new local directory - "./importDir" and a new file -          * "./importDir/importFile.txt" that will be imported into the repository         * (into the '/MyRepos/importDir' directory)          */        createLocalDir(anImportDir, new File[]{anImportFile}, new String[]{importFileText});                System.out.println("Importing a new directory into '" + importToURL + "'...");        try{            /*             * recursively importing an unversioned directory into a repository              * and displaying what revision the repository was committed to             */            boolean isRecursive = true;            committedRevision = importDirectory(anImportDir, importToURL, "importing a new directory '" + anImportDir.getAbsolutePath() + "'", isRecursive).getNewRevision();        }catch(SVNException svne){            error("error while importing a new directory '" + anImportDir.getAbsolutePath() + "' into '" + importToURL + "'", svne);        }        System.out.println("Committed to revision " + committedRevision);        System.out.println();                        /*         * creates a local directory where the working copy will be checked out into         */        File wcDir = new File(myWorkingCopyPath);        if (wcDir.exists()) {            error("the destination directory '"                    + wcDir.getAbsolutePath() + "' already exists!", null);        }        wcDir.mkdirs();        System.out.println("Checking out a working copy from '" + url + "'...");        long checkoutRevision = -1;        try {            /*             * recursively checking out a working copy from url into wcDir,             * SVNRevision.HEAD means the latest revision to be checked out              */            checkoutRevision = checkout(url, SVNRevision.HEAD, wcDir, true);        } catch (SVNException svne) {            error("error while checking out a working copy for the location '"                            + url + "'", svne);        }        System.out.println();                /*         * recursively displaying info for wcDir at the current working revision          * in the manner of 'svn info -R' command         */        try {            showInfo(wcDir, SVNRevision.WORKING, true);        } catch (SVNException svne) {            error("error while recursively getting info for the working copy at'"                    + wcDir.getAbsolutePath() + "'", svne);        }        System.out.println();        File aNewDir = new File(wcDir, newDir);        File aNewFile = new File(aNewDir, SVNPathUtil.tail(newFile));        /*         * creating a new local directory - "wcDir/newDir" and a new file -          * "/MyWorkspace/newDir/newFile.txt"          */        createLocalDir(aNewDir, new File[]{aNewFile}, new String[]{fileText});                System.out.println("Recursively scheduling a new directory '" + aNewDir.getAbsolutePath() + "' for addition...");        try {            /*             * recursively scheduling aNewDir for addition             */            addEntry(aNewDir);        } catch (SVNException svne) {            error("error while recursively adding the directory '"                    + aNewDir.getAbsolutePath() + "'", svne);        }        System.out.println();        boolean isRecursive = true;        boolean isRemote = true;        boolean isReportAll = false;        boolean isIncludeIgnored = true;        boolean isCollectParentExternals = false;        System.out.println("Status for '" + wcDir.getAbsolutePath() + "':");        try {            /*             * status will be recursive on wcDir, will also cover the repository,              * won't cover unmodified entries, will disregard             * svn:ignore property ignores (if any), will ignore externals definitions             * (anyway this program doesn't deal with externals;))             */            showStatus(wcDir, isRecursive, isRemote, isReportAll,                    isIncludeIgnored, isCollectParentExternals);        } catch (SVNException svne) {            error("error while recursively performing status for '"                    + wcDir.getAbsolutePath() + "'", svne);        }        System.out.println();        System.out.println("Updating '" + wcDir.getAbsolutePath() + "'...");        long updatedRevision = -1;        try {            /*             * recursively updates wcDir to the latest revision (SVNRevision.HEAD);             * it's useful to do in real life as a working copy may contain out             * of date entries:)              */            updatedRevision = update(wcDir, SVNRevision.HEAD, true);        } catch (SVNException svne) {            error("error while recursively updating the working copy at '"                    + wcDir.getAbsolutePath() + "'", svne);        }        System.out.println("Updated to revision " + updatedRevision + ".");        System.out.println("Committing changes for '" + wcDir.getAbsolutePath() + "'...");        try {            /*             * commiting changes in wcDir to the repository with not saving items              * locked (if any) after the commit succeeds; this will add aNewDir &              * aNewFile to the repository.              */            committedRevision = commit(wcDir, false,                    "'/newDir' with '/newDir/newFile.txt' were added")                    .getNewRevision();        } catch (SVNException svne) {            error("error while committing changes to the working copy at '"                    + wcDir.getAbsolutePath()                    + "'", svne);        }        System.out.println("Committed to revision " + committedRevision);        System.out.println();        System.out                .println("Locking (with stealing if the entry is already locked) '"                        + aNewFile.getAbsolutePath() + "'.");        try {            /*             * locking aNewFile with stealing (if it has been already locked by someone             * else) and a lock comment             */            lock(aNewFile, true, "locking '/newDir/newFile.txt'");        } catch (SVNException svne) {            error("error while locking the working copy file '"                    + aNewFile.getAbsolutePath() + "'", svne);        }        System.out.println();        System.out.println("Status for '" + wcDir.getAbsolutePath() + "':");        try {            /*             * displaying status once again to see the file is really locked             */            showStatus(wcDir, isRecursive, isRemote, isReportAll,                    isIncludeIgnored, isCollectParentExternals);        } catch (SVNException svne) {            error("error while recursively performing status for '"                    + wcDir.getAbsolutePath() + "'", svne);        }        System.out.println();        System.out.println("Copying '" + url + "' to '" + copyURL + "'...");        try {            /*             * making a branch of url at copyURL - that is URL->URL copying             * with history; not moving url, only copying;             *              * checkoutRevision is to concretize url             */            committedRevision = copy(url,                    SVNRevision.create(checkoutRevision), copyURL, false,                    "remotely copying '" + url + "' to '" + copyURL + "'")                    .getNewRevision();        } catch (SVNException svne) {            error("error while copying '" + url + "' to '"                    + copyURL + "'", svne);        }       /*        * displaying what revision the repository was committed to        */        System.out.println("Committed to revision " + committedRevision);        System.out.println();        System.out.println("Switching '" + wcDir.getAbsolutePath() + "' to '"                + copyURL + "'...");        try {            /*             * recursively switching wcDir to copyURL to the latest revision              * (SVNRevision.HEAD)             */            updatedRevision = switchToURL(wcDir, copyURL,                    SVNRevision.HEAD, true);        } catch (SVNException svne) {            error("error while switching '"                    + wcDir.getAbsolutePath() + "' to '" + copyURL + "'", svne);        }        System.out.println();        /*         * recursively displaying info for the working copy once again to see         * it was really switched to a new URL         */        try {            showInfo(wcDir, SVNRevision.WORKING, true);        } catch (SVNException svne) {            error("error while recursively getting info for the working copy at'"                    + wcDir.getAbsolutePath() + "'", svne);        }        System.out.println();        System.out.println("Scheduling '" + aNewDir.getAbsolutePath() + "' for deletion ...");        try {            /*             * forcing aNewDir to be scheduled for deletion             */            delete(aNewDir, true);        } catch (SVNException svne) {            error("error while schediling '"                    + wcDir.getAbsolutePath() + "' for deletion", svne);        }        System.out.println();        System.out.println("Status for '" + wcDir.getAbsolutePath() + "':");        try {            /*             * recursively displaying status once more to see whether aNewDir             * was really scheduled for deletion               */            showStatus(wcDir, isRecursive, isRemote, isReportAll,                    isIncludeIgnored, isCollectParentExternals);        } catch (SVNException svne) {            error("error while recursively performing status for '"                    + wcDir.getAbsolutePath() + "'", svne);        }        System.out.println();        System.out.println("Committing changes for '" + wcDir.getAbsolutePath() + "'...");        try {            /*             * lastly committing changes in wcDir to the repository; all items that             * were locked by the user (if any) will be unlocked after the commit              * succeeds; this commit will remove aNewDir from the repository.              */            committedRevision = commit(                    wcDir,                    false,                    "deleting '" + aNewDir.getAbsolutePath()                            + "' from the filesystem as well as from the repository").getNewRevision();        } catch (SVNException svne) {            error("error while committing changes to the working copy '"                    + wcDir.getAbsolutePath()                    + "'", svne);        }        System.out.println("Committed to revision " + committedRevision);        System.exit(0);    }