Merge branch 'stable-2.14' into stable-2.15
* stable-2.14:
Change equality comparison for consistency
Handle sub-patch versioning
Handle changes in refs/meta
Handle file comment
Fix inline comment position
Use latest bazlets
Change-Id: I917ad34fbc711e78f02302eaf03c75b8e12b7e1e
diff --git a/src/main/java/com/googlesource/gerrit/plugins/importer/GerritApi.java b/src/main/java/com/googlesource/gerrit/plugins/importer/GerritApi.java
index 88cddce..ef1c1a6 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/importer/GerritApi.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/importer/GerritApi.java
@@ -82,22 +82,25 @@
final Integer major;
final Integer minor;
final Integer patch;
+ final Integer revision;
final String qualifier;
Version(String formatted) {
this.formatted = formatted;
- Matcher m = Pattern.compile("(\\d+)\\.(\\d+)(\\.(\\d+))?(-(.+))?")
+ Matcher m = Pattern.compile("(\\d+)\\.(\\d+)(\\.(\\d+))?(\\.(\\d+))?(-(.+))?")
.matcher(formatted);
if (m.matches()) {
this.major = Integer.parseInt(m.group(1));
this.minor = Integer.parseInt(m.group(2));
this.patch = m.group(3) != null ? Integer.parseInt(m.group(4)) : null;
- this.qualifier = m.group(5) != null ? m.group(6) : null;
+ this.revision = m.group(5) != null ? Integer.parseInt(m.group(6)) : null;
+ this.qualifier = m.group(7) != null ? m.group(8) : null;
} else {
this.major = null;
this.minor = null;
this.patch = null;
+ this.revision = null;
this.qualifier = null;
}
}
@@ -108,7 +111,7 @@
// either of the compared version is not valid
return -1;
}
- if (major == o.major) {
+ if (Objects.equal(major, o.major)) {
if (Objects.equal(minor, o.minor)) {
if (Objects.equal(patch, o.patch)) {
return 0;
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 8cc0c83..2820b15 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/importer/ReplayChangesStep.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/importer/ReplayChangesStep.java
@@ -25,6 +25,7 @@
import com.google.gerrit.reviewdb.client.Branch;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.Project;
+import com.google.gerrit.reviewdb.client.RefNames;
import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.Sequences;
import com.google.gerrit.server.update.UpdateException;
@@ -39,7 +40,6 @@
import com.google.inject.assistedinject.Assisted;
import org.eclipse.jgit.errors.ConfigInvalidException;
-import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ProgressMonitor;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevWalk;
@@ -215,7 +215,7 @@
private Change findChange(ChangeInfo c) throws OrmException {
List<Change> changes = ChangeData.asChanges(
queryProvider.get().byBranchKey(
- new Branch.NameKey(targetProject, fullName(c.branch)),
+ new Branch.NameKey(targetProject, RefNames.fullName(c.branch)),
new Change.Key(c.changeId)));
if (changes.isEmpty()) {
return null;
@@ -231,7 +231,7 @@
Change change =
new Change(new Change.Key(c.changeId), changeId, accountUtil.resolveUser(api, c.owner),
- new Branch.NameKey(targetProject, fullName(c.branch)), c.created);
+ new Branch.NameKey(targetProject, RefNames.fullName(c.branch)), c.created);
change.setStatus(Change.Status.forChangeStatus(c.status));
change.setTopic(c.topic);
change.setLastUpdatedOn(c.updated);
@@ -247,11 +247,4 @@
}
db.changes().upsert(Collections.singleton(change));
}
-
- private static String fullName(String branch) {
- if (branch.startsWith(Constants.R_HEADS)) {
- return branch;
- }
- return Constants.R_HEADS + branch;
- }
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/importer/ReplayInlineCommentsStep.java b/src/main/java/com/googlesource/gerrit/plugins/importer/ReplayInlineCommentsStep.java
index ec1062c..b1ec866 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/importer/ReplayInlineCommentsStep.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/importer/ReplayInlineCommentsStep.java
@@ -209,6 +209,8 @@
c.range.endLine,
c.range.endCharacter));
e.lineNbr = c.range.endLine;
+ } else {
+ e.lineNbr = c.line == null ? 0 : c.line;
}
ups.add(e);
}