Do not skip changes without current revision

If the current revision of a change is a draft patch set and the
querying user cannot see the draft patch set, then the
'current_revision' field in the ChangeInfo is not set. At the moment
we skip such changes, which is bad. Instead use the last revision as
current patch set in this case and log a warning.

Change-Id: I480d70e99079d4edd5ab1b101392d8bc65c3b726
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
diff --git a/src/main/java/com/googlesource/gerrit/plugins/importer/ReplayChangesStep.java b/src/main/java/com/googlesource/gerrit/plugins/importer/ReplayChangesStep.java
index 69b5789..dcebaff 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/importer/ReplayChangesStep.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/importer/ReplayChangesStep.java
@@ -180,12 +180,6 @@
           pluginName, c.id));
       return;
     }
-    if (c.currentRevision == null) {
-      log.warn(String.format(
-          "[%s] Change %s has no current revision.",
-          pluginName, c.id));
-      return;
-    }
 
     replayRevisionsFactory.create(repo, rw, change, c).replay(api);
     upsertChange(resumeChange, change, c);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/importer/ReplayRevisionsStep.java b/src/main/java/com/googlesource/gerrit/plugins/importer/ReplayRevisionsStep.java
index f13d4d3..ab9c061 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/importer/ReplayRevisionsStep.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/importer/ReplayRevisionsStep.java
@@ -130,7 +130,7 @@
         ps.setDraft(r.draft != null && r.draft);
 
         info = patchSetInfoFactory.get(commit, ps.getId());
-        if (changeInfo.currentRevision.equals(info.getRevId())) {
+        if (info.getRevId().equals(changeInfo.currentRevision)) {
           change.setCurrentPatchSet(info);
         }
 
@@ -140,11 +140,18 @@
       }
 
       if (change.currentPatchSetId() == null) {
-        log.warn(String.format(
-            "[%s] Current revision %s of change %s not found."
-            + " Setting lastest revision %s as current patch set.",
-            pluginName, changeInfo.currentRevision, changeInfo.id,
-            info.getRevId()));
+        if (changeInfo.currentRevision != null) {
+          log.warn(String.format(
+              "[%s] Current revision %s of change %s not found."
+              + " Setting lastest revision %s as current patch set.",
+              pluginName, changeInfo.currentRevision, changeInfo.id,
+              info.getRevId()));
+        } else {
+          log.warn(String.format(
+              "[%s] Change %s has no current revision."
+              + " Setting lastest revision %s as current patch set.",
+              pluginName, changeInfo.id, info.getRevId()));
+        }
         change.setCurrentPatchSet(info);
       }