Merge remote-tracking branch 'origin/patch'

This commit is contained in:
Ryan Kurtz 2025-04-29 12:38:59 -04:00
commit 73b743654a
3 changed files with 39 additions and 29 deletions

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -15,16 +15,6 @@
*/ */
package ghidra.app.merge.listing; package ghidra.app.merge.listing;
import ghidra.app.merge.tool.ListingMergePanel;
import ghidra.app.merge.util.ConflictUtility;
import ghidra.program.model.address.*;
import ghidra.program.model.listing.*;
import ghidra.program.model.mem.MemoryAccessException;
import ghidra.program.util.ProgramConflictException;
import ghidra.util.exception.AssertException;
import ghidra.util.exception.CancelledException;
import ghidra.util.task.TaskMonitor;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Hashtable; import java.util.Hashtable;
@ -33,6 +23,17 @@ import javax.swing.SwingUtilities;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import ghidra.app.merge.tool.ListingMergePanel;
import ghidra.app.merge.util.ConflictUtility;
import ghidra.program.model.address.*;
import ghidra.program.model.listing.*;
import ghidra.program.model.mem.MemoryAccessException;
import ghidra.program.util.ProgramConflictException;
import ghidra.util.SystemUtilities;
import ghidra.util.exception.AssertException;
import ghidra.util.exception.CancelledException;
import ghidra.util.task.TaskMonitor;
/** /**
* Class for merging bookmark changes. This class can merge non-conflicting * Class for merging bookmark changes. This class can merge non-conflicting
* bookmark changes that were made to the checked out version. It can determine * bookmark changes that were made to the checked out version. It can determine
@ -168,8 +169,8 @@ class BookmarkMerger extends AbstractListingMerger {
if (latest.length == 1) { if (latest.length == 1) {
String latestCategory = latest[0].getCategory(); String latestCategory = latest[0].getCategory();
String latestComment = latest[0].getComment(); String latestComment = latest[0].getComment();
if (!originalCategory.equals(latestCategory) || if (!SystemUtilities.isEqual(originalCategory, latestCategory) ||
!originalComment.equals(latestComment)) { !SystemUtilities.isEqual(originalComment, latestComment)) {
// MY deleted and LATEST changed, so conflict. // MY deleted and LATEST changed, so conflict.
addConflict(addr, originalType, null); addConflict(addr, originalType, null);
} }
@ -182,8 +183,8 @@ class BookmarkMerger extends AbstractListingMerger {
else if (my.length == 1) { else if (my.length == 1) {
String myCategory = my[0].getCategory(); String myCategory = my[0].getCategory();
String myComment = my[0].getComment(); String myComment = my[0].getComment();
if (!originalCategory.equals(myCategory) || if (!SystemUtilities.isEqual(originalCategory, myCategory) ||
!originalComment.equals(myComment)) { !SystemUtilities.isEqual(originalComment, myComment)) {
// Changed in MY // Changed in MY
if (latest.length == 0) { if (latest.length == 0) {
// MY changed and LATEST deleted, so conflict. // MY changed and LATEST deleted, so conflict.
@ -192,8 +193,10 @@ class BookmarkMerger extends AbstractListingMerger {
else if (latest.length == 1) { else if (latest.length == 1) {
String latestCategory = latest[0].getCategory(); String latestCategory = latest[0].getCategory();
String latestComment = latest[0].getComment(); String latestComment = latest[0].getComment();
if ((!originalCategory.equals(latestCategory) || !originalComment.equals(latestComment)) && if ((!SystemUtilities.isEqual(originalCategory, latestCategory) ||
(!myCategory.equals(latestCategory) || !myComment.equals(latestComment))) { !SystemUtilities.isEqual(originalComment, latestComment)) &&
(!SystemUtilities.isEqual(myCategory, latestCategory) ||
!SystemUtilities.isEqual(myComment, latestComment))) {
// MY changed and LATEST changed differently // MY changed and LATEST changed differently
addConflict(addr, originalType, null); addConflict(addr, originalType, null);
} }
@ -220,7 +223,7 @@ class BookmarkMerger extends AbstractListingMerger {
// Deleted in MY // Deleted in MY
if (latest != null) { if (latest != null) {
String latestComment = latest.getComment(); String latestComment = latest.getComment();
if (!originalComment.equals(latestComment)) { if (!SystemUtilities.isEqual(originalComment, latestComment)) {
// MY deleted and LATEST changed, so conflict. // MY deleted and LATEST changed, so conflict.
addConflict(addr, originalType, originalCategory); addConflict(addr, originalType, originalCategory);
} }
@ -232,7 +235,7 @@ class BookmarkMerger extends AbstractListingMerger {
} }
else { else {
String myComment = my.getComment(); String myComment = my.getComment();
if (!originalComment.equals(myComment)) { if (!SystemUtilities.isEqual(originalComment, myComment)) {
// Changed in MY // Changed in MY
if (latest == null) { if (latest == null) {
// MY changed and LATEST deleted, so conflict. // MY changed and LATEST deleted, so conflict.
@ -240,8 +243,8 @@ class BookmarkMerger extends AbstractListingMerger {
} }
else { else {
String latestComment = latest.getComment(); String latestComment = latest.getComment();
if (!originalComment.equals(latestComment) && if (!SystemUtilities.isEqual(originalComment, latestComment) &&
!myComment.equals(latestComment)) { !SystemUtilities.isEqual(myComment, latestComment)) {
// MY changed and LATEST changed differently // MY changed and LATEST changed differently
addConflict(addr, originalType, originalCategory); addConflict(addr, originalType, originalCategory);
} }
@ -291,8 +294,8 @@ class BookmarkMerger extends AbstractListingMerger {
else if (latest.length == 1) { else if (latest.length == 1) {
String latestCategory = latest[0].getCategory(); String latestCategory = latest[0].getCategory();
String latestComment = latest[0].getComment(); String latestComment = latest[0].getComment();
if (!myCategory.equals(latestCategory) || if (!SystemUtilities.isEqual(myCategory, latestCategory) ||
!myComment.equals(latestComment)) { !SystemUtilities.isEqual(myComment, latestComment)) {
// MY & LATEST added different NOTEs, so conflict. // MY & LATEST added different NOTEs, so conflict.
addConflict(addr, myType, null); addConflict(addr, myType, null);
} }
@ -316,7 +319,7 @@ class BookmarkMerger extends AbstractListingMerger {
} }
else { else {
String latestComment = latest.getComment(); String latestComment = latest.getComment();
if (!myComment.equals(latestComment)) { if (!SystemUtilities.isEqual(myComment, latestComment)) {
// MY & LATEST added same bookmark w/ different comments, so conflict. // MY & LATEST added same bookmark w/ different comments, so conflict.
addConflict(addr, myType, myCategory); addConflict(addr, myType, myCategory);
} }

View file

@ -76,7 +76,8 @@ public class BookmarkDB extends DatabaseObject implements Bookmark {
@Override @Override
public String getCategory() { public String getCategory() {
return record.getString(BookmarkDBAdapter.CATEGORY_COL); String category = record.getString(BookmarkDBAdapter.CATEGORY_COL);
return category != null ? category : ""; // NOTE: Old data may have stored null
} }
public void setComment(String comment) { public void setComment(String comment) {
@ -92,7 +93,8 @@ public class BookmarkDB extends DatabaseObject implements Bookmark {
@Override @Override
public String getComment() { public String getComment() {
return record.getString(BookmarkDBAdapter.COMMENT_COL); String comment = record.getString(BookmarkDBAdapter.COMMENT_COL);
return comment != null ? comment : ""; // NOTE: Old data may have stored null
} }
@Override @Override

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -206,6 +206,11 @@ public class BookmarkDBAdapterV3 extends BookmarkDBAdapter {
return null; return null;
} }
if (category == null)
category = "";
if (comment == null)
comment = "";
Table table = tables[typeID]; Table table = tables[typeID];
long nextId = table.getKey() + 1; long nextId = table.getKey() + 1;
long id = ((long) typeID << TYPE_ID_OFFSET) | nextId; long id = ((long) typeID << TYPE_ID_OFFSET) | nextId;