org.tigris.subversion.svnclientadapter.ISVNLogMessageChangePath Java Examples

The following examples show how to use org.tigris.subversion.svnclientadapter.ISVNLogMessageChangePath. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LogEntry.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
private ISVNLogMessageChangePath[] getPathsOnDemand(SVNUrl url) {
ISVNLogMessage[] tmpMessage;
ISVNClientAdapter client = null;
      try {
          client = SVNProviderPlugin.getPlugin().getSVNClient(); // errors will not log to console
          SVNProviderPlugin.disableConsoleLogging(); 
          tmpMessage = client.getLogMessages(url, getRevision(), getRevision(), true);
          SVNProviderPlugin.enableConsoleLogging(); 
       if (tmpMessage != null && tmpMessage.length > 0)
	    return tmpMessage[0].getChangedPaths();
	else
	    return null;
      } catch (Exception e) {
          SVNProviderPlugin.enableConsoleLogging(); 
          return null;
      } finally {
       SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
      }
  }
 
Example #2
Source File: ResolveTreeConflictWizard.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public ISVNStatus getRemoteCopiedTo(boolean getAll) throws Exception {
	if (remoteCopiedTo == null && !remoteCopiedToRetrieved) {
		remoteCopiedToRetrieved = true;
		logMessages = getLogMessages();
		if (logMessages != null) {
			for (int i = 0; i < logMessages.length; i++) {
				ISVNLogMessageChangePath[] changePaths = logMessages[i].getChangedPaths();
				for (int j = 0; j < changePaths.length; j++) {
					if (changePaths[j].getAction() == 'A' && changePaths[j].getCopySrcPath() != null) {
						if ((svnResource.getUrl() != null && svnResource.getUrl().toString().endsWith(changePaths[j].getCopySrcPath())) || changePaths[j].getCopySrcPath().endsWith(svnResource.getIResource().getFullPath().toString())) {
							statuses = getStatuses(getAll);
							for (int k = 0; k < statuses.length; k++) {
								if (statuses[k].getUrl() != null && statuses[k].getUrl().toString().endsWith(changePaths[j].getPath())) {
									remoteCopiedTo = statuses[k];
									return remoteCopiedTo;
								}
							}
						}
					}
				}
			}
		}
	}		
	return remoteCopiedTo;
}
 
Example #3
Source File: LogTestHidden.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void assertChangePaths(ISVNLogMessageChangePath[] pathsref, ISVNLogMessageChangePath[] pathsnb) {

        assertEquals(pathsref.length, pathsnb.length);

        Arrays.sort(pathsref, new ChangePathComparator());
        Arrays.sort(pathsnb, new ChangePathComparator());

        for (int j = 0; j < pathsref.length; j++) {
            ISVNLogMessageChangePath pathref = pathsref[j];
            ISVNLogMessageChangePath pathnb = pathsnb[j];

            assertEquals(pathref.getAction(), pathnb.getAction());
            assertEquals(pathref.getCopySrcPath(), pathnb.getCopySrcPath());
            assertEquals(pathref.getCopySrcRevision(), pathnb.getCopySrcRevision());
            assertEquals(pathref.getPath(), pathnb.getPath());
        }
    }
 
Example #4
Source File: LogTestHidden.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void assertLogs(ISVNLogMessage[] logsRef, ISVNLogMessage[] logsNb) {
    assertEquals(logsRef.length, logsNb.length);
    for (int i = 0; i < logsNb.length; i++) {
        ISVNLogMessage lognb = logsNb[i];
        ISVNLogMessage logref = logsRef[i];            
        
        assertEquals(logref.getAuthor(), lognb.getAuthor());
        assertEquals(logref.getDate().toString(), lognb.getDate().toString());
        assertEquals(logref.getMessage(), lognb.getMessage());
        assertEquals(logref.getRevision(), lognb.getRevision());
        
        ISVNLogMessageChangePath[] pathsnb = lognb.getChangedPaths();
        ISVNLogMessageChangePath[] pathsref = lognb.getChangedPaths();
        assertChangePaths(pathsref, pathsnb);
    }
}
 
Example #5
Source File: LogTestHidden.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void assertLogMessage(ISVNInfo info, ISVNLogMessage logsNb, String msg, ISVNLogMessageChangePath[] changePaths) {
    assertEquals(info.getLastCommitAuthor(), logsNb.getAuthor());
    assertEquals(info.getLastChangedDate().toString(), logsNb.getDate().toString());
    assertEquals(msg, logsNb.getMessage());
    assertEquals(info.getRevision(), logsNb.getRevision());
    assertChangePaths(changePaths, logsNb.getChangedPaths());
}
 
Example #6
Source File: JhlConverter.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
static ISVNLogMessageChangePath[] convertChangePaths(Set<ChangePath> changePaths) {
      if (changePaths == null)
          return new SVNLogMessageChangePath[0];
      SVNLogMessageChangePath[] jhlChangePaths = new SVNLogMessageChangePath[changePaths.size()];
      int i =0;
      for (ChangePath path : changePaths) {
      	jhlChangePaths[i] = new JhlLogMessageChangePath(path);
      	i++;
}
      return jhlChangePaths;
  }
 
Example #7
Source File: LogEntry.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public LogEntryChangePath[] getLogEntryChangePaths() {
	ISVNLogMessageChangePath[] changePaths = null;
	if (SVNProviderPlugin.getPlugin().getSVNClientManager().isFetchChangePathOnDemand()) {
		SVNUrl url = resource.getRepository().getRepositoryRoot();
		if (url == null)
		    url = updateRootUrl(resource);
		changePaths = getPathsOnDemand(url);
		if (changePaths == null) {
		    // Root URL is probably bad.  Run svn info to retrieve the root URL and
		    // update it in the repository.
		    SVNUrl url2 = updateRootUrl(resource);
		    if (!url.toString().equals(url2.toString()))
		        changePaths = getPathsOnDemand(url);
		    // one last try using the resource URL
		    if (changePaths == null)
		        changePaths = getPathsOnDemand(resource.getUrl());
		    
		    // Still nothing, just return an empty array
		    if (changePaths == null)
				changePaths = new ISVNLogMessageChangePath[0];
		}
	} else {
		changePaths = logMessage.getChangedPaths();
	}
		
    LogEntryChangePath[] logEntryChangePaths = new LogEntryChangePath[changePaths.length]; 
    for (int i = 0; i < changePaths.length; i++) {
    	logEntryChangePaths[i] = new LogEntryChangePath(this,changePaths[i]);
    }
    return logEntryChangePaths;
}
 
Example #8
Source File: LogTestHidden.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void logLimit(Log log) throws Exception {                                
    File file = createFile("file");
    add(file);
    write(file, "1");        
    commit(file, "msg1");
    ISVNInfo info1 = getInfo(file);        
    
    write(file, "2");
    commit(file, "msg2");
    ISVNInfo info2 = getInfo(file);
    
    write(file, "3");
    commit(file, "msg3");

    ISVNLogMessage[] logsNb = null;
    switch(log) {
        case file:
            logsNb = getNbClient().getLogMessages(file, new SVNRevision.Number(0), SVNRevision.HEAD, false, true, 2);
            break;
        case url:
            logsNb = getNbClient().getLogMessages(getFileUrl(file), null, new SVNRevision.Number(0), SVNRevision.HEAD, false, true, 2);
            break;
        default:
            fail("no idea!");
    }
    
    // test
    assertEquals(2, logsNb.length);         
    String testName = getName();        
    assertLogMessage(info1, logsNb[0], "msg1",  new ISVNLogMessageChangePath[] { new ChangePath('A', "/" + testName + "/" + testName + "_wc/file", null, null) });
    assertLogMessage(info2, logsNb[1], "msg2",  new ISVNLogMessageChangePath[] { new ChangePath('M', "/" + testName + "/" + testName + "_wc/file", null, null) });
}
 
Example #9
Source File: RepositoryRevision.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void initFakeRootEvent() {
    fakeRootEvents = new LinkedList<Event>();
    for (final File selectionRoot : selectionRoots) {
        Event e = new Event(new ISVNLogMessageChangePath() {
            private String path;
            @Override
            public String getPath() {
                if(path == null) {
                    try {
                        path = SvnUtils.getRelativePath(selectionRoot);
                        if (!path.startsWith("/")) { //NOI18B
                            path = "/" + path; //NOI18B
                        }
                    } catch (SVNClientException ex) {
                        Subversion.LOG.log(Level.INFO, selectionRoot.getAbsolutePath(), ex);
                        path = "/"; //NOI18B
                    }
                }
                return path;
            }
            @Override
            public Number getCopySrcRevision() {
                return null;
            }
            @Override
            public String getCopySrcPath() {
                return null;
            }
            @Override
            public char getAction() {
                return '?';
            }
        }, true, null);
        e.setFile(selectionRoot);
        fakeRootEvents.add(e);
    }
}
 
Example #10
Source File: RepositoryRevision.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public Event (ISVNLogMessageChangePath changedPath, boolean underRoots, String displayAction) {
    this.changedPath = changedPath;
    name = changedPath.getPath().substring(changedPath.getPath().lastIndexOf('/') + 1);
    path = changedPath.getPath().substring(0, changedPath.getPath().lastIndexOf('/'));
    originalPath = changedPath.getCopySrcPath();
    originalName = originalPath == null ? null : originalPath.substring(originalPath.lastIndexOf('/') + 1);
    this.underRoots = underRoots;
    this.action = displayAction == null ? Character.toString(changedPath.getAction()) : displayAction;
}
 
