Author: peterw
Date: 2006-07-06 04:02:00 -0400 (Thu, 06 Jul 2006)
New Revision: 62298

Modified:
   branches/peterw/mbuild-compiled/Monkeywrench/ChangeLog
   branches/peterw/mbuild-compiled/Monkeywrench/Monkeywrench/ActionLog.cs
   branches/peterw/mbuild-compiled/Monkeywrench/Monkeywrench/FileStateTable.cs
   
branches/peterw/mbuild-compiled/Monkeywrench/Monkeywrench/IProviderPersistence.cs
   branches/peterw/mbuild-compiled/Monkeywrench/Monkeywrench/WrenchProject.cs
Log:
2006-07-06  Peter Williams  <[EMAIL PROTECTED]>

        * Monkeywrench/FileStateTable.cs: Clean this up -- we were serializing
        a bunch of members that we shouldn't have. Really we shouldn't store
        those members because if we ever change directories, the stored values
        would be useless.

        * Monkeywrench/ActionLog.cs (Load): Right, use PathToStateItem instead
        of our homebrew.
        (Save): Same.

        * Monkeywrench/WrenchProject.cs: Also put code to save the provider
        persistence here; refactor a tiny bit. 

        * Monkeywrench/IProviderPersistence.cs: Don't make disposable.
        If we ever change directories, we *need* an up-to-date SourceSettings
        to write to the correct file.
        (Save): New member to do the above.



Modified: branches/peterw/mbuild-compiled/Monkeywrench/ChangeLog
===================================================================
--- branches/peterw/mbuild-compiled/Monkeywrench/ChangeLog      2006-07-06 
07:43:31 UTC (rev 62297)
+++ branches/peterw/mbuild-compiled/Monkeywrench/ChangeLog      2006-07-06 
08:02:00 UTC (rev 62298)
@@ -1,5 +1,24 @@
 2006-07-06  Peter Williams  <[EMAIL PROTECTED]>
 
+       * Monkeywrench/FileStateTable.cs: Clean this up -- we were serializing
+       a bunch of members that we shouldn't have. Really we shouldn't store
+       those members because if we ever change directories, the stored values
+       would be useless.
+
+       * Monkeywrench/ActionLog.cs (Load): Right, use PathToStateItem instead
+       of our homebrew.
+       (Save): Same.
+
+       * Monkeywrench/WrenchProject.cs: Also put code to save the provider
+       persistence here; refactor a tiny bit. 
+
+       * Monkeywrench/IProviderPersistence.cs: Don't make disposable.
+       If we ever change directories, we *need* an up-to-date SourceSettings
+       to write to the correct file.
+       (Save): New member to do the above.
+       
+2006-07-06  Peter Williams  <[EMAIL PROTECTED]>
+
        * Monkeywrench/ActionLog.cs: Renamed from LoggingData.
 
        * Monkeywrench/ProjectManager.cs: Track rename.

Modified: branches/peterw/mbuild-compiled/Monkeywrench/Monkeywrench/ActionLog.cs
===================================================================
--- branches/peterw/mbuild-compiled/Monkeywrench/Monkeywrench/ActionLog.cs      
2006-07-06 07:43:31 UTC (rev 62297)
+++ branches/peterw/mbuild-compiled/Monkeywrench/Monkeywrench/ActionLog.cs      
2006-07-06 08:02:00 UTC (rev 62298)
@@ -197,12 +197,6 @@
 
        public const string LogName = "eventlog.dat";
 
-       static string GetPath (SourceSettings ss)
-       {
-           string srcrel = Path.Combine (WrenchProject.ProviderInfo.StateDir, 
LogName);
-           return ss.PathToBuildRelative (srcrel);
-       }
-
        public static ActionLog Load (SourceSettings ss, IWarningLogger uilog)
        {
            ActionLog ld = null;
@@ -210,7 +204,7 @@
            if (uilog == null)
                throw new ArgumentNullException ();
 
-           string path = GetPath (ss);
+           string path = ss.PathToStateItem (LogName);
 
            if (File.Exists (path))
                ld = (ActionLog) SafeFileSerializer.Load (path, uilog);
@@ -225,7 +219,7 @@
 
        public bool Save (SourceSettings ss)
        {
-           return SafeFileSerializer.Save (GetPath (ss), this, uilog);
+           return SafeFileSerializer.Save (ss.PathToStateItem (LogName), this, 
uilog);
        }
     }
 }

