diff options
author | Matthias Sohn | 2011-12-26 23:03:27 +0000 |
---|---|---|
committer | Matthias Sohn | 2011-12-26 23:03:27 +0000 |
commit | 7123c4157b925643afc8803d3af2b728a98cca60 (patch) | |
tree | d8769fa9bf1ab6fc9a2b5e8e372500fb8592044e /org.eclipse.egit.core | |
parent | 2d11c384857dbd2ffbd82078eedc189bd75f9ca4 (diff) | |
parent | b1bbfd4ce7d321df35cd2320309129a8692fcc90 (diff) | |
download | egit-7123c4157b925643afc8803d3af2b728a98cca60.tar.gz egit-7123c4157b925643afc8803d3af2b728a98cca60.tar.xz egit-7123c4157b925643afc8803d3af2b728a98cca60.zip |
Merge branch 'stable-1.2'
* stable-1.2:
EGit v1.2.0.201112221803-r
Update documentation for 1.2
CompareIndexWithHeadAction: avoid unnecessary IndexDiff calculation
Unlock DirCache in case of exception
cleanup: Remove javadoc validation due to incomplete javadocs
Change-Id: I9a1293979dfdd3b4d29580de3078bf2cc4c0582b
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.egit.core')
4 files changed, 43 insertions, 24 deletions
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/AdapterUtils.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/AdapterUtils.java index 7fd71502ea..e154b292de 100644 --- a/org.eclipse.egit.core/src/org/eclipse/egit/core/AdapterUtils.java +++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/AdapterUtils.java @@ -26,6 +26,7 @@ public class AdapterUtils { * * @param object * @param target + * @param <V> type of target * @return adapted */ @SuppressWarnings("unchecked") diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/GitMoveDeleteHook.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/GitMoveDeleteHook.java index b02b641f15..bad3c01bcb 100644 --- a/org.eclipse.egit.core/src/org/eclipse/egit/core/GitMoveDeleteHook.java +++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/GitMoveDeleteHook.java @@ -65,8 +65,9 @@ class GitMoveDeleteHook implements IMoveDeleteHook { if (map == null) return false; + DirCache dirc = null; try { - final DirCache dirc = map.getRepository().lockDirCache(); + dirc = map.getRepository().lockDirCache(); final int first = dirc.findEntry(map.getRepoRelativePath(file)); if (first < 0) { dirc.unlock(); @@ -86,6 +87,9 @@ class GitMoveDeleteHook implements IMoveDeleteHook { } catch (IOException e) { tree.failed(new Status(IStatus.ERROR, Activator.getPluginId(), 0, CoreText.MoveDeleteHook_operationError, e)); + } finally { + if (dirc != null) + dirc.unlock(); } return true; } @@ -122,8 +126,9 @@ class GitMoveDeleteHook implements IMoveDeleteHook { return false; final RepositoryMapping dstm = RepositoryMapping.getMapping(dstf); + DirCache sCache = null; try { - final DirCache sCache = srcm.getRepository().lockDirCache(); + sCache = srcm.getRepository().lockDirCache(); final String sPath = srcm.getRepoRelativePath(srcf); final DirCacheEntry sEnt = sCache.getEntry(sPath); if (sEnt == null) { @@ -150,6 +155,9 @@ class GitMoveDeleteHook implements IMoveDeleteHook { } catch (IOException e) { tree.failed(new Status(IStatus.ERROR, Activator.getPluginId(), 0, CoreText.MoveDeleteHook_operationError, e)); + } finally { + if (sCache != null) + sCache.unlock(); } return true; } @@ -355,31 +363,36 @@ class GitMoveDeleteHook implements IMoveDeleteHook { private MoveResult moveIndexContent(String dPath, final RepositoryMapping srcm, final String sPath) throws IOException { + final DirCache sCache = srcm.getRepository().lockDirCache(); - final DirCacheEntry[] sEnt = sCache.getEntriesWithin(sPath); - if (sEnt.length == 0) { - sCache.unlock(); - return MoveResult.UNTRACKED; - } + try { + final DirCacheEntry[] sEnt = sCache.getEntriesWithin(sPath); + if (sEnt.length == 0) { + sCache.unlock(); + return MoveResult.UNTRACKED; + } - final DirCacheEditor sEdit = sCache.editor(); - sEdit.add(new DirCacheEditor.DeleteTree(sPath)); - final int sPathLen = sPath.length() == 0 ? sPath.length() : sPath - .length() + 1; - for (final DirCacheEntry se : sEnt) { - final String p = se.getPathString().substring(sPathLen); - sEdit.add(new DirCacheEditor.PathEdit(dPath + p) { - @Override - public void apply(final DirCacheEntry dEnt) { - dEnt.copyMetaData(se); - } - }); + final DirCacheEditor sEdit = sCache.editor(); + sEdit.add(new DirCacheEditor.DeleteTree(sPath)); + final int sPathLen = sPath.length() == 0 ? sPath.length() : sPath + .length() + 1; + for (final DirCacheEntry se : sEnt) { + final String p = se.getPathString().substring(sPathLen); + sEdit.add(new DirCacheEditor.PathEdit(dPath + p) { + @Override + public void apply(final DirCacheEntry dEnt) { + dEnt.copyMetaData(se); + } + }); + } + if (sEdit.commit()) + return MoveResult.SUCCESS; + else + return MoveResult.FAILED; + } finally { + if (sCache != null) + sCache.unlock(); } - if (sEdit.commit()) - return MoveResult.SUCCESS; - else - return MoveResult.FAILED; - } private boolean cannotModifyRepository(final IResourceTree tree) { diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/AssumeUnchangedOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/AssumeUnchangedOperation.java index 251e2ce1c9..2e7080a7b7 100644 --- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/AssumeUnchangedOperation.java +++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/AssumeUnchangedOperation.java @@ -101,6 +101,8 @@ public class AssumeUnchangedOperation implements IEGitOperation { } finally { for (final RepositoryMapping rm : mappings.keySet()) rm.fireRepositoryChanged(); + for (DirCache cache:caches.values()) + cache.unlock(); caches.clear(); mappings.clear(); monitor.done(); diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/UntrackOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/UntrackOperation.java index e140fcece5..4da1e9db4f 100644 --- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/UntrackOperation.java +++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/UntrackOperation.java @@ -96,6 +96,9 @@ public class UntrackOperation implements IEGitOperation { } finally { for (final RepositoryMapping rm : mappings.keySet()) rm.fireRepositoryChanged(); + for (DirCacheEditor editor:edits.values()) + if (editor.getDirCache() != null) + editor.getDirCache().unlock(); edits.clear(); mappings.clear(); monitor.done(); |