Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(471)

Unified Diff: pylib/gyp/MSVSNew.py

Issue 10943017: Ensure that all entries in .sln files are sorted. (Closed) Base URL: https://gyp.googlecode.com/svn/trunk
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pylib/gyp/MSVSNew.py
diff --git a/pylib/gyp/MSVSNew.py b/pylib/gyp/MSVSNew.py
index 0865973783172f7dd815cfa26318d1fe42c5e9a5..253fe61986329a90eda4954b07a28cdbd764d5b7 100644
--- a/pylib/gyp/MSVSNew.py
+++ b/pylib/gyp/MSVSNew.py
@@ -59,7 +59,13 @@ def MakeGuid(name, seed='msvs_new'):
#------------------------------------------------------------------------------
-class MSVSFolder(object):
+class MSVSSolutionEntry(object):
+ def __cmp__(self, other):
+ # Sort by name then guid (so things are in order on vs2008).
+ return cmp((self.name, self.get_guid()), (other.name, other.get_guid()))
+
+
+class MSVSFolder(MSVSSolutionEntry):
"""Folder in a Visual Studio project or solution."""
def __init__(self, path, name = None, entries = None,
@@ -85,7 +91,7 @@ class MSVSFolder(object):
self.guid = guid
# Copy passed lists (or set to empty lists)
- self.entries = list(entries or [])
+ self.entries = sorted(list(entries or []))
self.items = list(items or [])
self.entry_type_guid = ENTRY_TYPE_GUIDS['folder']
@@ -100,7 +106,7 @@ class MSVSFolder(object):
#------------------------------------------------------------------------------
-class MSVSProject(object):
+class MSVSProject(MSVSSolutionEntry):
"""Visual Studio project."""
def __init__(self, path, name = None, dependencies = None, guid = None,
@@ -229,15 +235,7 @@ class MSVSSolution:
if isinstance(e, MSVSFolder):
entries_to_check += e.entries
- # Sort by name then guid (so things are in order on vs2008).
- def NameThenGuid(a, b):
- if a.name < b.name: return -1
- if a.name > b.name: return 1
- if a.get_guid() < b.get_guid(): return -1
- if a.get_guid() > b.get_guid(): return 1
- return 0
-
- all_entries = sorted(all_entries, NameThenGuid)
+ all_entries = sorted(all_entries)
# Open file and print header
f = writer(self.path)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698