Modified: 
branches/peterw/mbuild-compiled/Monkeywrench/Monkeywrench/FileStateTable.cs
===================================================================
--- branches/peterw/mbuild-compiled/Monkeywrench/Monkeywrench/FileStateTable.cs 
2006-07-06 07:43:31 UTC (rev 62297)
+++ branches/peterw/mbuild-compiled/Monkeywrench/Monkeywrench/FileStateTable.cs 
2006-07-06 08:02:00 UTC (rev 62298)
@@ -10,11 +10,7 @@
 namespace Monkeywrench {
 
        [Serializable]
-       public class FileStateTable : StateTable, IProviderPersistence, 
IDisposable {
-               string path;
-               bool disposed;
-               IWarningLogger log;
-
+           public class FileStateTable : StateTable, IProviderPersistence {
                FileStateTable () : base () {}
 
                public static FileStateTable Load (string path, IWarningLogger 
log) {
@@ -24,24 +20,11 @@
                        if (fst == null)
                                fst = new FileStateTable ();
 
-                       fst.path = path;
-                       fst.log = log;
                        return fst;
                }
 
-               public void Close () {
-                       Dispose ();
+               public bool Save (string path, IWarningLogger log) {
+                       return SafeFileSerializer.Save (path, this, log);
                }
-
-               public void Dispose () { 
-                       if (disposed)
-                               return;
-
-                       // Ignore error. Can't do much about it.
-                       SafeFileSerializer.Save (path, this, log);
-                       disposed = true;
-
-                       GC.SuppressFinalize (this);
-               }
        }
 }

Modified: 
branches/peterw/mbuild-compiled/Monkeywrench/Monkeywrench/IProviderPersistence.cs
===================================================================
--- 
branches/peterw/mbuild-compiled/Monkeywrench/Monkeywrench/IProviderPersistence.cs
   2006-07-06 07:43:31 UTC (rev 62297)
+++ 
branches/peterw/mbuild-compiled/Monkeywrench/Monkeywrench/IProviderPersistence.cs
   2006-07-06 08:02:00 UTC (rev 62298)
@@ -8,9 +8,11 @@
 
 namespace Monkeywrench {
 
-       public interface IProviderPersistence : IDisposable {
+       public interface IProviderPersistence {
                BuiltItem GetItem (string name);
                void SetItem (string name, BuiltItem value);
+
+               bool Save (string file, IWarningLogger log);
        }
 
 }

Modified: 
branches/peterw/mbuild-compiled/Monkeywrench/Monkeywrench/WrenchProject.cs
===================================================================
--- branches/peterw/mbuild-compiled/Monkeywrench/Monkeywrench/WrenchProject.cs  
2006-07-06 07:43:31 UTC (rev 62297)
+++ branches/peterw/mbuild-compiled/Monkeywrench/Monkeywrench/WrenchProject.cs  
2006-07-06 08:02:00 UTC (rev 62298)
@@ -143,22 +143,33 @@
            public short id;
            public IProviderPersistence pp;
            public InfoContext context;
-           
-           public const string StateDir = ".monkeywrench_state";
-           public const string StateSuffix = "state.dat";
 
+           // TODO: Use varying persistence storages; right now
+           // we only ever use FileStateTable.
+
            public ProviderInfo (short id, WrenchProject proj) 
            {
                this.id = id;
 
-               string basis = proj.Graph.GetProviderBasis (id);
-               string s = proj.ss.PathToStateItem 
(SourceSettings.BasisToFileToken (basis) + 
-                                                   StateSuffix);
-               pp = FileStateTable.Load (s, proj.Log);
+               pp = FileStateTable.Load (GetStatePath (proj), proj.Log);
 
                context = new InfoContext (proj.Graph.GetProviderDeclarationLoc 
(id), proj);
            }
            
+           public bool Close (WrenchProject proj)
+           {
+               return pp.Save (GetStatePath (proj), proj.Log);
+           }
+
+           public const string StateSuffix = "state.dat";
+
+           string GetStatePath (WrenchProject proj)
+           {
+               string basis = proj.Graph.GetProviderBasis (id);
+               return proj.ss.PathToStateItem (SourceSettings.BasisToFileToken 
(basis) + 
+                                               StateSuffix);
+           }
+
            public bool InitializeBuilddir (WrenchProject proj)
            {
                string declloc = proj.Graph.GetProviderDeclarationLoc (id);
@@ -377,10 +388,8 @@
            if (disposed)
                return;
 
-           foreach (ProviderInfo pi in providers.Values) {
-               if (pi.pp != null)
-                   pi.pp.Dispose ();
-           }
+           foreach (ProviderInfo pi in providers.Values)
+               pi.Close (this);
 
            providers = null;
            disposed = true;

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to