Index: src/plugin/build.xml
===================================================================
--- src/plugin/build.xml	(revision 1687080)
+++ src/plugin/build.xml	(working copy)
@@ -106,6 +106,7 @@
      <ant dir="parse-swf" target="test"/>
      <ant dir="parse-tika" target="test"/>
      <ant dir="parse-zip" target="test"/>
+     <ant dir="scoring-depth" target="test"/>
      <ant dir="subcollection" target="test"/>
      <ant dir="urlfilter-automaton" target="test"/>
      <ant dir="urlfilter-domain" target="test"/>
Index: src/plugin/scoring-depth/src/java/org/apache/nutch/scoring/depth/DepthScoringFilter.java
===================================================================
--- src/plugin/scoring-depth/src/java/org/apache/nutch/scoring/depth/DepthScoringFilter.java	(revision 1687080)
+++ src/plugin/scoring-depth/src/java/org/apache/nutch/scoring/depth/DepthScoringFilter.java	(working copy)
@@ -1,3 +1,19 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
 package org.apache.nutch.scoring.depth;
 
 import java.util.Collection;
@@ -17,6 +33,7 @@
 import org.apache.nutch.parse.Parse;
 import org.apache.nutch.parse.ParseData;
 import org.apache.nutch.protocol.Content;
+import org.apache.nutch.util.URLUtil;
 import org.apache.nutch.scoring.ScoringFilter;
 import org.apache.nutch.scoring.ScoringFilterException;
 
@@ -40,6 +57,8 @@
   public static final int DEFAULT_MAX_DEPTH = 1000;
 
   private int defaultMaxDepth;
+  
+  private boolean ignoreExternal = false;
 
   @Override
   public void setConf(Configuration conf) {
@@ -50,6 +69,7 @@
     if (defaultMaxDepth <= 0) {
       defaultMaxDepth = DEFAULT_MAX_DEPTH;
     }
+    ignoreExternal = conf.getBoolean("scoring.depth.ignore.exteral", false);
   }
 
   @Override
