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

Unified Diff: appengine/chromium_rietveld/new_static/model/patch_file.js

Issue 992403002: Simplify and fix sorting of PatchFiles. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Created 5 years, 9 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 | appengine/chromium_rietveld/new_static/model/tests/patch_set_tests.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/chromium_rietveld/new_static/model/patch_file.js
diff --git a/appengine/chromium_rietveld/new_static/model/patch_file.js b/appengine/chromium_rietveld/new_static/model/patch_file.js
index 60c83f06b5c525c3cc6d174017e89ae302fd00ec..d65f331220958b5828105714ecaf7dcaafd7205f 100644
--- a/appengine/chromium_rietveld/new_static/model/patch_file.js
+++ b/appengine/chromium_rietveld/new_static/model/patch_file.js
@@ -7,8 +7,8 @@
function PatchFile(patchset, name)
{
this.name = name || "";
+ this.prefix = name || "";
this.extension = "";
- this.prefix = "";
this.language = "";
this.containsEmbeddedLanguages = false;
this.status = "";
@@ -26,11 +26,13 @@ function PatchFile(patchset, name)
this.draftCount = 0;
this.diff = null;
this.isLayoutTest = this.name.startsWith("LayoutTests/");
+ this.isHeader = false;
Object.preventExtensions(this);
var dotIndex = this.name.lastIndexOf(".");
if (dotIndex != -1) {
this.extension = this.name.from(dotIndex + 1);
+ this.isHeader = PatchFile.HEADER_EXTENSIONS[this.extension] || false;
this.prefix = this.name.to(dotIndex);
this.language = PatchFile.SYNTAX_LANGUAGES[this.extension] || "";
this.containsEmbeddedLanguages = PatchFile.MIXED_LANGUAGES[this.language];
@@ -78,20 +80,20 @@ PatchFile.SYNTAX_LANGUAGES = {
"xml": "xml",
};
+PatchFile.HEADER_EXTENSIONS = {
+ "h": true,
+ "hxx": true,
+ "hpp": true,
+};
+
PatchFile.compare = function(a, b)
{
- if (a.isLayoutTest && b.isLayoutTest)
- return a.name.localeCompare(b.name);
- if (a.isLayoutTest)
- return 1;
- if (b.isLayoutTest)
- return -1;
+ if (a.isLayoutTest != b.isLayoutTest)
+ return b.isLayoutTest ? -1 : 1;
if (a.prefix != b.prefix)
- return a.name.localeCompare(b.name);
- if (a.extension == "h" && (b.extension == "cpp" || b.extension == "cc"))
- return -1;
- if (b.extension == "h" && (a.extension == "cpp" || a.extension == "cc"))
- return 1;
+ return a.prefix.localeCompare(b.prefix);
+ if (a.isHeader != b.isHeader)
+ return a.isHeader ? -1 : 1;
return a.extension.localeCompare(b.extension);
};
« no previous file with comments | « no previous file | appengine/chromium_rietveld/new_static/model/tests/patch_set_tests.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698