Changeset 3:296778dfdf6d

Show
Ignore:
Timestamp:
10/19/08 22:24:45 (3 years ago)
Author:
Whitney Sorenson <ws@…>
Branch:
default
Message:

0.8.7 - add support for log on repo, dont block ui thread on history

Files:
11 modified

Legend:

Unmodified
Added
Removed
  • com.goldenhammers.merclipse.feature/feature.xml

    r2 r3  
    33      id="com.goldenhammers.merclipse.feature" 
    44      label="Merclipse Feature" 
    5       version="0.8.6" 
     5      version="0.8.7" 
    66      provider-name="goldenhammers.com"> 
    77 
  • com.goldenhammers.merclipse.update.site/site.xml

    r2 r3  
    11<?xml version="1.0" encoding="UTF-8"?> 
    22<site> 
    3    <feature url="features/com.goldenhammers.merclipse.feature_0.8.6.jar" id="com.goldenhammers.merclipse.feature" version="0.8.6"> 
     3   <feature url="features/com.goldenhammers.merclipse.feature_0.8.7.jar" id="com.goldenhammers.merclipse.feature" version="0.8.7"> 
    44      <category name="com.goldenhammers.merclipse.category"/> 
    55   </feature> 
  • com.goldenhammers.merclipse/META-INF/MANIFEST.MF

    r2 r3  
    33Bundle-Name: Merclipse Plug-in 
    44Bundle-SymbolicName: com.goldenhammers.merclipse;singleton:=true 
    5 Bundle-Version: 0.8.6 
     5Bundle-Version: 0.8.7 
    66Bundle-Activator: com.goldenhammers.merclipse.MercurialPlugin 
    77Require-Bundle: org.eclipse.ui, 
  • com.goldenhammers.merclipse/plugin.xml

    r0 r3  
    4747            class="com.goldenhammers.merclipse.prefs.MercurialPreferencePage" 
    4848            id="com.goldenhammers.merclipse.preferencepage" 
    49             name="Mercurial"> 
     49            name="Merclipse"> 
    5050      </page> 
    5151   </extension> 
     
    179179               icon="icons/hg16.png" 
    180180               id="com.goldenhammers.merclipse.showLog" 
    181                label="Show Repository Log View" 
     181               label="Show Repository Log" 
    182182               menubarPath="team.main/group8" 
    183183               tooltip="Show view for displaying the entire repository&apos;s log"> 
  • com.goldenhammers.merclipse/src/com/goldenhammers/merclipse/history/MercurialFileHistory.java

    r0 r3  
    1313import java.io.BufferedReader; 
    1414import java.io.IOException; 
     15import java.io.InputStream; 
    1516import java.io.InputStreamReader; 
    1617import java.util.List; 
    1718 
    1819import org.eclipse.core.resources.IFile; 
     20import org.eclipse.swt.widgets.Display; 
    1921import org.eclipse.team.core.history.IFileRevision; 
    2022import org.eclipse.team.core.history.provider.FileHistory; 
     
    3133 
    3234        private IFile file; 
     35        private MercurialWorkingDir workingDir; 
    3336        private IFileRevision[] revisions; 
    3437         
    3538        public MercurialFileHistory(IFile file) { 
    3639                this.file = file; 
     40        } 
     41         
     42        public MercurialFileHistory(MercurialWorkingDir workingDir) { 
     43                this.workingDir = workingDir; 
    3744        } 
    3845         
     
    5057                         
    5158                        try { 
    52                                 revs = MercurialUtils.getRevisions(MercurialUtils.runSync(MercurialConstants.CMD_LOG,  
    53                                                 new MercurialPath(file), null, MercurialConstants.ARG_FOLLOW, MercurialConstants.ARG_VERBOSE)); 
     59                                InputStream results = null; 
     60                                if (workingDir == null) { 
     61                                        results = MercurialUtils.runSyncOnUIThread(Display.getCurrent(), MercurialConstants.CMD_LOG, new MercurialPath(file), null, MercurialConstants.ARG_FOLLOW, MercurialConstants.ARG_VERBOSE); 
     62                                } else { 
     63                                        results = MercurialUtils.runSyncOnUIThread(Display.getCurrent(), MercurialUtils.getCommand(MercurialConstants.CMD_LOG), workingDir, null); 
     64                                } 
     65                                 
     66                                revs = MercurialUtils.getRevisions(results); 
    5467                                 
    5568                        } catch (MercurialException e) { 
     
    6881                                revisions = new MercurialFileRevision[revs.size()]; 
    6982                                 
    70                                 MercurialWorkingDir workingDir = MercurialUtils.getWorkingDirectory(file); 
     83                                MercurialWorkingDir dir = null; 
     84                                String lastFilePath = null; 
    7185                                 
    72                                 String lastFilePath = MercurialPath.getMercurialPath(workingDir, file); 
     86                                if (workingDir == null) { 
     87                                        dir = MercurialUtils.getWorkingDirectory(file); 
     88                                        lastFilePath = MercurialPath.getMercurialPath(dir, file); 
     89                                } else { 
     90                                        dir = workingDir; 
     91                                } 
    7392                                 
    7493                                int i = 0; 
     
    7897                                for (MercurialRevision rev : revs) { 
    7998                                         
    80                                         if (!rev.getFiles().contains(lastFilePath)) { 
     99                                        if (workingDir == null && !rev.getFiles().contains(lastFilePath)) { 
    81100                                                // renamed in previous revision 
    82101                                                 
     
    96115                                                 
    97116                                                try { 
    98                                                         BufferedReader br = new BufferedReader(new InputStreamReader(MercurialUtils.runSync(cmd, workingDir, null))); 
     117                                                        BufferedReader br = new BufferedReader(new InputStreamReader(MercurialUtils.runSync(cmd, dir, null))); 
    99118                                                         
    100119                                                        // first line is diff  
     
    113132                                        previous = rev; 
    114133                                         
    115                                         revisions[i++] = new MercurialFileRevision(rev, lastFilePath, workingDir);       
     134                                        revisions[i++] = new MercurialFileRevision(rev, lastFilePath, dir);      
    116135                                } 
    117136                        } 
  • com.goldenhammers.merclipse/src/com/goldenhammers/merclipse/history/MercurialHistoryPage.java

    r0 r3  
    1414 
    1515import org.eclipse.core.resources.IFile; 
     16import org.eclipse.core.resources.IProject; 
    1617import org.eclipse.core.resources.IResource; 
     18import org.eclipse.core.runtime.IPath; 
    1719import org.eclipse.jface.action.Action; 
    1820import org.eclipse.jface.action.IAction; 
     
    8183                        @Override 
    8284                        public void run() { 
    83                                 IFile file = getCurrentFile(); 
     85                                IFile file = (IFile) getCurrentResource(); 
    8486                                 
    8587                                MercurialWorkingDir workingDir = MercurialUtils.getWorkingDirectory(file); 
     
    133135                                if (newInput != null) { 
    134136                                        // TODO what if the files are commited? we need a new pull here. 
    135                                         mfh = new MercurialFileHistory(getCurrentFile()); 
     137                                        IResource currentResource = getCurrentResource(); 
     138                                         
     139                                        if (currentResource.getType() == IResource.FILE) { 
     140                                                mfh = new MercurialFileHistory((IFile) currentResource); 
     141                                        } else { 
     142                                                mfh = new MercurialFileHistory(MercurialUtils.getWorkingDirectory(currentResource)); 
     143                                        }                                        
    136144                                } else { 
    137145                                        mfh = null; 
     
    162170         
    163171        private void fillTableMenu(IMenuManager menuMgr) { 
     172                if (getCurrentResource().getType() == IResource.PROJECT) { 
     173                        return; 
     174                } 
     175                 
    164176                ISelection sel = tableViewer.getSelection(); 
    165177                StructuredSelection structuredSel = (StructuredSelection) sel; 
     
    184196                return container; 
    185197        } 
    186          
    187         protected IFile getCurrentFile() { 
    188                 return (IFile) getInput(); 
     198                 
     199        protected IResource getCurrentResource() { 
     200                return (IResource) getInput(); 
    189201        } 
    190202 
     
    194206 
    195207        public String getDescription() { 
     208                IPath location = getCurrentResource().getLocation(); 
     209                 
     210                if (location != null) { 
     211                        return location.toString(); 
     212                } 
     213                 
    196214                return getName(); 
    197215        } 
    198216 
    199217        public String getName() { 
    200                 return getCurrentFile().getName(); 
     218                return getCurrentResource().getName(); 
    201219        } 
    202220 
     
    223241                 
    224242                if (isValidInput(input)) { 
    225                         currentRevision = new LocalFileRevision(getCurrentFile()); 
    226                         tableViewer.setInput(getCurrentFile()); 
     243                        if (getCurrentResource().getType() == IResource.FILE) { 
     244                                currentRevision = new LocalFileRevision((IFile) getCurrentResource()); 
     245                        } else { 
     246                                currentRevision = null; 
     247                        } 
     248                        tableViewer.setInput(getCurrentResource()); 
    227249                        return true; 
    228250                } 
     
    232254         
    233255        public boolean isValidInput(Object object) { 
    234                 return object instanceof IFile; 
     256                return object instanceof IFile || object instanceof IProject; 
    235257        } 
    236258 
  • com.goldenhammers.merclipse/src/com/goldenhammers/merclipse/history/MercurialHistoryPageSource.java

    r0 r3  
    1111package com.goldenhammers.merclipse.history; 
    1212 
    13 import org.eclipse.core.resources.IFile; 
    1413import org.eclipse.core.resources.IResource; 
    1514import org.eclipse.team.core.RepositoryProvider; 
     
    2423         
    2524        public boolean canShowHistoryFor(Object object) { 
    26                 if (object instanceof IResource && ((IResource) object).getType() == IResource.FILE) { 
    27                         RepositoryProvider provider = RepositoryProvider.getProvider(((IFile) object).getProject()); 
     25                if (object instanceof IResource) { 
     26                        IResource resource = (IResource) object; 
     27                         
     28                        if (resource.getType() != IResource.PROJECT && resource.getType() != IResource.FILE) { 
     29                                return false; 
     30                        } 
     31                         
     32                        RepositoryProvider provider = RepositoryProvider.getProvider(resource.getProject()); 
    2833                        if (provider instanceof MercurialRepositoryProvider) { 
    2934                                return true; 
  • com.goldenhammers.merclipse/src/com/goldenhammers/merclipse/team/actions/MercurialShowLogAction.java

    r0 r3  
    1212 
    1313import org.eclipse.jface.viewers.ISelection; 
     14import org.eclipse.team.internal.ui.TeamUIPlugin; 
     15import org.eclipse.team.ui.TeamUI; 
    1416 
    1517public class MercurialShowLogAction extends MercurialAction { 
     
    1820        @Override 
    1921        public void executeMercurialAction(ISelection selection) { 
     22                TeamUI.showHistoryFor(TeamUIPlugin.getActivePage(), getSelectedResources(selection).get(0).getProject(),  
     23                                null); 
    2024        } 
    2125 
    22         @Override 
    23         public void refreshEnablement() { 
    24                 setEnabled(false); 
    25         } 
    2626         
    2727         
  • com.goldenhammers.merclipse/src/com/goldenhammers/merclipse/utils/MercurialOperationMonitor.java

    r0 r3  
    1818 */ 
    1919public class MercurialOperationMonitor implements IMercurialOperationMonitor { 
    20                  
     20         
     21        private boolean finished; 
     22         
     23        public MercurialOperationMonitor() { 
     24                this.finished = false; 
     25        } 
     26         
    2127        public void handleLine(String line) throws MercurialException { 
    2228                if (line.startsWith(MercurialUtils.ERROR_INDICATOR)) { 
     
    3238        protected void handleCleanLine(String line) throws MercurialException {} 
    3339 
    34         public void operationFinished() {} 
     40        public void operationFinished() { 
     41                finished = true; 
     42        } 
     43         
     44        public boolean isFinished() { 
     45                return finished; 
     46        } 
    3547 
    3648} 
  • com.goldenhammers.merclipse/src/com/goldenhammers/merclipse/utils/MercurialUtils.java

    r1 r3  
    447447                                throws MercurialException, MercurialNotFoundException, IOException, InterruptedException { 
    448448                 
    449                 MercurialProcess mp = runAsync(command, workingDirectory,  
    450                                  new MercurialProgressOperationMonitor(monitor)); 
    451                  
    452                 while (mp.isRunning()) { 
     449                MercurialOperationMonitor opMonitor = new MercurialProgressOperationMonitor(monitor); 
     450                 
     451                MercurialProcess mp = runAsync(command, workingDirectory, opMonitor); 
     452                 
     453                while (!opMonitor.isFinished()) { 
    453454                        if (!display.readAndDispatch()) { 
    454455                                display.sleep(); 
     
    473474                List<String> cmdList = getCommand(cmd, workingDir, path, args); 
    474475                return runSync(cmdList, workingDir, monitor); 
     476        } 
     477         
     478        public static InputStream runSyncOnUIThread(Display display, String cmd, MercurialPath path, IProgressMonitor monitor, String... args)  
     479                throws MercurialException, MercurialNotFoundException, IOException, InterruptedException { 
     480                MercurialWorkingDir workingDir = getWorkingDirectory(path); 
     481                List<String> cmdList = getCommand(cmd, workingDir, path, args); 
     482                return runSyncOnUIThread(display, cmdList, workingDir, monitor); 
    475483        } 
    476484         
  • com.goldenhammers.merclipse/src/com/goldenhammers/merclipse/utils/OutputStreamMercurialOperationMonitor.java

    r0 r3  
    3131         */ 
    3232        public OutputStreamMercurialOperationMonitor(OutputStream os) { 
     33                super(); 
    3334                w = new BufferedWriter(new OutputStreamWriter(os)); 
    3435        } 
     
    6566                 
    6667                StreamUtils.close(w); 
     68                 
     69                super.operationFinished(); 
    6770        } 
    6871