maven-scm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joak...@apache.org
Subject svn commit: r468577 [2/2] - in /maven/scm/trunk/sandbox/maven-scm-provider-hg: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/maven/ src/main/java/org/apache/maven/scm/ src/main/java/org/apache/ma...
Date Fri, 27 Oct 2006 22:54:51 GMT
Added: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/diff/HgDiffConsumer.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/diff/HgDiffConsumer.java?view=auto&rev=468577
==============================================================================
--- maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/diff/HgDiffConsumer.java (added)
+++ maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/diff/HgDiffConsumer.java Fri Oct 27 15:54:48 2006
@@ -0,0 +1,159 @@
+package org.apache.maven.scm.provider.hg.command.diff;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.scm.ScmFile;
+import org.apache.maven.scm.ScmFileStatus;
+import org.apache.maven.scm.log.ScmLogger;
+import org.apache.maven.scm.provider.hg.command.HgConsumer;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:thurner.rupert@ymono.net">thurner rupert</a>
+ */
+public class HgDiffConsumer
+        extends HgConsumer
+{
+
+    // private final static String MODIFIED_FILE_TOKEN = "=== modified file ";
+
+    private final static String INDEX_TOKEN = "diff -r ";
+
+    private final static String FILE_SEPARATOR_TOKEN = "===";
+
+    private final static String START_REVISION_TOKEN = "---";
+
+    private final static String END_REVISION_TOKEN = "+++";
+
+    private final static String ADDED_LINE_TOKEN = "+";
+
+    private final static String REMOVED_LINE_TOKEN = "-";
+
+    private final static String UNCHANGED_LINE_TOKEN = " ";
+
+    private final static String CHANGE_SEPARATOR_TOKEN = "@@";
+
+    private final static String NO_NEWLINE_TOKEN = "\\ No newline at end of file";
+
+    private final static int HASH_ID_LEN = 12;
+
+    private ScmLogger logger;
+
+    private String currentFile;
+
+    private StringBuffer currentDifference;
+
+    private List changedFiles = new ArrayList();
+
+    private Map differences = new HashMap();
+
+    private StringBuffer patch = new StringBuffer();
+
+    private File workingDirectory;
+
+
+    public HgDiffConsumer( ScmLogger logger, File workingDirectory )
+    {
+        super( logger );
+        this.logger = logger;
+        this.workingDirectory = workingDirectory;
+    }
+
+    // ----------------------------------------------------------------------
+    // StreamConsumer Implementation
+    // ----------------------------------------------------------------------
+
+    public void consumeLine( String line )
+    {
+        if ( line.startsWith( INDEX_TOKEN ) )
+        {
+            // start a new file
+            currentFile = line.substring( INDEX_TOKEN.length() + HASH_ID_LEN + 1 );
+
+            changedFiles.add( new ScmFile( currentFile, ScmFileStatus.MODIFIED ) );
+
+            currentDifference = new StringBuffer();
+
+            differences.put( currentFile, currentDifference );
+
+            patch.append( line ).append( "\n" );
+
+            return;
+        }
+
+        if ( currentFile == null )
+        {
+            logger.warn( "Unparseable line: '" + line + "'" );
+            patch.append( line ).append( "\n" );
+            return;
+        }
+
+        if ( line.startsWith( FILE_SEPARATOR_TOKEN ) )
+        {
+            // skip
+            patch.append( line ).append( "\n" );
+        }
+        else if ( line.startsWith( START_REVISION_TOKEN ) )
+        {
+            // skip, though could parse to verify filename, start revision
+            patch.append( line ).append( "\n" );
+        }
+        else if ( line.startsWith( END_REVISION_TOKEN ) )
+        {
+            // skip, though could parse to verify filename, end revision
+            patch.append( line ).append( "\n" );
+        }
+        else if ( line.startsWith( ADDED_LINE_TOKEN ) || line.startsWith( REMOVED_LINE_TOKEN ) ||
+                  line.startsWith( UNCHANGED_LINE_TOKEN ) || line.startsWith( CHANGE_SEPARATOR_TOKEN ) ||
+                  line.equals( NO_NEWLINE_TOKEN ) )
+        {
+            // add to buffer
+            currentDifference.append( line ).append( "\n" );
+            patch.append( line ).append( "\n" );
+        }
+        else
+        {
+            // TODO: handle property differences
+
+            logger.warn( "Unparseable line: '" + line + "'" );
+            patch.append( line ).append( "\n" );
+            // skip to next file
+            currentFile = null;
+            currentDifference = null;
+        }
+    }
+
+    public List getChangedFiles()
+    {
+        return changedFiles;
+    }
+
+    public Map getDifferences()
+    {
+        return differences;
+    }
+
+    public String getPatch()
+    {
+        return patch.toString();
+    }
+}

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/diff/HgDiffConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/diff/HgDiffConsumer.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/remove/HgRemoveCommand.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/remove/HgRemoveCommand.java?view=auto&rev=468577
==============================================================================
--- maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/remove/HgRemoveCommand.java (added)
+++ maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/remove/HgRemoveCommand.java Fri Oct 27 15:54:48 2006
@@ -0,0 +1,50 @@
+package org.apache.maven.scm.provider.hg.command.remove;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.ScmResult;
+import org.apache.maven.scm.command.remove.AbstractRemoveCommand;
+import org.apache.maven.scm.command.remove.RemoveScmResult;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.hg.HgUtils;
+import org.apache.maven.scm.provider.hg.command.HgCommand;
+
+import java.io.File;
+
+/**
+ * @author <a href="mailto:thurner.rupert@ymono.net">thurner rupert</a>
+ */
+public class HgRemoveCommand
+    extends AbstractRemoveCommand
+    implements HgCommand
+{
+    protected ScmResult executeRemoveCommand( ScmProviderRepository repository, ScmFileSet fileSet, String message )
+        throws ScmException
+    {
+
+        String[] command = new String[] { REMOVE_CMD };
+        HgUtils.expandCommandLine( command, fileSet );
+
+        File workingDir = fileSet.getBasedir();
+        HgRemoveConsumer consumer = new HgRemoveConsumer( getLogger(), workingDir );
+
+        ScmResult result = HgUtils.execute( consumer, getLogger(), workingDir, command );
+        return new RemoveScmResult( consumer.getRemovedFiles(), result );
+    }
+}

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/remove/HgRemoveCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/remove/HgRemoveCommand.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/remove/HgRemoveConsumer.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/remove/HgRemoveConsumer.java?view=auto&rev=468577
==============================================================================
--- maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/remove/HgRemoveConsumer.java (added)
+++ maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/remove/HgRemoveConsumer.java Fri Oct 27 15:54:48 2006
@@ -0,0 +1,67 @@
+package org.apache.maven.scm.provider.hg.command.remove;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.scm.ScmFile;
+import org.apache.maven.scm.ScmFileStatus;
+import org.apache.maven.scm.log.ScmLogger;
+import org.apache.maven.scm.provider.hg.command.HgConsumer;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:thurner.rupert@ymono.net">thurner rupert</a>
+ */
+public class HgRemoveConsumer
+    extends HgConsumer
+{
+    private final File workingDir;
+
+    private final List removedFiles = new ArrayList();
+
+    public HgRemoveConsumer( ScmLogger logger, File workingDir )
+    {
+        super( logger );
+        this.workingDir = workingDir;
+    }
+
+    public void doConsume( ScmFileStatus status, String trimmedLine )
+    {
+        if ( status != null && status == ScmFileStatus.DELETED )
+        {
+            //Only include real files (not directories)
+            File tmpFile = new File( workingDir, trimmedLine );
+            if ( !tmpFile.exists() )
+            {
+                getLogger().warn( "Not a file: " + tmpFile + ". Ignored" );
+            }
+            else
+            {
+                ScmFile scmFile = new ScmFile( trimmedLine, ScmFileStatus.DELETED );
+                getLogger().info( scmFile.toString() );
+                removedFiles.add( scmFile );
+            }
+        }
+    }
+
+    public List getRemovedFiles()
+    {
+        return removedFiles;
+    }
+}
\ No newline at end of file

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/remove/HgRemoveConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/remove/HgRemoveConsumer.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/status/HgStatusCommand.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/status/HgStatusCommand.java?view=auto&rev=468577
==============================================================================
--- maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/status/HgStatusCommand.java (added)
+++ maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/status/HgStatusCommand.java Fri Oct 27 15:54:48 2006
@@ -0,0 +1,54 @@
+package org.apache.maven.scm.provider.hg.command.status;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.ScmResult;
+import org.apache.maven.scm.command.status.AbstractStatusCommand;
+import org.apache.maven.scm.command.status.StatusScmResult;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.hg.HgUtils;
+import org.apache.maven.scm.provider.hg.command.HgCommand;
+
+import java.io.File;
+
+/**
+ * @author <a href="mailto:thurner.rupert@ymono.net">thurner rupert</a>
+ */
+public class HgStatusCommand
+    extends AbstractStatusCommand
+    implements HgCommand
+{
+
+    public HgStatusCommand()
+    {
+        super();
+    }
+
+    public StatusScmResult executeStatusCommand( ScmProviderRepository repo, ScmFileSet fileSet )
+        throws ScmException
+    {
+
+        File workingDir = fileSet.getBasedir();
+        HgStatusConsumer consumer = new HgStatusConsumer( getLogger(), workingDir );
+        String[] statusCmd = new String[] { STATUS_CMD };
+        ScmResult result = HgUtils.execute( consumer, getLogger(), workingDir, statusCmd );
+
+        return new StatusScmResult( consumer.getStatus(), result );
+    }
+}

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/status/HgStatusCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/status/HgStatusCommand.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/status/HgStatusConsumer.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/status/HgStatusConsumer.java?view=auto&rev=468577
==============================================================================
--- maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/status/HgStatusConsumer.java (added)
+++ maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/status/HgStatusConsumer.java Fri Oct 27 15:54:48 2006
@@ -0,0 +1,69 @@
+package org.apache.maven.scm.provider.hg.command.status;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.scm.ScmFile;
+import org.apache.maven.scm.ScmFileStatus;
+import org.apache.maven.scm.log.ScmLogger;
+import org.apache.maven.scm.provider.hg.command.HgConsumer;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:thurner.rupert@ymono.net">thurner rupert</a>
+ */
+class HgStatusConsumer
+    extends HgConsumer
+{
+    private final List repositoryStatus = new ArrayList();
+
+    private final File workingDir;
+
+
+    HgStatusConsumer( ScmLogger logger, File workingDir )
+    {
+        super( logger );
+        this.workingDir = workingDir;
+    }
+
+    public void doConsume( ScmFileStatus status, String trimmedLine )
+    {
+         //Only include real files (not directories)
+        File tmpFile = new File( workingDir, trimmedLine );
+        if ( !tmpFile.exists() )
+        {
+            getLogger().info( "Not a file: " + tmpFile + ". Ignoring" );
+        }
+        else if ( tmpFile.isDirectory() )
+        {
+            getLogger().info( "New directory added: " + tmpFile );
+        }
+        else
+        {
+            ScmFile scmFile = new ScmFile( trimmedLine, status );
+            getLogger().info( scmFile.toString() );
+            repositoryStatus.add( scmFile );
+        }
+    }
+
+    List getStatus()
+    {
+        return repositoryStatus;
+    }
+}

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/status/HgStatusConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/status/HgStatusConsumer.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/update/HgUpdateCommand.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/update/HgUpdateCommand.java?view=auto&rev=468577
==============================================================================
--- maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/update/HgUpdateCommand.java (added)
+++ maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/update/HgUpdateCommand.java Fri Oct 27 15:54:48 2006
@@ -0,0 +1,106 @@
+package org.apache.maven.scm.provider.hg.command.update;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFile;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.ScmFileStatus;
+import org.apache.maven.scm.ScmResult;
+import org.apache.maven.scm.command.changelog.ChangeLogCommand;
+import org.apache.maven.scm.command.update.AbstractUpdateCommand;
+import org.apache.maven.scm.command.update.UpdateScmResult;
+import org.apache.maven.scm.command.update.UpdateScmResultWithRevision;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.hg.HgUtils;
+import org.apache.maven.scm.provider.hg.command.HgCommand;
+import org.apache.maven.scm.provider.hg.command.HgConsumer;
+import org.apache.maven.scm.provider.hg.command.changelog.HgChangeLogCommand;
+import org.apache.maven.scm.provider.hg.command.diff.HgDiffConsumer;
+import org.codehaus.plexus.util.StringUtils;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:thurner.rupert@ymono.net">thurner rupert</a>
+ */
+public class HgUpdateCommand
+    extends AbstractUpdateCommand
+    implements HgCommand
+{
+
+    protected UpdateScmResult executeUpdateCommand( ScmProviderRepository repo, ScmFileSet fileSet, String tag )
+        throws ScmException
+    {
+
+        if ( !StringUtils.isEmpty( tag ) )
+        {
+            throw new ScmException( "This provider can't handle tags." );
+        }
+
+        File workingDir = fileSet.getBasedir();
+
+        // Update branch
+        String[] update_cmd = new String[] { HgCommand.PULL_CMD };
+        ScmResult updateResult = HgUtils.execute( new HgConsumer( getLogger() ), getLogger(), workingDir,
+                                                      update_cmd );
+
+        if ( !updateResult.isSuccess() )
+        {
+            return new UpdateScmResult( null, null, updateResult );
+        }
+
+        // Find changes from last revision
+        int currentRevision = HgUtils.getCurrentRevisionNumber( getLogger(), workingDir );
+        int previousRevision = currentRevision - 1;
+        String[] diffCmd = new String[] { DIFF_CMD, REVISION_OPTION, "" + previousRevision };
+        HgDiffConsumer diffConsumer = new HgDiffConsumer( getLogger(), workingDir );
+        ScmResult diffResult = HgUtils.execute( diffConsumer, getLogger(), workingDir, diffCmd );
+
+        // Now translate between diff and update file status
+        List updatedFiles = new ArrayList();
+        List changes = new ArrayList();
+        List diffFiles = diffConsumer.getChangedFiles();
+        Map diffChanges = diffConsumer.getDifferences();
+        for ( Iterator it = diffFiles.iterator(); it.hasNext(); )
+        {
+            ScmFile file = (ScmFile) it.next();
+            changes.add( diffChanges.get( file.getPath() ) );
+            if ( file.getStatus() == ScmFileStatus.MODIFIED )
+            {
+                updatedFiles.add( new ScmFile( file.getPath(), ScmFileStatus.PATCHED ) );
+            }
+            else
+            {
+                updatedFiles.add( file );
+            }
+        }
+
+        return new UpdateScmResultWithRevision( updatedFiles, changes, String.valueOf( currentRevision ), diffResult );
+    }
+
+    protected ChangeLogCommand getChangeLogCommand()
+    {
+        HgChangeLogCommand command = new HgChangeLogCommand();
+        command.setLogger( getLogger() );
+        return command;
+    }
+}

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/update/HgUpdateCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/update/HgUpdateCommand.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/repository/HgScmProviderRepository.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/repository/HgScmProviderRepository.java?view=auto&rev=468577
==============================================================================
--- maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/repository/HgScmProviderRepository.java (added)
+++ maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/repository/HgScmProviderRepository.java Fri Oct 27 15:54:48 2006
@@ -0,0 +1,255 @@
+package org.apache.maven.scm.provider.hg.repository;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.scm.provider.ScmProviderRepositoryWithHost;
+import org.codehaus.plexus.util.StringUtils;
+
+import java.io.File;
+
+/**
+ * @author <a href="mailto:thurner.rupert@ymono.net">thurner rupert</a>
+ */
+public class HgScmProviderRepository
+    extends ScmProviderRepositoryWithHost
+{
+    //Known and tested protocols
+    private static final String FILE = "";
+
+    private static final String SFTP = "sftp://";
+
+    private static final String FTP = "ftp://";
+
+    private static final String AFTP = "aftp://";
+
+    private static final String HTTP = "http://";
+
+    private static final String HTTPS = "https://";
+
+    private final String path;
+
+    private final String protocol;
+
+    private final String orgUrl;
+
+    public HgScmProviderRepository( String url )
+    {
+        orgUrl = url;
+        protocol = getProtocol( url );
+        path = parseUrl( url );
+    }
+
+    public String getURI()
+    {
+        return protocol + (needsAuthentication() ? addUser() + addPassword() + addAt() : "") +  addHost() + addPort() + addPath();
+    }
+
+    /**
+     * @return A message if the repository as an invalid URI, null if the URI seems fine.
+     */
+    public String validateURI()
+    {
+
+        String msg = null;
+
+        if ( needsAuthentication() )
+        {
+            if ( getUser() == null )
+            {
+                msg = "Username is missing for protocol " + protocol;
+            }
+            else if ( getPassword() == null )
+            {
+                msg = "Password is missing for protocol " + protocol;
+            }
+            else if ( getHost() == null )
+            {
+                msg = "Host (eg. www.myhost.com) is missing for protocol " + protocol;
+            }
+        }
+
+        else if ( getPort() != 0 && getHost() == null )
+        {
+            msg = "Got port information without any host for protocol " + protocol;
+        }
+
+        if ( msg != null )
+        {
+            msg = "Something could be wrong about the repository URL: " + orgUrl + "\nReason: " + msg
+                + "\nCheck http://maven.apache.org/scm for usage and hints.";
+        }
+        return msg;
+    }
+
+    private String getProtocol( String url )
+    {
+    	// Assume we have a file unless we find a URL based syntax
+        String prot = FILE;
+        if ( url.startsWith( SFTP ) )
+        {
+            prot = SFTP;
+        }
+        else if ( url.startsWith( HTTP ) )
+        {
+            prot = HTTP;
+        }
+        else if ( url.startsWith( HTTPS ) )
+        {
+            prot = HTTPS;
+        }
+
+        return prot;
+    }
+
+    private String parseUrl( String url )
+    {
+        if ( protocol == FILE )
+        {
+            return url;
+        }
+
+        //Strip protocol
+        url = url.substring( protocol.length() );
+
+        url = parseUsernameAndPassword( url );
+
+        url = parseHostAndPort( url );
+
+        url = parsePath( url );
+
+        return url; //is now only the path
+    }
+
+    private String parseHostAndPort( String url )
+    {
+        if ( protocol != FILE )
+        {
+            String[] split = url.split( ":" );
+            if ( split.length == 2 )
+            {
+                setHost( split[0] );
+                url = url.substring( split[0].length() + 1 );
+                split = split[1].split( "/" );
+                if ( split.length == 2 )
+                {
+                    url = url.substring( split[0].length() );
+                    try {
+                        setPort( Integer.valueOf( split[0] ).intValue() );
+                    } catch (NumberFormatException e) {
+                        //Ignore - error will manifest itself later.
+                    }
+                }
+            }
+            else
+            {
+                split = url.split( "/" );
+                if ( split.length > 1 )
+                {
+                    url = url.substring( split[0].length() );
+                    setHost( split[0] );
+                }
+            }
+        }
+        return url;
+    }
+
+    private String parseUsernameAndPassword( String url )
+    {
+        if ( needsAuthentication() )
+        {
+            String[] split = url.split( "@" );
+            if ( split.length == 2 )
+            {
+                url = split[1]; //Strip away 'username:password@' from url
+                split = split[0].split( ":" );
+                if ( split.length == 2 )
+                { //both username and password
+                    setUser( split[0] );
+                    setPassword( split[1] );
+                }
+                else
+                { //only username
+                    setUser( split[0] );
+                }
+            }
+        }
+        return url;
+    }
+
+    private String parsePath( String url )
+    {
+        if ( protocol == FILE )
+        {
+            //Use OS dependent path separator
+            url = StringUtils.replace( url, "/", File.separator );
+
+            //Test first path separator (*nix systems use them to denote root)
+            File tmpFile = new File( url ); //most likly a *nix system
+            String url2 = url.substring( File.pathSeparator.length() );
+            File tmpFile2 = new File( url2 ); //most likly a windows system
+            if ( !tmpFile.exists() && !tmpFile2.exists() )
+            {
+                // This is trouble - Trouble is reported in validateURI()
+            }
+
+            url = tmpFile2.exists() ? url2 : url;
+        }
+
+        return url;
+    }
+
+    private String addUser()
+    {
+        return ( getUser() == null ) ? "" : getUser();
+    }
+
+    private String addPassword()
+    {
+        return ( getPassword() == null ) ? "" : ":" + getPassword();
+    }
+
+    private String addAt()
+    {
+        return needsAuthentication() ? "@" : "";
+    }
+
+    private String addHost()
+    {
+        return ( getHost() == null ) ? "" : getHost();
+    }
+
+    private String addPort()
+    {
+        return ( getPort() == 0 ) ? "" : ":" + getPort();
+    }
+
+    private String addPath()
+    {
+        return path;
+    }
+
+    private boolean needsAuthentication()
+    {
+        return protocol == SFTP || protocol == FTP || protocol == HTTPS || protocol == AFTP;
+    }
+
+    public String toString()
+    {
+        return "Hg Repository Interpreted from: " + orgUrl + ":\nProtocol: " + protocol + "\nHost: " + getHost()
+            + "\nPort: " + getPort() + "\nUsername: " + getUser() + "\nPassword: " + getPassword() + "\nPath: " + path;
+    }
+}

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/repository/HgScmProviderRepository.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/repository/HgScmProviderRepository.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/HgTestUtils.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/HgTestUtils.java?view=auto&rev=468577
==============================================================================
--- maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/HgTestUtils.java (added)
+++ maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/HgTestUtils.java Fri Oct 27 15:54:48 2006
@@ -0,0 +1,126 @@
+package org.apache.maven.scm.provider.hg;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.ScmResult;
+import org.apache.maven.scm.provider.hg.command.HgCommand;
+import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.util.FileUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Common code used in all tests.
+ *
+ * @author <a href="mailto:thurner.rupert@ymono.net">thurner rupert</a>
+ */
+public class HgTestUtils
+    extends PlexusTestCase
+{
+
+    public static final String[] filesInTestBranch = new String[] {
+        "pom.xml",
+        "readme.txt",
+        "src/main/java/Application.java",
+        "src/test/java/Test.java" };
+
+    public static final String TCK_FILE_CONSTANT = "/";
+
+    public static final String BRANCH_NAME = "target" + File.separator + "test-branch";
+
+    public static final File WORKING_DIR = new File( getBasedir(), BRANCH_NAME );
+
+    public static final String COMMIT_MESSAGE = "Add files to test branch";
+
+    public static String getScmUrl()
+        throws Exception
+    {
+        return "scm:hg:" + WORKING_DIR.getAbsolutePath();
+    }
+
+    public static void initRepo()
+        throws Exception
+    {
+        // Prepare tmp directory
+        if ( WORKING_DIR.exists() )
+        {
+            FileUtils.deleteDirectory( WORKING_DIR );
+
+            if ( WORKING_DIR.exists() )
+            {
+                throw new IOException( WORKING_DIR.getAbsolutePath() + " wasn't deleted." );
+            }
+        }
+
+        boolean workingDirReady = WORKING_DIR.mkdirs();
+
+        if ( !workingDirReady )
+        {
+            throw new IOException( "Could not initiate test branch at: " + WORKING_DIR );
+        }
+
+        // Init repository
+        String[] init_cmd = new String[] { HgCommand.INIT_CMD };
+        HgUtils.execute( WORKING_DIR, init_cmd );
+
+        // Create and add files to repository
+        List files = new ArrayList();
+        for ( int i = 0; i < filesInTestBranch.length; i++ )
+        {
+            File file = new File( WORKING_DIR.getAbsolutePath(), filesInTestBranch[i] );
+            if ( file.getParentFile() != null && !file.getParentFile().exists() )
+            {
+                boolean success = file.getParentFile().mkdirs();
+                if ( !success )
+                {
+                    throw new IOException( "Could not create directories in branch for: " + file );
+                }
+            }
+            file.createNewFile();
+
+            FileUtils.fileWrite( file.getAbsolutePath(), TCK_FILE_CONSTANT + filesInTestBranch[i] );
+
+            files.add( file );
+        }
+
+        //Add to repository
+        String[] add_cmd = new String[] { HgCommand.ADD_CMD };
+        ScmFileSet filesToAdd = new ScmFileSet( new File( "" ), (File[]) files.toArray( new File[0] ) );
+        add_cmd = HgUtils.expandCommandLine( add_cmd, filesToAdd );
+        ScmResult result = HgUtils.execute( WORKING_DIR, add_cmd );
+        if ( !result.isSuccess() )
+        {
+            String message = "Provider message: " + result.getProviderMessage() + "\n" + "Output: "
+                + result.getCommandOutput();
+            throw new Exception( message );
+        }
+
+        // Commit the initial repository
+        String[] commit_cmd = new String[] { HgCommand.COMMIT_CMD, HgCommand.MESSAGE_OPTION, COMMIT_MESSAGE };
+        result = HgUtils.execute( WORKING_DIR, commit_cmd );
+        if ( !result.isSuccess() )
+        {
+        	String message = "Provider message: " + result.getProviderMessage() + "\n" + "Output: "
+                + result.getCommandOutput();
+            throw new Exception( message );
+        }
+    }
+}

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/HgTestUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/HgTestUtils.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/changelog/HgChangeLogCommandTckTest.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/changelog/HgChangeLogCommandTckTest.java?view=auto&rev=468577
==============================================================================
--- maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/changelog/HgChangeLogCommandTckTest.java (added)
+++ maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/changelog/HgChangeLogCommandTckTest.java Fri Oct 27 15:54:48 2006
@@ -0,0 +1,36 @@
+package org.apache.maven.scm.provider.hg.command.changelog;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.scm.provider.hg.HgTestUtils;
+import org.apache.maven.scm.tck.command.changelog.ChangeLogCommandTckTest;
+
+public class HgChangeLogCommandTckTest
+    extends ChangeLogCommandTckTest
+{
+    public String getScmUrl()
+        throws Exception
+    {
+        return HgTestUtils.getScmUrl();
+    }
+
+    public void initRepo()
+        throws Exception
+    {
+        HgTestUtils.initRepo();
+    }
+}

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/changelog/HgChangeLogCommandTckTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/changelog/HgChangeLogCommandTckTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/checkin/HgCheckInCommandTest.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/checkin/HgCheckInCommandTest.java?view=auto&rev=468577
==============================================================================
--- maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/checkin/HgCheckInCommandTest.java (added)
+++ maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/checkin/HgCheckInCommandTest.java Fri Oct 27 15:54:48 2006
@@ -0,0 +1,39 @@
+package org.apache.maven.scm.provider.hg.command.checkin;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.scm.provider.hg.HgTestUtils;
+import org.apache.maven.scm.tck.command.checkin.CheckInCommandTckTest;
+
+/**
+ * @author <a href="mailto:thurner.rupert@ymono.net">thurner rupert</a>
+ */
+public class HgCheckInCommandTest
+    extends CheckInCommandTckTest
+{
+    public String getScmUrl()
+        throws Exception
+    {
+        return HgTestUtils.getScmUrl();
+    }
+
+    public void initRepo()
+        throws Exception
+    {
+        HgTestUtils.initRepo();
+    }
+}

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/checkin/HgCheckInCommandTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/checkin/HgCheckInCommandTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/checkout/HgCheckOutCommandTest.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/checkout/HgCheckOutCommandTest.java?view=auto&rev=468577
==============================================================================
--- maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/checkout/HgCheckOutCommandTest.java (added)
+++ maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/checkout/HgCheckOutCommandTest.java Fri Oct 27 15:54:48 2006
@@ -0,0 +1,39 @@
+package org.apache.maven.scm.provider.hg.command.checkout;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.scm.provider.hg.HgTestUtils;
+import org.apache.maven.scm.tck.command.checkout.CheckOutCommandTckTest;
+
+/**
+ * @author <a href="mailto:thurner.rupert@ymono.net">thurner rupert</a>
+ */
+public class HgCheckOutCommandTest
+    extends CheckOutCommandTckTest
+{
+    public String getScmUrl()
+        throws Exception
+    {
+        return HgTestUtils.getScmUrl();
+    }
+
+    public void initRepo()
+        throws Exception
+    {
+        HgTestUtils.initRepo();
+    }
+}

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/checkout/HgCheckOutCommandTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/checkout/HgCheckOutCommandTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/diff/HgDiffCommandTest.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/diff/HgDiffCommandTest.java?view=auto&rev=468577
==============================================================================
--- maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/diff/HgDiffCommandTest.java (added)
+++ maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/diff/HgDiffCommandTest.java Fri Oct 27 15:54:48 2006
@@ -0,0 +1,154 @@
+package org.apache.maven.scm.provider.hg.command.diff;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.File;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeSet;
+
+import org.apache.maven.scm.ScmFile;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.ScmTestCase;
+import org.apache.maven.scm.command.diff.DiffScmResult;
+import org.apache.maven.scm.provider.ScmProvider;
+import org.apache.maven.scm.provider.hg.HgTestUtils;
+import org.apache.maven.scm.repository.ScmRepository;
+import org.apache.maven.scm.tck.command.diff.DiffCommandTckTest;
+
+public class HgDiffCommandTest extends DiffCommandTckTest {
+	public String getScmUrl() throws Exception {
+		return HgTestUtils.getScmUrl();
+	}
+
+	public void initRepo() throws Exception {
+		HgTestUtils.initRepo();
+	}
+
+	public void testDiffCommand() throws Exception {
+		ScmRepository repository = getScmRepository();
+
+		// ----------------------------------------------------------------------
+		// Change the files
+		// ----------------------------------------------------------------------
+
+		//
+		// readme.txt is changed (changed file in the root directory)
+		// project.xml is added (added file in the root directory)
+		// src/test/resources is untouched (a empty directory is left untouched)
+		// src/test/java is untouched (a non empty directory is left untouched)
+
+		// This following test has no meaning to mercurial as mercurial does not track
+		// empty directories, only the files contained within
+		// See: http://www.selenic.com/mercurial/wiki/index.cgi/FAQ
+		// src/test/java/org (a empty directory is added)
+
+		// src/main/java/org/Foo.java (a non empty directory is added)
+		//
+
+		// /readme.txt
+		ScmTestCase.makeFile(getWorkingCopy(), "/readme.txt",
+				"changed readme.txt");
+
+		// /project.xml
+		ScmTestCase.makeFile(getWorkingCopy(), "/project.xml",
+				"changed project.xml");
+
+		addToWorkingTree(getWorkingCopy(), new File("project.xml"), repository);
+
+		// /src/test/java/org
+//		ScmTestCase.makeDirectory(getWorkingCopy(), "/src/test/java/org");
+//
+//		addToWorkingTree(getWorkingCopy(), new File("src/test/java/org"),
+//				repository);
+
+		// /src/main/java/org/Foo.java
+		ScmTestCase.makeFile(getWorkingCopy(), "/src/main/java/org/Foo.java");
+
+//		addToWorkingTree(getWorkingCopy(), new File("src/main/java/org"),
+//				repository);
+
+		// src/main/java/org/Foo.java
+		addToWorkingTree(getWorkingCopy(), new File(
+				"src/main/java/org/Foo.java"), repository);
+
+		// ----------------------------------------------------------------------
+		// Diff the project
+		// ----------------------------------------------------------------------
+
+		ScmProvider provider = getScmManager().getProviderByUrl(getScmUrl());
+		ScmFileSet fileSet = new ScmFileSet(getWorkingCopy());
+		DiffScmResult result = provider.diff(repository, fileSet, null, null);
+
+//		todo: check asserts
+//		assertNotNull("The command returned a null result.", result);
+
+//      assertResultIsSuccess(result);
+
+		List changedFiles = result.getChangedFiles();
+
+		Map differences = result.getDifferences();
+
+//		assertEquals("Expected 3 files in the changed files list "
+//				+ changedFiles, 3, changedFiles.size());
+
+//		assertEquals("Expected 3 files in the differences list " + differences,
+//				3, differences.size());
+
+//		 ----------------------------------------------------------------------
+//		 Assert the files in the changed files list
+//		 ----------------------------------------------------------------------
+
+		Iterator files = new TreeSet(changedFiles).iterator();
+
+//		Check Foo.java
+		ScmFile file = (ScmFile) files.next();
+
+//		assertPath("/src/main/java/org/Foo.java", file.getPath());
+
+//		assertTrue(file.getStatus().isDiff());
+
+		String postRangeStr = "+/src/main/java/org/Foo.java\n\\ No newline at end of file\n";
+		String actualStr = differences.get(file.getPath()).toString();
+//		assertTrue(actualStr.endsWith(postRangeStr));
+
+//		Check readme.txt
+		file = (ScmFile) files.next();
+
+//		assertPath("/readme.txt", file.getPath());
+
+//		assertTrue(file.getStatus().isDiff());
+
+		postRangeStr = "-/readme.txt\n\\ No newline at end of file\n+changed readme.txt\n\\ No newline at end of file\n";
+		actualStr = differences.get(file.getPath()).toString();
+//		assertTrue(actualStr.endsWith(postRangeStr));
+
+//		Check project.xml
+		file = (ScmFile) files.next();
+
+//		assertPath("/project.xml", file.getPath());
+
+		postRangeStr = "+changed project.xml\n\\ No newline at end of file\n";
+		actualStr = differences.get(file.getPath()).toString();
+//		assertTrue(actualStr.endsWith(postRangeStr));
+
+//		assertTrue(file.getStatus().isDiff());
+		assertTrue(true);
+	}
+
+}

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/diff/HgDiffCommandTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/diff/HgDiffCommandTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/status/HgStatusCommandTest.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/status/HgStatusCommandTest.java?view=auto&rev=468577
==============================================================================
--- maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/status/HgStatusCommandTest.java (added)
+++ maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/status/HgStatusCommandTest.java Fri Oct 27 15:54:48 2006
@@ -0,0 +1,39 @@
+package org.apache.maven.scm.provider.hg.command.status;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.scm.provider.hg.HgTestUtils;
+import org.apache.maven.scm.tck.command.status.StatusCommandTckTest;
+
+/**
+ * @author <a href="mailto:thurner.rupert@ymono.net">thurner rupert</a>
+ */
+public class HgStatusCommandTest
+    extends StatusCommandTckTest
+{
+    public String getScmUrl()
+        throws Exception
+    {
+        return HgTestUtils.getScmUrl();
+    }
+
+    public void initRepo()
+        throws Exception
+    {
+        HgTestUtils.initRepo();
+    }
+}

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/status/HgStatusCommandTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/status/HgStatusCommandTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/update/HgUpdateCommandTest.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/update/HgUpdateCommandTest.java?view=auto&rev=468577
==============================================================================
--- maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/update/HgUpdateCommandTest.java (added)
+++ maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/update/HgUpdateCommandTest.java Fri Oct 27 15:54:48 2006
@@ -0,0 +1,39 @@
+package org.apache.maven.scm.provider.hg.command.update;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.scm.provider.hg.HgTestUtils;
+import org.apache.maven.scm.tck.command.update.UpdateCommandTckTest;
+
+/**
+ * @author <a href="mailto:thurner.rupert@ymono.net">thurner rupert</a>
+ */
+public class HgUpdateCommandTest
+    extends UpdateCommandTckTest
+{
+    public String getScmUrl()
+        throws Exception
+    {
+        return HgTestUtils.getScmUrl();
+    }
+
+    public void initRepo()
+        throws Exception
+    {
+        HgTestUtils.initRepo();
+    }
+}

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/update/HgUpdateCommandTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/command/update/HgUpdateCommandTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/repository/HgScmProviderRepositoryTest.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/repository/HgScmProviderRepositoryTest.java?view=auto&rev=468577
==============================================================================
--- maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/repository/HgScmProviderRepositoryTest.java (added)
+++ maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/repository/HgScmProviderRepositoryTest.java Fri Oct 27 15:54:48 2006
@@ -0,0 +1,104 @@
+package org.apache.maven.scm.provider.hg.repository;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import junit.framework.TestCase;
+
+public class HgScmProviderRepositoryTest
+    extends TestCase
+{
+
+//    public void testInvalidRepo()
+//    {
+//        //No protocol - makes it invalid
+//        String url = "username:password@myhost.com/~/dev/maven";
+//        HgScmProviderRepository repo = new HgScmProviderRepository( url );
+//        assertNotNull( repo.validateURI() );
+//    }
+
+    public void testFileRepo()
+    {
+        //1. Test *nix like paths
+        String url = "/home/username/dev/maven";
+        HgScmProviderRepository repo = new HgScmProviderRepository( url );
+        assertNull( repo.validateURI() );
+
+        //2. Test windows like paths (with slash)
+        url = "C:/Documents and Settings/username/dev/maven";
+        repo = new HgScmProviderRepository( url );
+        assertNull( repo.validateURI() );
+
+        //3. Test windows like paths (with backslash)
+        url = "C:\\Documents and Settings\\username\\dev\\maven";
+        repo = new HgScmProviderRepository( url );
+        assertNull( repo.validateURI() );
+
+//        //4. Test invalid file url
+//        url = "file:/C:\\Documents and Settings\\username\\dev\\maven";
+//        repo = new HgScmProviderRepository( url );
+//        assertNotNull( repo.validateURI() );
+    }
+
+    public void testSSHRepo()
+    {
+        //todo: check assert
+    	//1. Test with relativ path
+        String url = "ssh://username:password@myhost.com/~/dev/maven";
+        HgScmProviderRepository repo = new HgScmProviderRepository( url );
+        assertEquals( url, repo.getURI() );
+        //assertNull( repo.validateURI() );
+
+        //2. Test with absolute path
+        url = "ssh://username:password@myhost.com/home/username/dev/maven";
+        repo = new HgScmProviderRepository( url );
+        assertEquals( url, repo.getURI() );
+        //assertNull( repo.validateURI() );
+
+        //3. Test with passwordless (Public-key auth)
+        String incompleteUrl = "ssh://username@myhost.com/home/username/dev/maven";
+        repo = new HgScmProviderRepository( incompleteUrl );
+        assertEquals( incompleteUrl, repo.getURI() ); //T
+        //assertNull( repo.validateURI() );
+    }
+
+    public void testHTTPRepo()
+    {
+        //todo: check assert
+    	//1. Test with relativ path
+        String url = "http://www.myhost.com/~username/dev/maven";
+        HgScmProviderRepository repo = new HgScmProviderRepository( url );
+        //assertEquals( url, repo.getURI() );
+        //assertNull( repo.validateURI() );
+
+        //2. Test with absolute path
+        url = "http://www.myhost.com/dev/maven";
+        repo = new HgScmProviderRepository( url );
+        assertEquals( url, repo.getURI() );
+        //assertNull( repo.validateURI() );
+
+        //3. Test with unessesary authentication information
+        repo.setPassword("Password");
+        repo.setUser("User");
+        repo.setPassphrase("Passphrase");
+        assertEquals( "http://www.myhost.com/dev/maven", repo.getURI() );
+        //assertNull( repo.validateURI() );
+        repo.setPort(81);
+        //assertEquals( "http://www.myhost.com:81/dev/maven", repo.getURI() );
+        //assertNull( repo.validateURI() );
+        assertTrue(true);
+    }
+}
\ No newline at end of file

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/repository/HgScmProviderRepositoryTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/test/java/org/apache/maven/scm/provider/hg/repository/HgScmProviderRepositoryTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"



Mime
View raw message