Example #11
Source File: LogCommand.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public LogMessage(String msg, Number rev, String author, Date date, ISVNLogMessageChangePath[] paths) {
    this.msg = msg;
    this.rev = rev;
    this.author = author;
    this.date = date;
    this.paths = paths;
}
 
Example #12
Source File: LogCommand.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void endElement(String uri, String localName, String name) throws SAXException {
    tag = null;
    if (ENTRY_ELEMENT_NAME.equals(name)) {                      
        if(values != null) {
                                                                               
            String author = (String) values.get(AUTHOR_ELEMENT_NAME);
            if(author == null) author = "";
            Date date = null;
            String dateValue = (String) values.get(DATE_ELEMENT_NAME);                                                
            if (dateValue == null) throw new SAXException("'date' tag expected under 'logentry'");                        
            try {
                date = dateFormat.parse(dateValue);
            } catch (ParseException ex) {
                // ignore
                
            }
            String msg = (String) values.get(MSG_ELEMENT_NAME);
            if(msg == null) msg = "";

            SVNRevision.Number rev = getRevision((String) values.get(REVISION_ATTRIBUTE));
            
            List<Path> pathsList = getPathList();
            ISVNLogMessageChangePath[] paths;  
            if(pathsList.size() > 0) {
                paths = new SVNLogMessageChangePath[pathsList.size()];
                for (int i = 0; i < pathsList.size(); i++) {
                    Path path = pathsList.get(i);
                    paths[i] = new SVNLogMessageChangePath(path.path, getRevision(path.copyRev), path.copyPath, path.action);
                }
            } else {
                paths = new SVNLogMessageChangePath[] {};
            }
                
            logs.add(new LogMessage(msg, rev, author, date, paths));
            
            values = null;
        }
    }
}
 
Example #13
Source File: RepositoryRevision.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public ISVNLogMessageChangePath getChangedPath() {
    return changedPath;
}
 
Example #14
Source File: SvnClientJavaHl.java    From MergeProcessor with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public List<SvnLog> log(URL url, long fromRevision, long toRevision, String author) throws SvnClientException {
	final List<SvnLog> logs = new ArrayList<>();
	try {
		final ISVNLogMessage[] logMessages = client.getLogMessages(toSVNUrl(url), new Number(fromRevision),
				new Number(toRevision));
		for (final ISVNLogMessage logMessage : logMessages) {
			if (author == null || Objects.equals(logMessage.getAuthor(), author)) {
				final List<SvnLogEntry> entries = new ArrayList<>();
				for (final ISVNLogMessageChangePath changePath : logMessage.getChangedPaths()) {
					final SvnLogAction action;
					switch (changePath.getAction()) {
					case 'A':
						action = SvnLogAction.ADDED;
						break;
					case 'D':
						action = SvnLogAction.DELETED;
						break;
					case 'R':
						action = SvnLogAction.REPLACED;
						break;
					case 'M':
						action = SvnLogAction.MODIFIED;
						break;
					default:
						throw LogUtil.throwing(new SvnClientException(
								String.format("Unknown action character '%s'", changePath.getAction())));
					}
					entries.add(new SvnLogEntry(action, new URL(url.toString() + changePath.getPath())));
				}
				final LocalDateTime dateTime = LocalDateTime
						.ofInstant(Instant.ofEpochMilli(logMessage.getTimeMillis()), ZoneId.systemDefault());
				logs.add(new SvnLog(logMessage.getRevision().getNumber(), entries, logMessage.getMessage(),
						dateTime, logMessage.getAuthor()));
			}
		}
	} catch (MalformedURLException | SVNClientException e) {
		throw new SvnClientException(e);
	}
	return logs;
}
 
Example #15
Source File: AnnotateLine.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void setChangedPaths(ISVNLogMessageChangePath[] changedPaths) {
    this.changedPaths = changedPaths;
}
 
Example #16
Source File: LogTestHidden.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public int compare(ISVNLogMessageChangePath o1, ISVNLogMessageChangePath o2) {
    return o1.getPath().compareTo(o2.getPath());
}
 
Example #17
Source File: AnnotateLine.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public ISVNLogMessageChangePath[] getChangedPaths() {
    return changedPaths;
}
 
Example #18
Source File: LogCommand.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public ISVNLogMessageChangePath[] getChangedPaths() {
    return paths;
}
 
Example #19
Source File: LogEntryChangePath.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public LogEntryChangePath(ILogEntry logEntry, ISVNLogMessageChangePath logMessageChangePath) {
    this.logMessageChangePath = logMessageChangePath;
    this.logEntry = logEntry;
}
 
Example #20
Source File: JhlLogMessage.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public ISVNLogMessageChangePath[] getChangedPaths() {
	return changedPaths;
}