Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ide/git/nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.
javac.compilerargs=-Xlint
javac.release=17
javac.release=21
nbm.homepage=http://netbeans.org/projects/versioncontrol/pages/Git_main
nbm.module.author=Ondrej Vrabec
nbm.needs.restart=true
Expand Down
10 changes: 8 additions & 2 deletions ide/git/src/org/netbeans/modules/git/FileStatusCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
public class FileStatusCache {

public static final String PROP_FILE_STATUS_CHANGED = "status.changed"; // NOI18N
public static final String PROP_FILES_STATUS_CHANGED = "status.changed.batch"; // NOI18N

private final CacheIndex conflictedFiles, modifiedFiles, ignoredFiles;
private static final Logger LOG = Logger.getLogger("org.netbeans.modules.git.status.cache"); //NOI18N
Expand Down Expand Up @@ -562,6 +563,7 @@ private void refreshStatusesBatch (Map<File, GitStatus> interestingFiles) {
boolean fireEvent = true;
current = getInfo(file);
fi = checkForIgnore(fi, current, file);
boolean upToDateOnFirstLoad = current == null && fi.getStatus().equals(EnumSet.of(Status.UPTODATE));
if (equivalent(fi, current)) {
// no need to fire an event
if (Utilities.isWindows() || Utilities.isMac()) {
Expand All @@ -570,6 +572,10 @@ private void refreshStatusesBatch (Map<File, GitStatus> interestingFiles) {
} else {
continue;
}
} else if (upToDateOnFirstLoad) {
// file is up-to-date and not yet in cache: UPTODATE is the implicit default,
// no cache update or event needed
continue;
}
boolean addToIndex = updateCachedValue(fi, file);
indexUpdates.add(new IndexUpdateItem(file, fi, addToIndex));
Expand All @@ -579,8 +585,8 @@ private void refreshStatusesBatch (Map<File, GitStatus> interestingFiles) {
}
updateIndexBatch(indexUpdates);
}
for (ChangedEvent event : events) {
fireFileStatusChanged(event);
if (!events.isEmpty()) {
listenerSupport.firePropertyChange(PROP_FILES_STATUS_CHANGED, null, events);
}
}

Expand Down
19 changes: 14 additions & 5 deletions ide/git/src/org/netbeans/modules/git/GitVCS.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import java.beans.PropertyChangeListener;
import java.util.MissingResourceException;
import java.io.File;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.logging.Logger;
import java.util.prefs.PreferenceChangeEvent;
Expand All @@ -38,17 +40,17 @@
* @author ondra
*/
@VersioningSystem.Registration(
displayName="#CTL_Git_DisplayName",
menuLabel="#CTL_Git_MainMenu",
metadataFolderNames={".git"},
displayName="#CTL_Git_DisplayName",
menuLabel="#CTL_Git_MainMenu",
metadataFolderNames={".git"},
actionsCategory="Git"
)
public class GitVCS extends VersioningSystem implements PropertyChangeListener, PreferenceChangeListener {

private static final Logger LOG = Logger.getLogger("org.netbeans.modules.git.GitVCS"); //NOI18N

public GitVCS() {
putProperty(PROP_DISPLAY_NAME, getDisplayName());
putProperty(PROP_DISPLAY_NAME, getDisplayName());
putProperty(PROP_MENU_LABEL, org.openide.util.NbBundle.getMessage(GitVCS.class, "CTL_Git_MainMenu")); // NOI18N
GitModuleConfig.getDefault().getPreferences().addPreferenceChangeListener(this);
Git.getInstance().registerGitVCS(this);
Expand Down Expand Up @@ -77,7 +79,7 @@ public void getOriginalFile (File workingCopy, File originalFile) {
public File getTopmostManagedAncestor(File file) {
return Git.getInstance().getTopmostManagedAncestor(file);
}

@Override
public CollocationQueryImplementation getCollocationQueryImplementation() {
return collocationQueryImplementation;
Expand Down Expand Up @@ -111,6 +113,13 @@ public void propertyChange(PropertyChangeEvent event) {
if (event.getPropertyName().equals(FileStatusCache.PROP_FILE_STATUS_CHANGED)) {
FileStatusCache.ChangedEvent changedEvent = (FileStatusCache.ChangedEvent) event.getNewValue();
fireStatusChanged(changedEvent.getFile());
} else if (event.getPropertyName().equals(FileStatusCache.PROP_FILES_STATUS_CHANGED)) {
List<FileStatusCache.ChangedEvent> changedEvents = (List<FileStatusCache.ChangedEvent>) event.getNewValue();
Set<File> files = HashSet.newHashSet(changedEvents.size());
for (FileStatusCache.ChangedEvent e : changedEvents) {
files.add(e.getFile());
}
fireStatusChanged(files);
} else if (event.getPropertyName().equals(Git.PROP_ANNOTATIONS_CHANGED)) {
fireAnnotationsChanged((Set<File>) event.getNewValue());
} else if (event.getPropertyName().equals(Git.PROP_VERSIONED_FILES_CHANGED)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public class MultiDiffPanelController implements ActionListener, PropertyChangeL

private GitProgressSupport statusRefreshSupport;
private PreferenceChangeListener prefList;

private final Revision revisionOriginalLeft;
private final Revision revisionOriginalRight;
private Revision revisionLeft;
Expand All @@ -211,7 +211,7 @@ public class MultiDiffPanelController implements ActionListener, PropertyChangeL
private int popupViewIndex;
private int requestedRightLine = -1;
private int requestedLeftLine = -1;

private static final int VIEW_MODE_TABLE = 1;
private static final int VIEW_MODE_TREE = 2;
private int currentSetupDiffLengthChanged;
Expand Down Expand Up @@ -270,7 +270,7 @@ public MultiDiffPanelController (File file, Revision rev1, Revision rev2, int re
prepareTask = RP.create(dpt);
prepareTask.schedule(0);
}

private MultiDiffPanelController (VCSContext context, Revision revisionLeft, Revision revisionRight, boolean fixedRevisions) {
this.context = context;
this.revisionLeft = revisionOriginalLeft = revisionLeft;
Expand Down Expand Up @@ -315,7 +315,7 @@ private void setActiveComponent (DiffFileViewComponent<DiffNode> fileComponent)
panel.splitPane.setTopComponent(getActiveFileComponent().getComponent());
panel.splitPane.setDividerLocation(gg);
}

private void refreshSelectionCombos () {
if (!fixedRevisions && GitUtils.getRepositoryRoots(context).size() == 1) {
panel.cmbDiffTreeFirst.setEnabled(false);
Expand Down Expand Up @@ -432,7 +432,7 @@ public void componentClosed () {
cancelBackgroundTasks();
setups.clear();
editorCookies.clear();

if (list != null) {
Git.getInstance().getFileStatusCache().removePropertyChangeListener(list);
}
Expand Down Expand Up @@ -569,7 +569,7 @@ private void initToolbarButtons () {
panel.treeButton.setVisible(false);
}
}

private JComponent getInfoPanelLoading () {
if (infoPanelLoadingFromRepo == null) {
infoPanelLoadingFromRepo = new NoContentPanel(NbBundle.getMessage(MultiDiffPanel.class, "MSG_DiffPanel_NoContent"));
Expand Down Expand Up @@ -812,11 +812,11 @@ public void run () {
public void run () {
multiTextDiffSupport = null;
}

});
}
}

private String findEncoding () {
for (File f : actionRoots.getValue()) {
FileObject fo = FileUtil.toFileObject(f);
Expand Down Expand Up @@ -861,7 +861,7 @@ private void exportDiff (ByteArrayOutputStream bos) throws GitException {
actionRoots.getKey(), Bundle.MSG_DiffPanel_multiTextualDiff_preparing());
}
}

});
displayDiffView();
}
Expand Down Expand Up @@ -891,7 +891,7 @@ private Map.Entry<File, File[]> getSelectedActionRoots () {
ctx = GitUtils.getContextForFiles(filterExcluded(selectedFiles));
return GitUtils.getActionRoots(ctx);
}

private File[] filterExcluded (File[] files) {
List<File> filtered = new ArrayList<>(files.length);
for (File f : files) {
Expand All @@ -903,7 +903,7 @@ private File[] filterExcluded (File[] files) {
}
return filtered.toArray(new File[0]);
}

private boolean showingFileComponent() {
return getActiveFileComponent() != null;
}
Expand Down Expand Up @@ -1064,7 +1064,7 @@ private DiffMode getDiffMode () {
}
return diffMode;
}

private Revision getSelectedRevision (JComboBox cmbDiffTree) {
Object selectedItem = cmbDiffTree.getSelectedItem();
Revision selection = null;
Expand Down Expand Up @@ -1123,15 +1123,25 @@ public void propertyChange (PropertyChangeEvent evt) {
if (FileStatusCache.PROP_FILE_STATUS_CHANGED.equals(evt.getPropertyName())) {
FileStatusCache.ChangedEvent changedEvent = (FileStatusCache.ChangedEvent) evt.getNewValue();
if (LOG.isLoggable(Level.FINE)) {
LOG.log(Level.FINE, "File status for file {0} changed from {1} to {2}", new Object[] {
changedEvent.getFile(),
LOG.log(Level.FINE, "File status for file {0} changed from {1} to {2}", new Object[] {
changedEvent.getFile(),
changedEvent.getOldInfo(),
changedEvent.getNewInfo() } );
}
if (revisionLeft == Revision.HEAD // remove when we're able to refresh single file changes for Local vs. any revision
if (revisionLeft == Revision.HEAD // remove when we're able to refresh single file changes for Local vs. any revision
&& revisionRight == Revision.LOCAL && affectsView(changedEvent)) {
applyChange(changedEvent);
}
} else if (FileStatusCache.PROP_FILES_STATUS_CHANGED.equals(evt.getPropertyName())) {
if (revisionLeft == Revision.HEAD && revisionRight == Revision.LOCAL) {
@SuppressWarnings("unchecked")
List<FileStatusCache.ChangedEvent> changedEvents = (List<FileStatusCache.ChangedEvent>) evt.getNewValue();
for (FileStatusCache.ChangedEvent changedEvent : changedEvents) {
if (affectsView(changedEvent)) {
applyChange(changedEvent);
}
}
}
} else if (DiffController.PROP_DIFFERENCES.equals(evt.getPropertyName())) {
// something has changed
Setup setup = currentSetup;
Expand Down Expand Up @@ -1537,7 +1547,7 @@ private boolean isLocal () {
* Eliminates unnecessary cache.listFiles call as well as the whole node creation process ()
*/
private final class ApplyChangesTask implements Runnable, Cancellable {

private volatile boolean canceled;

@Override
Expand Down Expand Up @@ -1651,7 +1661,7 @@ public boolean cancel () {
return true;
}
}

private class RefreshComboTask implements Runnable {

@Override
Expand All @@ -1663,7 +1673,7 @@ public void run () {
if (revisionOriginalLeft != Revision.HEAD) {
modelLeft.add(Revision.HEAD);
}
modelRight.add(revisionOriginalRight);
modelRight.add(revisionOriginalRight);
if (revisionOriginalRight != Revision.LOCAL) {
modelRight.add(Revision.LOCAL);
}
Expand Down Expand Up @@ -1767,7 +1777,7 @@ public void run() {
GitClientExceptionHandler.notifyException(exception, true);
}
}

private DiffNode[] prepareSetupsToRefresh () {
return Mutex.EVENT.readAccess(new Mutex.Action<DiffNode[]>() {
@Override
Expand Down Expand Up @@ -1810,7 +1820,7 @@ private int getMatchingLine (StreamSource ss2, StreamSource ss1, int requestedRi
}
}
}// </editor-fold>

@NbBundle.Messages({
"MSG_Revision_Select_Tooltip=Select a revision from the picker"
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,14 @@ public void propertyChange (PropertyChangeEvent evt) {
if (affectsView((FileStatusCache.ChangedEvent) evt.getNewValue())) {
applyChange(changedEvent);
}
} else if (FileStatusCache.PROP_FILES_STATUS_CHANGED.equals(evt.getPropertyName())) {
@SuppressWarnings("unchecked")
List<FileStatusCache.ChangedEvent> changedEvents = (List<FileStatusCache.ChangedEvent>) evt.getNewValue();
for (FileStatusCache.ChangedEvent changedEvent : changedEvents) {
if (affectsView(changedEvent)) {
applyChange(changedEvent);
}
}
}
}

Expand Down
Loading
Loading