Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Krüger <mkrueger@xamarin.com>2012-01-19 11:52:46 +0400
committerMike Krüger <mkrueger@xamarin.com>2012-01-19 11:52:46 +0400
commit63a7837c796d7e29f4401ea2369302e6e9462aeb (patch)
tree8dd0590255e56d27969323a1840a9203dafec499 /main/src/addins/VersionControl
parent6a4b50b5e965b983bb9bec1c26de891ded16ad2e (diff)
parent29f45fe8d8697d3347e5e826b42088bc0a10e2ca (diff)
Merge branch 'master' into newresolver
Diffstat (limited to 'main/src/addins/VersionControl')
-rw-r--r--main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs38
-rw-r--r--main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion/SubversionRepository.cs8
-rw-r--r--main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/StatusView.cs23
-rw-r--r--main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/SubviewAttachmentHandler.cs21
-rw-r--r--main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/Repository.cs5
5 files changed, 68 insertions, 27 deletions
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs
index f9bb1b5ca4..2b21cd1348 100644
--- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs
+++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs
@@ -802,26 +802,34 @@ namespace MonoDevelop.VersionControl.Git
return GetCommitTextContent (c, repositoryPath);
}
+ public override DiffInfo GenerateDiff (FilePath baseLocalPath, VersionInfo vi)
+ {
+ try {
+ if ((vi.Status & VersionStatus.ScheduledAdd) != 0) {
+ var ctxt = GetFileContent (vi.LocalPath);
+ return new DiffInfo (baseLocalPath, vi.LocalPath, GenerateDiff (EmptyContent, ctxt));
+ } else if ((vi.Status & VersionStatus.ScheduledDelete) != 0) {
+ var ctxt = GetCommitContent (GetHeadCommit (), vi.LocalPath);
+ return new DiffInfo (baseLocalPath, vi.LocalPath, GenerateDiff (ctxt, EmptyContent));
+ } else if ((vi.Status & VersionStatus.Modified) != 0 || (vi.Status & VersionStatus.Conflicted) != 0) {
+ var ctxt1 = GetCommitContent (GetHeadCommit (), vi.LocalPath);
+ var ctxt2 = GetFileContent (vi.LocalPath);
+ return new DiffInfo (baseLocalPath, vi.LocalPath, GenerateDiff (ctxt1, ctxt2));
+ }
+ } catch (Exception ex) {
+ LoggingService.LogError ("Could not get diff for file '" + vi.LocalPath + "'", ex);
+ }
+ return null;
+ }
+
public override DiffInfo[] PathDiff (FilePath baseLocalPath, FilePath[] localPaths, bool remoteDiff)
{
List<DiffInfo> diffs = new List<DiffInfo> ();
VersionInfo[] vinfos = GetDirectoryVersionInfo (baseLocalPath, localPaths, false, true);
foreach (VersionInfo vi in vinfos) {
- try {
- if ((vi.Status & VersionStatus.ScheduledAdd) != 0) {
- var ctxt = GetFileContent (vi.LocalPath);
- diffs.Add (new DiffInfo (baseLocalPath, vi.LocalPath, GenerateDiff (EmptyContent, ctxt)));
- } else if ((vi.Status & VersionStatus.ScheduledDelete) != 0) {
- var ctxt = GetCommitContent (GetHeadCommit (), vi.LocalPath);
- diffs.Add (new DiffInfo (baseLocalPath, vi.LocalPath, GenerateDiff (ctxt, EmptyContent)));
- } else if ((vi.Status & VersionStatus.Modified) != 0 || (vi.Status & VersionStatus.Conflicted) != 0) {
- var ctxt1 = GetCommitContent (GetHeadCommit (), vi.LocalPath);
- var ctxt2 = GetFileContent (vi.LocalPath);
- diffs.Add (new DiffInfo (baseLocalPath, vi.LocalPath, GenerateDiff (ctxt1, ctxt2)));
- }
- } catch (Exception ex) {
- LoggingService.LogError ("Could not get diff for file '" + vi.LocalPath + "'", ex);
- }
+ var diff = GenerateDiff (baseLocalPath, vi);
+ if (diff != null)
+ diffs.Add (diff);
}
return diffs.ToArray ();
}
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion/SubversionRepository.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion/SubversionRepository.cs
index d0993809ad..b2582b578d 100644
--- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion/SubversionRepository.cs
+++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion/SubversionRepository.cs
@@ -479,6 +479,14 @@ namespace MonoDevelop.VersionControl.Subversion
}
}
+ public override DiffInfo GenerateDiff (FilePath baseLocalPath, VersionInfo versionInfo)
+ {
+ string diff = Svn.GetUnifiedDiff (versionInfo.LocalPath, false, false);
+ if (!string.IsNullOrEmpty (diff))
+ return GenerateUnifiedDiffInfo (diff, baseLocalPath, new FilePath[] { versionInfo.LocalPath }) [0];
+ return null;
+ }
+
public override DiffInfo[] PathDiff (FilePath localPath, Revision fromRevision, Revision toRevision)
{
string diff = Svn.GetUnifiedDiff (localPath, (SvnRevision)fromRevision, localPath, (SvnRevision)toRevision, true);
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/StatusView.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/StatusView.cs
index 2061e4979b..75eab0ff56 100644
--- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/StatusView.cs
+++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/StatusView.cs
@@ -375,7 +375,7 @@ namespace MonoDevelop.VersionControl.Views
void LoadStatus (List<VersionInfo> newList)
{
- statuses = newList;
+ statuses = newList.Where (f => FileVisible (f)).ToList ();
// Remove from the changeset files/folders which have been deleted
var toRemove = new List<ChangeSetItem> ();
@@ -933,7 +933,26 @@ namespace MonoDevelop.VersionControl.Views
delegate {
ddata.diffException = null;
try {
- ddata.difs = vc.PathDiff (filepath, null, remote);
+ List<DiffInfo> diffs = new List<DiffInfo> ();
+ // Calling GenerateDiff and supplying the versioninfo
+ // is the new fast way of doing things. If we do not get
+ // the same number of diffs as VersionInfos, we should
+ // fall back to the old slow method as the VC addin probably
+ // has not implemented the new fast one.
+ // The new way can also only be used locally.
+ if (!remote) {
+ foreach (var vi in statuses) {
+ var diff = vc.GenerateDiff (filepath, vi);
+ if (diff == null)
+ break;
+ diffs.Add (diff);
+ }
+ }
+
+ if (diffs.Count == statuses.Count)
+ ddata.difs = diffs.ToArray ();
+ else
+ ddata.difs = vc.PathDiff (filepath, null, remote);
} catch (Exception ex) {
ddata.diffException = ex;
} finally {
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/SubviewAttachmentHandler.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/SubviewAttachmentHandler.cs
index 42f9856bf2..1b9d9de827 100644
--- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/SubviewAttachmentHandler.cs
+++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/SubviewAttachmentHandler.cs
@@ -36,23 +36,24 @@ namespace MonoDevelop.VersionControl.Views
{
protected override void Run ()
{
- Ide.IdeApp.Workbench.DocumentOpened += HandleDocumentOpened;
+ Ide.IdeApp.Workbench.ActiveDocumentChanged += HandleDocumentChanged;
}
- void HandleDocumentOpened (object sender, Ide.Gui.DocumentEventArgs e)
+ void HandleDocumentChanged (object sender, EventArgs e)
{
- if (!e.Document.IsFile || e.Document.Project == null)
+ var document = Ide.IdeApp.Workbench.ActiveDocument;
+ if (document == null || !document.IsFile || document.Project == null || document.Window.FindView<IDiffView> () >= 0)
return;
- var repo = VersionControlService.GetRepository (e.Document.Project);
- if (repo == null || !repo.GetVersionInfo (e.Document.FileName).IsVersioned)
+ var repo = VersionControlService.GetRepository (document.Project);
+ if (repo == null || !repo.GetVersionInfo (document.FileName).IsVersioned)
return;
- var item = new VersionControlItem (repo, e.Document.Project, e.Document.FileName, false, null);
- TryAttachView <IDiffView> (e.Document, item, DiffCommand.DiffViewHandlers);
- TryAttachView <IBlameView> (e.Document, item, BlameCommand.BlameViewHandlers);
- TryAttachView <ILogView> (e.Document, item, LogCommand.LogViewHandlers);
- TryAttachView <IMergeView> (e.Document, item, MergeCommand.MergeViewHandlers);
+ var item = new VersionControlItem (repo, document.Project, document.FileName, false, null);
+ TryAttachView <IDiffView> (document, item, DiffCommand.DiffViewHandlers);
+ TryAttachView <IBlameView> (document, item, BlameCommand.BlameViewHandlers);
+ TryAttachView <ILogView> (document, item, LogCommand.LogViewHandlers);
+ TryAttachView <IMergeView> (document, item, MergeCommand.MergeViewHandlers);
}
void TryAttachView <T>(Document document, VersionControlItem item, string type)
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/Repository.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/Repository.cs
index 6b5353bac6..05b20fb666 100644
--- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/Repository.cs
+++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/Repository.cs
@@ -377,6 +377,11 @@ namespace MonoDevelop.VersionControl
throw new System.NotSupportedException ();
}
+ public virtual DiffInfo GenerateDiff (FilePath baseLocalPath, VersionInfo versionInfo)
+ {
+ return null;
+ }
+
// Returns a dif description between local files and the remote files.
// baseLocalPath is the root path of the diff. localPaths is optional and
// it can be a list of files to compare.