I created the patch from my git repo via
git format-patch --relative <sha1>...<sha2>
to create 2 patches: 01.patch
and 02.patch
. I imported the patches to my hg repo via
hg import <patch file>
The first patch works, which is an entire file addition of workspace/GraphUtilities/src/edu/washington/cs/utils/graph/impl/EdgeBase.java
. The second patch is a diff on the file workspace/GraphUtilities/src/edu/washington/cs/utils/graph/impl/UndirectedEdge.java
, and I get the following output:
[lucas-ThinkPad-W520]/home/.../.Solstice_WS/7K_Manual$ hg import 0*
applying 01.patch
applying 02.patch
patching file workspace/GraphUtilities/src/edu/washington/cs/utils/graph/impl/UndirectedEdge.java
Hunk #1 FAILED at 10
Hunk #2 FAILED at 21
Hunk #3 FAILED at 30
Hunk #4 FAILED at 39
Hunk #5 FAILED at 48
Hunk #6 FAILED at 57
6 out of 6 hunks FAILED -- saving rejects to file workspace/GraphUtilities/src/edu/washington/cs/utils/graph/impl/UndirectedEdge.java.rej
transaction abort!
rollback completed
abort: patch failed to apply
[lucas-ThinkPad-W520]/home/.../.Solstice_WS/7K_Manual$ ls
Any suggestions on how to debug this? The diffs in the code (the "hunks") seem to match up perfectly. Any suggestions on where to look, or what other factors to consider when debugging?
Here is a relevant section of my .hgrc:
[extensions]
mq =
hgext.purge=
hgext.fetch=
shelve=
[diff]
git = 1
showfunc = 1
unified = 8
If interested, here are the hunks and the original UndirectedEdge.java
file:
The hunks:
.../washington/cs/utils/graph/impl/UndirectedEdge.java | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/workspace/GraphUtilities/src/edu/washington/cs/utils/graph/impl/UndirectedEdge.java b/workspace/GraphUtilities/src/edu/washington/cs/utils/graph/impl/UndirectedEdge.java
index ef7e993..647f4f1 100644
--- a/workspace/GraphUtilities/src/edu/washington/cs/utils/graph/impl/UndirectedEdge.java
+++ b/workspace/GraphUtilities/src/edu/washington/cs/utils/graph/impl/UndirectedEdge.java
@@ -11,7 +11,8 @@ import edu.washington.cs.utils.graph.IVertex;
*
* @param <V> Vertex type for the edge
*/
-public class UndirectedEdge<V extends IVertex> implements IUndirectedEdge<V>
+public class UndirectedEdge<V extends IVertex> extends EdgeBase<V>
+ implements IUndirectedEdge<V>
{
/**
* Constructs an undirected edge between <code>vertex1</code> and <code>vertex1</code>.
@@ -22,7 +23,7 @@ public class UndirectedEdge<V extends IVertex> implements IUndirectedEdge<V>
*/
public UndirectedEdge(V vertex1, V vertex2)
{
- throw new RuntimeException("Method not implemented.");
+ super(vertex1, vertex2);
}
/**
@@ -31,7 +32,7 @@ public class UndirectedEdge<V extends IVertex> implements IUndirectedEdge<V>
@Override
public Set<V> getVertices()
{
- throw new RuntimeException("Method not implemented.");
+ return super.getVertices();
}
/**
@@ -40,7 +41,7 @@ public class UndirectedEdge<V extends IVertex> implements IUndirectedEdge<V>
@Override
public boolean equals(IUndirectedEdge<?> other)
{
- throw new RuntimeException("Method not implemented.");
+ return getVertices().equals(other.getVertices());
}
/**
@@ -49,7 +50,9 @@ public class UndirectedEdge<V extends IVertex> implements IUndirectedEdge<V>
@Override
public boolean equals(Object other)
{
- throw new RuntimeException("Method not implemented.");
+ if (other instanceof IUndirectedEdge<?>)
+ return equals((IUndirectedEdge<?>) other);
+ return false;
}
/**
@@ -58,6 +61,8 @@ public class UndirectedEdge<V extends IVertex> implements IUndirectedEdge<V>
@Override
public int hashCode()
{
- throw new RuntimeException("Method not implemented.");
+ int result = 17;
+ result = result * 31 + getVertices().hashCode();
+ return result;
}
}
--
1.9.1
UndirectedEdge.java:
package edu.washington.cs.utils.graph.impl;
import java.util.Set;
import edu.washington.cs.utils.graph.IUndirectedEdge;
import edu.washington.cs.utils.graph.IVertex;
/**
* UndirectedEdge is a implementation of {@link IUndirectedEdge}.
*
* @param <V> Vertex type for the edge
*/
public class UndirectedEdge<V extends IVertex> implements IUndirectedEdge<V>
{
/**
* Constructs an undirected edge between <code>vertex1</code> and <code>vertex1</code>.
*
* @param vertex1 vertex at one end of the edge.
* @param vertex2 vertex at the other end of the edge.
* @throws IllegalArgumentException if any of the arguments is <code>null</code>
*/
public UndirectedEdge(V vertex1, V vertex2)
{
throw new RuntimeException("Method not implemented.");
}
/**
* {@inheritDoc}
*/
@Override
public Set<V> getVertices()
{
throw new RuntimeException("Method not implemented.");
}
/**
* {@inheritDoc}
*/
@Override
public boolean equals(IUndirectedEdge<?> other)
{
throw new RuntimeException("Method not implemented.");
}
/**
* {@inheritDoc}
*/
@Override
public boolean equals(Object other)
{
throw new RuntimeException("Method not implemented.");
}
/**
* {@inheritDoc}
*/
@Override
public int hashCode()
{
throw new RuntimeException("Method not implemented.");
}
}