OSDN Git Service

na-get-lib,r981で入ったバグの修正。
authorttp <ttp@users.sourceforge.jp>
Sun, 21 Sep 2008 10:06:37 +0000 (10:06 +0000)
committerttp <ttp@users.sourceforge.jp>
Sun, 21 Sep 2008 10:06:37 +0000 (10:06 +0000)
 * 依存関係で間違ったソフトに解決される。
 * 正規表現化するときにMatchは部分一致ということを忘れていた。

git-svn-id: http://localhost/svn/AppliStation/trunk@982 34ed2c89-c49f-4a4b-abdb-c318350108cf

na-get-lib/NaGet.Packages.Install/DependeciesResolver.cs
na-get-lib/NaGet.Packages/Package.cs
na-get-lib/NaGet.Packages/PackageList.cs
na-get-lib/NaGet.Packages/PackageListsManager.cs

index f9e7ad6..5d1b32c 100644 (file)
@@ -44,14 +44,29 @@ namespace NaGet.Packages.Install
                        List<Installation> reqInsts = new List<Installation>();\r
                        \r
                        foreach (Entry entry in DeleteDuplicatedEntries(CreateRequiresEntries(insts))) {\r
-                               if (!pkgListsMan.IsInstalledFor(entry)) {\r
+                               List<InstalledPackage> instPkgs = NaGet.Utils.MeargeList<InstalledPackage>(\r
+                                       pkgListsMan.installedPkgList.GetPackagesForEntry(entry),\r
+                                       pkgListsMan.systemInstalledPkgList.GetPackagesForEntry(entry)\r
+                               );\r
+                               \r
+                               if (instPkgs.Count <= 0) {\r
                                        if (Array.Exists(insts, delegate(Installation inst) {\r
-                                                       return inst.InstalledPackage.Name == entry.Name;\r
+                                                               return entry.Match(inst.InstalledPackage);\r
                                                         })) {\r
                                                continue;\r
                                        } else {\r
-                                               Package pkg = pkgListsMan.AvailablePkgList.GetPackageForEntry(entry);\r
-                                               reqInsts.Add(new Installation(pkg));\r
+                                               VersionComparetor vc = new VersionComparetor();\r
+                                               Package pkgToBeInstall = null;\r
+                                               \r
+                                               foreach (Package pkg in pkgListsMan.availablePkgList.GetPackagesForEntry(entry)) {\r
+                                                       if ((pkgToBeInstall == null) || (vc.Compare(pkgToBeInstall.Version, pkg.Version) > 0)) {\r
+                                                               pkgToBeInstall = pkg;\r
+                                                       }\r
+                                               }\r
+                                               \r
+                                               if (pkgToBeInstall != null) {\r
+                                                       reqInsts.Add(new Installation(pkgToBeInstall));\r
+                                               }\r
                                        }\r
                                }\r
                        }\r
index bc5ec42..3cfd8e6 100644 (file)
@@ -140,14 +140,6 @@ namespace NaGet.Packages
        /// </summary>\r
        public struct Entry\r
        {\r
-               public Entry(string name, string flags, string version)\r
-               {\r
-                       Name = name;\r
-                       Flags = flags;\r
-                       Version = version;\r
-               }\r
-               \r
-               \r
                /// <summary>\r
                /// パッケージ名\r
                /// </summary>\r
@@ -163,6 +155,32 @@ namespace NaGet.Packages
                /// </summary>\r
                [XmlAttribute]\r
                public string Version;\r
+               \r
+               public Entry(string name, string flags, string version)\r
+               {\r
+                       Name = name;\r
+                       Flags = flags;\r
+                       Version = version;\r
+               }\r
+               public bool Match(Package pkg)\r
+               {\r
+                       System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(\r
+                               (System.Text.RegularExpressions.Regex.IsMatch(Name, "^/.*/$"))?\r
+                               Name.Substring(1, Name.Length-2) :\r
+                               string.Format("^{0}$", System.Text.RegularExpressions.Regex.Escape(Name))\r
+                       , System.Text.RegularExpressions.RegexOptions.Singleline);\r
+                       \r
+                       if (regex.IsMatch(pkg.Name)) {\r
+                               if (string.IsNullOrEmpty(Version)) {\r
+                                       return true;\r
+                               } else {\r
+                                       // TODO Flagの内容は現在のところ無視\r
+                                       return pkg.Version == Version;\r
+                               }\r
+                       } else {\r
+                               return false;\r
+                       }\r
+               }\r
        }\r
 \r
        public class Installer\r
index 5aa1aa4..4de4b18 100644 (file)
@@ -95,6 +95,10 @@ namespace NaGet.Packages
                        packageArrayList.Remove(package);\r
                }\r
                \r
+               #region パッケージ検索\r
+               \r
+               #region 検索用Predicate\r
+               \r
                /// <summary>\r
                /// パッケージを検索をする際のPredicateを返す \r
                /// </summary>\r
@@ -110,6 +114,38 @@ namespace NaGet.Packages
                }\r
                \r
                /// <summary>\r
+               /// パッケージ名で検索をする際のPredicateを返す \r
+               /// </summary>\r
+               /// <param name="name">\r
+               /// パッケージ名\r
+               /// </param>\r
+               /// <returns>\r
+               /// Predicate\r
+               /// </returns>\r
+               protected internal static Predicate<TPackage> GetPredicateForPackageName(string name)\r
+               {\r
+                       return delegate(TPackage package) {\r
+                               return package.Name == name;\r
+                       };\r
+               }\r
+               \r
+               /// <summary>\r
+               /// エントリで検索をする際のPredicateを返す \r
+               /// </summary>\r
+               /// <param name="entry">\r
+               /// エントリ\r
+               /// </param>\r
+               /// <returns>\r
+               /// Predicate\r
+               /// </returns>\r
+               protected internal static Predicate<TPackage> GetPredicateForEntry(Entry entry)\r
+               {\r
+                       return entry.Match;\r
+               }\r
+               \r
+               #endregion\r
+                               \r
+               /// <summary>\r
                /// パッケージを検索して、それにマッチしたパッケージをイテレータとして返す。\r
                /// </summary>\r
                /// <param name="predicate">検索条件のPredicate</param>\r
@@ -130,22 +166,6 @@ namespace NaGet.Packages
                }\r
                \r
                /// <summary>\r
-               /// パッケージ名で検索をする際のPredicateを返す \r
-               /// </summary>\r
-               /// <param name="name">\r
-               /// パッケージ名\r
-               /// </param>\r
-               /// <returns>\r
-               /// Predicate\r
-               /// </returns>\r
-               protected internal static Predicate<TPackage> GetPredicateForPackageName(string name)\r
-               {\r
-                       return delegate(TPackage package) {\r
-                               return package.Name == name;\r
-                       };\r
-               }\r
-               \r
-               /// <summary>\r
                /// 指定した名前に対応するパッケージを返す\r
                /// </summary>\r
                /// <param name="name">検索にかけるパッケージ名</param>\r
@@ -176,30 +196,21 @@ namespace NaGet.Packages
                /// <summary>\r
                /// パッケージ参照エントリが対応するパッケージを返す\r
                /// </summary>\r
-               /// <remarks>現在の実装では、名前でしか存在確認をしていない。</remarks>\r
                /// <param name="name">検索にかけるパッケージ参照エントリ</param>\r
                public TPackage GetPackageForEntry(Entry entry)\r
                {\r
-                       System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(\r
-                               (System.Text.RegularExpressions.Regex.IsMatch(entry.Name, "^/.*/$"))?\r
-                               entry.Name.Substring(1, entry.Name.Length-2) :\r
-                               System.Text.RegularExpressions.Regex.Escape(entry.Name)\r
-                       );\r
-                       \r
-                       return packageArrayList.Find(\r
-                               (Predicate<TPackage>) delegate(TPackage pkg){\r
-                                       if (regex.IsMatch(pkg.Name)) {\r
-                                               if (string.IsNullOrEmpty(entry.Version)) {\r
-                                                       return true;\r
-                                               } else {\r
-                                                       // TODO Flagの内容は現在のところ無視\r
-                                                       return pkg.Version == entry.Version;\r
-                                               }\r
-                                       } else {\r
-                                               return false;\r
-                                       }\r
-                               }\r
-                       );\r
+                       return packageArrayList.Find(GetPredicateForEntry(entry));\r
                }\r
+               \r
+               /// <summary>\r
+               /// パッケージ参照エントリが対応するパッケージをすべて返す\r
+               /// </summary>\r
+               /// <param name="name">検索にかけるパッケージ参照エントリ</param>\r
+               public IEnumerable<TPackage> GetPackagesForEntry(Entry entry)\r
+               {\r
+                       return packageArrayList.FindAll(GetPredicateForEntry(entry));\r
+               }\r
+               \r
+               #endregion\r
        }\r
 }\r
index af10c01..d5b1d43 100644 (file)
@@ -217,18 +217,6 @@ namespace NaGet.Packages
                        );\r
                }\r
                \r
-               /// <summary>\r
-               /// 与えられたパッケージ参照エントリに対応するパッケージはインストール済みか否かを返す\r
-               /// </summary>\r
-               /// <seealso cref="PackageList.GetPackageForEntry(Entry)" />\r
-               /// <param name="entry">パッケージ参照エントリ</param>\r
-               /// <returns>対応するパッケージがインストール済みならば<code>true</code></returns>\r
-               public bool IsInstalledFor(Entry entry)\r
-               {\r
-                       return (installedPkgList.GetPackageForEntry(entry) != null) ||\r
-                               (systemInstalledPkgList.GetPackageForEntry(entry) != null);\r
-               }\r
-               \r
                #endregion\r
                \r
                #region インストールログ関連\r