@@ -56,6 +76,7 @@
   public CrawlDatum distributeScoreToOutlinks(Text fromUrl,
       ParseData parseData, Collection<Entry<Text, CrawlDatum>> targets,
       CrawlDatum adjust, int allCount) throws ScoringFilterException {
+    String fromHost = URLUtil.getHost(fromUrl.toString());
     String depthString = parseData.getMeta(DEPTH_KEY);
     if (depthString == null) {
       LOG.warn("Missing depth, removing all outlinks from url " + fromUrl);
@@ -71,7 +92,7 @@
       curMaxDepth = Integer.parseInt(maxDepthString);
       customMaxDepth = new IntWritable(curMaxDepth);
     }
-    if (curDepth >= curMaxDepth) {
+    if (curMaxDepth > 0 && curDepth >= curMaxDepth) {
       // depth exceeded - throw away
       LOG.info("Depth limit (" + curMaxDepth
           + ") reached, ignoring outlinks for " + fromUrl);
@@ -81,6 +102,14 @@
     Iterator<Entry<Text, CrawlDatum>> it = targets.iterator();
     while (it.hasNext()) {
       Entry<Text, CrawlDatum> e = it.next();
+      
+      if (ignoreExternal) {
+        String toHost = URLUtil.getHost(e.getKey().toString());
+        if (!toHost.equals(fromHost)) {
+          continue;
+        }
+      }
+
       // record increased depth
       e.getValue().getMetaData()
           .put(DEPTH_KEY_W, new IntWritable(curDepth + 1));
Index: src/plugin/scoring-depth/src/test/org/apache/nutch/scoring/depth/TestDepthScoringFilter.java
===================================================================
--- src/plugin/scoring-depth/src/test/org/apache/nutch/scoring/depth/TestDepthScoringFilter.java	(revision 0)
+++ src/plugin/scoring-depth/src/test/org/apache/nutch/scoring/depth/TestDepthScoringFilter.java	(working copy)
@@ -0,0 +1,108 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.nutch.scoring.depth;
+
+import java.util.AbstractMap.SimpleEntry;
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.List;
+import java.util.Map;
+import java.util.ArrayList;
+import java.util.HashMap;
+import junit.framework.TestCase;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.io.MapWritable;
+import org.apache.hadoop.io.Text;
+import org.apache.nutch.crawl.CrawlDatum;
+import org.apache.nutch.parse.ParseData;
+import org.apache.nutch.scoring.ScoringFilter;
+import org.apache.nutch.scoring.ScoringFilterException;
+import org.apache.nutch.util.NutchConfiguration;
+
+public class TestDepthScoringFilter extends TestCase {
+
+  public void testPropagateDepthToExternalHost() throws Exception {
+    Configuration conf = NutchConfiguration.create();
+    ScoringFilter filter = new DepthScoringFilter();
+    filter.setConf(conf);
+    
+    Text sourceUrl = new Text("http://nutch.apache.org/");
+    CrawlDatum sourceDatum = new CrawlDatum();
+    ParseData parseData = new ParseData();
+    parseData.getParseMeta().add(DepthScoringFilter.DEPTH_KEY, "1");
+    
+    // Make some outlinks to external hosts
+    List<Map.Entry<Text,CrawlDatum>> outlinks = new ArrayList<Map.Entry<Text,CrawlDatum>>();
+    for (int i = 0; i < 10; i++) {
+      Map.Entry<Text, CrawlDatum> outlink = new SimpleEntry<Text, CrawlDatum>(new Text("http://external" + i + ".apache.org"), new CrawlDatum());
+      outlinks.add(outlink);
+    }
+    
+    // and one internal
+    Map.Entry<Text, CrawlDatum> outlink = new SimpleEntry<Text, CrawlDatum>(new Text("http://nutch.apache.org/stuff"), new CrawlDatum());
+    outlinks.add(outlink);
+    
+    // Do stuff
+    filter.distributeScoreToOutlinks(sourceUrl, parseData, outlinks, sourceDatum, 0);
+    
+    // All outlinks should have depth 2
+    Iterator<Entry<Text,CrawlDatum>> it = outlinks.iterator();
+    while (it.hasNext()) {
+      Entry<Text,CrawlDatum> e = it.next();
+      assertEquals("2", e.getValue().getMetaData().get(DepthScoringFilter.DEPTH_KEY_W).toString());      
+    }
+  }
+  
+  public void testPreventPropagateDepthToExternalHost() throws Exception {
+    Configuration conf = NutchConfiguration.create();
+    ScoringFilter filter = new DepthScoringFilter();
+    conf.setBoolean("scoring.depth.ignore.exteral", true);
+    filter.setConf(conf);
+    
+    Text sourceUrl = new Text("http://nutch.apache.org/");
+    CrawlDatum sourceDatum = new CrawlDatum();
+    ParseData parseData = new ParseData();
+    parseData.getParseMeta().add(DepthScoringFilter.DEPTH_KEY, "1");
+    
+    // Make some outlinks to external hosts
+    List<Map.Entry<Text,CrawlDatum>> outlinks = new ArrayList<Map.Entry<Text,CrawlDatum>>();
+    for (int i = 0; i < 10; i++) {
+      Map.Entry<Text, CrawlDatum> outlink = new SimpleEntry<Text, CrawlDatum>(new Text("http://external" + i + ".apache.org"), new CrawlDatum());
+      outlinks.add(outlink);
+    }
+    
+    // and one internal
+    Map.Entry<Text, CrawlDatum> outlink = new SimpleEntry<Text, CrawlDatum>(new Text("http://nutch.apache.org/stuff"), new CrawlDatum());
+    outlinks.add(outlink);
+    
+    // Do stuff
+    filter.distributeScoreToOutlinks(sourceUrl, parseData, outlinks, sourceDatum, 0);
+    
+    // All outlinks should have depth 2
+    Iterator<Entry<Text,CrawlDatum>> it = outlinks.iterator();
+    while (it.hasNext()) {
+      Entry<Text,CrawlDatum> e = it.next();
+      
+      if (e.getKey().toString().equals("http://nutch.apache.org/stuff")) {
+        assertEquals("2", e.getValue().getMetaData().get(DepthScoringFilter.DEPTH_KEY_W).toString());
+      } else {
+        assertEquals(null, e.getValue().getMetaData().get(DepthScoringFilter.DEPTH_KEY_W));
+      }
+    }
+  } 
+}
\ No newline at end of file
