Fix dependency cycle false positive

This corrects a false-positive in the dependency cycle detection,
but only for the new URL-style depends-on headers.  It does not
do so for the legacy gerrit headers.

We used a single history list to store all the changes we enqueued
ahead of a given change, but this meant that if there was more
than one path to a change, we would see it in the history on the
second traversal.  Instead, when traversing the tree, use copies
of the history list at each stage so that it can be rewound when
going back up the tree.  The second path to a change will not
trip the cycle detection, and will proceed on to the point where
it notices the change is already in the queue and return harmlessly.

Also, check whether the exact change is in the history, not just
the number, since numbers are no longer unique with multiple sources.

Also, fix a bug in the test_crd_cycle test which was causing the
test to always pass since the changes were never enqueued due to
missing approval requirements.

Change-Id: I3241f90a1d7469d433cfa176e719322203d4d089
Story: 2001427
Task: 6133
diff --git a/tests/unit/test_gerrit_legacy_crd.py b/tests/unit/test_gerrit_legacy_crd.py
index c711e4d..90c93ec 100644
--- a/tests/unit/test_gerrit_legacy_crd.py
+++ b/tests/unit/test_gerrit_legacy_crd.py
@@ -260,6 +260,7 @@
         B = self.fake_gerrit.addFakeChange('org/project2', 'master', 'B')
         A.addApproval('Code-Review', 2)
         B.addApproval('Code-Review', 2)
+        B.addApproval('Approved', 1)
 
         # A -> B -> A (via commit-depends)