Finish (at least, on this branch) issue #1497 - svn_fs_history_prev()
can return duplicates.

* subversion/libsvn_fs/tree.c
  (txn_body_history_prev): If our last-reported history point also
    just happens to be a copy destination, skip it and move on the next
    history point.

git-svn-id: https://svn.apache.org/repos/asf/subversion/branches/issue-1499-dev@847355 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/subversion/libsvn_fs/tree.c b/subversion/libsvn_fs/tree.c
index bdc714e..29fbaec 100644
--- a/subversion/libsvn_fs/tree.c
+++ b/subversion/libsvn_fs/tree.c
@@ -4146,8 +4146,11 @@
 
   /* The Subversion filesystem is written in such a way that a given
      line of history may have at most one interesting history point
-     per filesystem revision.  So, if our history revision matches its
-     node's commit revision, we know that ... */
+     per filesystem revision.  Either that node was edited (and
+     possibly copied), or it was copied but not edited.  And a copy
+     source cannot be from the same revision as its destination.  So,
+     if our history revision matches its node's commit revision, we
+     know that ... */
   if (revision == commit_rev)
     {
       if (! reported)
@@ -4188,6 +4191,7 @@
   if (! end_copy_id)
     end_copy_id = examine_copy_inheritance (parent_path);
 
+  /* Initialize some state variables. */
   src_path = NULL;
   src_rev = SVN_INVALID_REVNUM;
   dst_rev = SVN_INVALID_REVNUM;
@@ -4253,6 +4257,19 @@
       *prev_history = assemble_history (fs, apr_pstrdup (retpool, path), 
                                         dst_rev, 1, src_path, src_rev, 
                                         retpool);
+      /* It's possible for us to find a copy location that is the same
+         as the history point we've just reported.  If that happens,
+         we simply need to take another trip through this history
+         search. */
+      if ((dst_rev == revision) && reported)
+        {
+          struct history_prev_args prev_args;
+          prev_args.prev_history_p = prev_history;
+          prev_args.history = *prev_history;
+          prev_args.cross_copies = args->cross_copies;
+          prev_args.pool = args->pool;
+          SVN_ERR (txn_body_history_prev (&prev_args, trail));
+        }
     }
   else
     {