Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
View | Details | Raw Unified | Return to bug 126588 | Differences between
and this patch

Collapse All | Expand All

(-)mercurial/src/org/netbeans/modules/mercurial/FileStatusCache.java (+1 lines)
 Lines 322-327   public class FileStatusCache { Link Here 
322
    
322
    
323
    private FileInformation refresh(File file, FileStatus repositoryStatus, 
323
    private FileInformation refresh(File file, FileStatus repositoryStatus, 
324
            boolean forceChangeEvent) {
324
            boolean forceChangeEvent) {
325
        Mercurial.LOG.log(Level.FINE, "refresh(): {0}", file); // NOI18N
325
        File dir = file.getParentFile();
326
        File dir = file.getParentFile();
326
        if (dir == null) {
327
        if (dir == null) {
327
            return FileStatusCache.FILE_INFORMATION_NOTMANAGED; //default for filesystem roots
328
            return FileStatusCache.FILE_INFORMATION_NOTMANAGED; //default for filesystem roots
(-)mercurial/src/org/netbeans/modules/mercurial/MercurialInterceptor.java (-3 / +41 lines)
 Lines 57-62   import java.util.Calendar; Link Here 
57
import java.util.Calendar;
57
import java.util.Calendar;
58
import org.netbeans.modules.mercurial.util.HgUtils;
58
import org.netbeans.modules.mercurial.util.HgUtils;
59
import org.netbeans.api.queries.SharabilityQuery;
59
import org.netbeans.api.queries.SharabilityQuery;
60
import java.util.concurrent.ConcurrentLinkedQueue;
61
60
62
61
/**
63
/**
62
 * Listens on file system changes and reacts appropriately, mainly refreshing affected files' status.
64
 * Listens on file system changes and reacts appropriately, mainly refreshing affected files' status.
 Lines 69-77   public class MercurialInterceptor extend Link Here 
69
71
70
    private List<File> dirsToDelete; 
72
    private List<File> dirsToDelete; 
71
73
74
    private ConcurrentLinkedQueue<File> filesToRefresh = new ConcurrentLinkedQueue<File>();
75
76
    private RequestProcessor.Task refreshTask;
77
78
    private static final RequestProcessor rp = new RequestProcessor("MercurialRefresh", 1, true);
79
72
    public MercurialInterceptor() {
80
    public MercurialInterceptor() {
73
        cache = Mercurial.getInstance().getFileStatusCache();
81
        cache = Mercurial.getInstance().getFileStatusCache();
74
        dirsToDelete = new ArrayList<File>();
82
        dirsToDelete = new ArrayList<File>();
83
        refreshTask = rp.create(new RefreshTask());
75
    }
84
    }
76
85
77
    public boolean beforeDelete(File file) {
86
    public boolean beforeDelete(File file) {
 Lines 315-321   public class MercurialInterceptor extend Link Here 
315
324
316
        HgProgressSupport supportCreate = new HgProgressSupport() {
325
        HgProgressSupport supportCreate = new HgProgressSupport() {
317
            public void perform() {
326
            public void perform() {
318
                cache.refresh(file, FileStatusCache.REPOSITORY_STATUS_UNKNOWN);
327
                // There is no point in refreshing the cache for ignored files.
328
                if (!HgUtils.isIgnored(file, false)) {
329
                    reScheduleRefresh(1000, file);
330
                }
319
            }
331
            }
320
        };
332
        };
321
333
 Lines 344-355   public class MercurialInterceptor extend Link Here 
344
                Mercurial.LOG.log(Level.FINE, "fileChangedImpl(): File: {0}", file); // NOI18N
356
                Mercurial.LOG.log(Level.FINE, "fileChangedImpl(): File: {0}", file); // NOI18N
345
                // There is no point in refreshing the cache for ignored files.
357
                // There is no point in refreshing the cache for ignored files.
346
                if (!HgUtils.isIgnored(file, false)) {
358
                if (!HgUtils.isIgnored(file, false)) {
347
                    cache.refresh(file, FileStatusCache.REPOSITORY_STATUS_UNKNOWN);
359
                    reScheduleRefresh(1000, file);
348
                }
360
                }
349
            }
361
            }
350
        };
362
        };
351
363
352
        supportCreate.start(rp, root.getAbsolutePath(), 
364
        supportCreate.start(rp, root.getAbsolutePath(), 
353
                org.openide.util.NbBundle.getMessage(MercurialInterceptor.class, "MSG_Change_Progress")); // NOI18N
365
                org.openide.util.NbBundle.getMessage(MercurialInterceptor.class, "MSG_Change_Progress")); // NOI18N
354
   }
366
    }
367
368
    private void reScheduleRefresh(int delayMillis, File fileToRefresh) {
369
        if (!filesToRefresh.contains(fileToRefresh)) {
370
            if (!filesToRefresh.offer(fileToRefresh)) {
371
                Mercurial.LOG.log(Level.FINE, "reScheduleRefresh failed to add to filesToRefresh queue {0}", fileToRefresh);
372
            }
373
        }
374
        refreshTask.schedule(delayMillis);
375
    }
376
377
    private class RefreshTask implements Runnable {
378
        public void run() {
379
            Thread.interrupted();
380
            File fileToRefresh = filesToRefresh.poll();
381
            if (fileToRefresh != null) {
382
                cache.refresh(fileToRefresh, FileStatusCache.REPOSITORY_STATUS_UNKNOWN);
383
                fileToRefresh = filesToRefresh.peek();
384
                if (fileToRefresh != null) {
385
                    refreshTask.schedule(0);
386
                }
387
            }
388
        }
389
    }
390
391
        
392
355
}
393
}

Return to bug 126588
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo