r1679 - isis-fish/trunk/src/main/java/fr/ifremer/isisfish/vcs
Author: chatellier Date: 2008-12-17 17:18:41 +0000 (Wed, 17 Dec 2008) New Revision: 1679 Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/vcs/VCS.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/vcs/VCSNone.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/vcs/VCSSVN.java Log: Update cvs svn, return conflit file on switch Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/vcs/VCS.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/vcs/VCS.java 2008-12-17 13:40:51 UTC (rev 1678) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/vcs/VCS.java 2008-12-17 17:18:41 UTC (rev 1679) @@ -338,9 +338,10 @@ * trunk. * @param version version to go, if null trunk is used, otherwize * tags/version is used + * @return a list of all file in conflict * @throws VCSException */ - void setTag(VersionNumber version) throws VCSException; + List<File> setTag(VersionNumber version) throws VCSException; /** * Change host. Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/vcs/VCSNone.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/vcs/VCSNone.java 2008-12-17 13:40:51 UTC (rev 1678) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/vcs/VCSNone.java 2008-12-17 17:18:41 UTC (rev 1679) @@ -196,8 +196,9 @@ return false; } - public void setTag(VersionNumber version) throws VCSException { + public List<File> setTag(VersionNumber version) throws VCSException { // do nothing + return null; } public String getTag() throws VCSException { Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/vcs/VCSSVN.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/vcs/VCSSVN.java 2008-12-17 13:40:51 UTC (rev 1678) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/vcs/VCSSVN.java 2008-12-17 17:18:41 UTC (rev 1679) @@ -1,4 +1,4 @@ -/* *##% IsisFish +/* *##% GeSi * Copyright (C) 2008 CodeLutin * * This program is free software: you can redistribute it and/or modify @@ -165,15 +165,15 @@ getSVNManager().getWCClient().doGetProperty(url, "", SVNRevision.HEAD, SVNRevision.HEAD); connectionState = ConnectionState.ON_LINE; - - if (log.isInfoEnabled()) { + + if(log.isInfoEnabled()) { log.info(_("isisfish.vcs.vcssvn.isconnected.switchto", - getRemoteRepository())); + getRemoteRepository())); } } catch (SVNException eee) { - if (log.isWarnEnabled()) { + if(log.isWarnEnabled()) { log.warn(_("isisfish.vcs.vcssvn.isconnected.switchoff", - getRemoteRepository())); + getRemoteRepository())); } connectionState = ConnectionState.OFF_LINE; } @@ -191,41 +191,39 @@ */ @Override public void checkProtocol() throws VCSException { - + // on doit verifier ici que seul le protocole a change // le doRelocate de svn, ne permet de ne change que // le protocol ou host par exemple // dans le cas d'un changement de path, le do relocate // echoue (operation non permise) - + try { // test que les protocoles, userInfo, host, port sont egaux. - + // copies locales File localRoot = getLocalRepository(); SVNInfo info = getSVNManager().getWCClient().doInfo(localRoot, SVNRevision.WORKING); SVNURL url = info.getURL(); - + // url distante (suposée) SVNURL newUrl = getRemoteURL(); - + // hack just for doRelocate to work newUrl = newUrl.setPath(url.getPath(), false); - + if (!url.getProtocol().equals(newUrl.getProtocol()) // http, svn ... - || (url.getUserInfo() == null && newUrl.getUserInfo() != url - .getUserInfo()) // username - || (url.getUserInfo() != null && !url.getUserInfo().equals( - newUrl.getUserInfo())) // username + || (url.getUserInfo() == null && newUrl.getUserInfo() != url.getUserInfo()) // username + || (url.getUserInfo() != null && !url.getUserInfo().equals(newUrl.getUserInfo())) // username || url.getPort() != newUrl.getPort() // 80 || !url.getHost().equals(newUrl.getHost())) { if (fireAction(VCSActionEvent.SWITCH_PROTOCOL)) { - if (log.isInfoEnabled()) { - log.info(_("isisfish.vcs.vcssvn.checkProtocol.relocate", - localRoot, url, newUrl)); + if(log.isInfoEnabled()) { + log.info(_("isisfish.vcs.vcssvn.checkProtocol.relocate", localRoot, + url, newUrl)); } - + // le relocate de SVNKit // ne supporte que le changement de protocole/host/port // pas le path @@ -234,7 +232,8 @@ } } } catch (SVNException e) { - throw new VCSException(_("isisfish.vcs.vcssvn.checkProtocol.error"), e); + throw new VCSException( + _("isisfish.vcs.vcssvn.checkProtocol.error"), e); } } @@ -346,7 +345,8 @@ // if can't commit if (!isWriteable()) { - throw new VCSException(_("isisfish.vcs.vcssvn.commit.errorreadonly")); + throw new VCSException( + _("isisfish.vcs.vcssvn.commit.errorreadonly")); } // list to array @@ -390,8 +390,7 @@ SVNDepth.INFINITY); // depth if (log.isInfoEnabled()) { - log.info(_("isisfish.vcs.vcssvn.global.torevision", commitInfo - .getNewRevision())); + log.info(_("isisfish.vcs.vcssvn.global.torevision", commitInfo.getNewRevision())); } } catch (SVNException e) { throw new VCSException(_("isisfish.vcs.vcssvn.commit.error"), e); @@ -400,7 +399,8 @@ public void add(List<File> files, String msg) throws VCSException { if (!isWriteable()) { - throw new VCSException(_("isisfish.vcs.vcssvn.add.errorreadonly")); + throw new VCSException( + _("isisfish.vcs.vcssvn.add.errorreadonly")); } try { if (fireAction(VCSActionEvent.ADD, files.toArray(new File[files @@ -463,9 +463,7 @@ true); // boolean allowUnversionedObstructions if (log.isInfoEnabled()) { - log - .info(_("isisfish.vcs.vcssvn.global.torevision", - newRevision)); + log.info(_("isisfish.vcs.vcssvn.global.torevision", newRevision)); } } } catch (SVNException eee) { @@ -475,7 +473,8 @@ public void delete(List<File> files, String msg) throws VCSException { if (!isWriteable()) { - throw new VCSException(_("isisfish.vcs.vcssvn.delete.errorreadonly")); + throw new VCSException( + _("isisfish.vcs.vcssvn.delete.errorreadonly")); } try { if (fireAction(VCSActionEvent.DELETE, files.toArray(new File[files @@ -639,7 +638,7 @@ public Map<File, String> getChanglog(List<File> files) throws VCSException { throw new UnsupportedOperationException("Not supported yet."); - + /*final Map<File, String> changLog = new HashMap<File, String>(); try { @@ -649,7 +648,7 @@ // Handler ISVNLogEntryHandler handler = new ISVNLogEntryHandler() { - + @Override public void handleLogEntry(SVNLogEntry logEntry) throws SVNException { @@ -795,8 +794,8 @@ // log if (log.isDebugEnabled()) { - log.debug(_("isisfish.vcs.vcssvn.global.filestatus", status - .getFile().getAbsolutePath(), status + log.debug(_("isisfish.vcs.vcssvn.global.filestatus", status.getFile() + .getAbsolutePath(), status .getRemoteContentsStatus().toString())); } @@ -805,9 +804,8 @@ // log if (log.isDebugEnabled()) { - log.debug(_( - "isisfish.vcs.vcssvn.global.foundUpdatedFile", - status.getFile().getAbsolutePath())); + log.debug(_("isisfish.vcs.vcssvn.global.foundUpdatedFile", status + .getFile().getAbsolutePath())); } result.add(status.getFile()); @@ -839,13 +837,13 @@ * @throws VCSException */ public boolean haveUpdate() throws VCSException { - + // c'est juste si la liste renvoyé par getUpdatedFile() n'est pas vide ? List<File> updatedFiles = getUpdatedFile(); - + boolean result = false; - - if (updatedFiles != null && !updatedFiles.isEmpty()) { + + if(updatedFiles != null && !updatedFiles.isEmpty()) { result = true; } return result; @@ -859,35 +857,29 @@ * @throws VCSException */ public boolean isOnRemote(File file) throws VCSException { - + File localFile = file; if (localFile == null) { localFile = getLocalRepository(); } - + boolean result = false; try { SVNStatusClient statusClient = getSVNManager().getStatusClient(); - SVNStatus status = statusClient - .doStatus(localFile, true /*remote*/); - + SVNStatus status = statusClient.doStatus(localFile, true /*remote*/); + SVNStatusType localStatus = status.getContentsStatus(); SVNStatusType remoteStatus = status.getRemoteContentsStatus(); - - if (log.isDebugEnabled()) { - log - .debug(_( - "isisfish.vcs.vcssvn.global.filelocalandremotestatus", - localFile.getAbsolutePath(), localStatus, - remoteStatus)); + + if(log.isDebugEnabled()) { + log.debug(_("isisfish.vcs.vcssvn.global.filelocalandremotestatus",localFile.getAbsolutePath(),localStatus, remoteStatus)); } - + // don't return true if: // - file is locally added // - file is remotely deleted - if (!localStatus.equals(SVNStatusType.STATUS_ADDED) - && !remoteStatus.equals(SVNStatusType.STATUS_DELETED)) { + if(!localStatus.equals(SVNStatusType.STATUS_ADDED) && !remoteStatus.equals(SVNStatusType.STATUS_DELETED)) { result = true; } @@ -895,12 +887,11 @@ // catch exception // if exception, file doesn't exists on server // result is still 'false' - if (log.isDebugEnabled()) { - log.debug(_("isisfish.vcs.vcssvn.isonremote.error", localFile - .getAbsolutePath()), e); + if(log.isDebugEnabled()) { + log.debug(_("isisfish.vcs.vcssvn.isonremote.error",localFile.getAbsolutePath()),e); } } - + return result; } @@ -913,33 +904,31 @@ */ @Override public boolean isUpToDate(File file) throws VCSException { - + File localFile = file; if (localFile == null) { localFile = getLocalRepository(); } - + boolean result = false; - + try { SVNStatusClient statusClient = getSVNManager().getStatusClient(); - SVNStatus status = statusClient - .doStatus(localFile, true /*remote*/); + SVNStatus status = statusClient.doStatus(localFile, true /*remote*/); SVNStatusType localStatus = status.getContentsStatus(); SVNStatusType remoteStatus = status.getRemoteContentsStatus(); - + // TODO peut on dire que le fichier est à jour // si le status local est normal et le distant est none - if (localStatus == SVNStatusType.STATUS_NORMAL - && remoteStatus == SVNStatusType.STATUS_NONE) { + if (localStatus == SVNStatusType.STATUS_NORMAL && remoteStatus == SVNStatusType.STATUS_NONE) { result = true; } } catch (SVNException eee) { throw new VCSException(_("isisfish.vcs.vcssvn.isuptodate.error"), eee); } - + return result; } @@ -956,7 +945,8 @@ localFile = getLocalRepository(); } if (!accept(localFile)) { - throw new VCSException(_("isisfish.vcs.vcssvn.update.notinlocal")); + throw new VCSException( + _("isisfish.vcs.vcssvn.update.notinlocal")); } if (fireAction(VCSActionEvent.UPDATE, localFile)) { // si le repertoire pere, n'est pas encore dans le repo local @@ -976,8 +966,7 @@ false); // boolean depthIsSticky if (log.isInfoEnabled()) { - log.info(_("isisfish.vcs.vcssvn.global.torevision", - newRevision)); + log.info(_("isisfish.vcs.vcssvn.global.torevision", newRevision)); } // recherche de tous les fichiers locaux en conflit @@ -1070,7 +1059,8 @@ } return result; } catch (SVNException eee) { - throw new VCSException(_("isisfish.vcs.vcssvn.gettag.error"), eee); + throw new VCSException( + _("isisfish.vcs.vcssvn.gettag.error"), eee); } } @@ -1078,8 +1068,12 @@ * @see org.codelutin.isisfish.vcs.VCS#setTag(org.codelutin.util.VersionNumber) */ @Override - public void setTag(VersionNumber version) throws VCSException { + public List<File> setTag(VersionNumber version) throws VCSException { + + List<File> filesInConflict = null; + try { + String tag = "/trunk"; if (version != null) { tag = "/tags/" + version; @@ -1115,14 +1109,35 @@ true);// boolean depthIsSticky if (log.isInfoEnabled()) { - log.info(_("isisfish.vcs.vcssvn.global.torevision", - newRevision)); + log.info(_("isisfish.vcs.vcssvn.global.torevision", newRevision)); } + + // recherche de tous les fichiers locaux en conflit apres le switch + Map<File, SVNStatus> status = getLocalStatus(localRoot, + true, SVNStatusType.STATUS_CONFLICTED); + if (status.size() > 0) { + filesInConflict = new ArrayList<File>(); + filesInConflict.addAll(status.keySet()); + // on supprime les conflits pour pouvoir commiter convenablement + // les fichiers + //getSVNManager().getWCClient().doResolve(localFile, recurse); + + // FIXME use conflit resolution choice ? + //SVNWCClient wcClient = getSVNManager().getWCClient(); + //wcClient.doResolve(localFile, // File file + // recurse ? SVNDepth.INFINITY : SVNDepth.FILES, // depth + // SVNConflictChoice.MERGED); // ConflictChoice + } } } + + } catch (SVNException eee) { - throw new VCSException(_("isisfish.vcs.vcssvn.setTag.error"), eee); + throw new VCSException( + _("isisfish.vcs.vcssvn.setTag.error"), eee); } + + return filesInConflict; } } \ No newline at end of file
participants (1)
-
chatellier@users.labs.libre-entreprise.org