Skip to content

Commit

Permalink
make crates with the same name sort consistently
Browse files Browse the repository at this point in the history
  • Loading branch information
thestinger committed Mar 24, 2013
1 parent 11ca2ef commit a919e5e
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/librustc/metadata/cstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,24 +141,28 @@ pub fn find_extern_mod_stmt_cnum(cstore: @mut CStore,
extern_mod_crate_map.find(&emod_id)
}

// returns hashes of crates directly used by this crate. Hashes are
// sorted by crate name.
// returns hashes of crates directly used by this crate. Hashes are sorted by
// (crate name, crate version, crate hash) in lexicographic order (not semver)
pub fn get_dep_hashes(cstore: @mut CStore) -> ~[~str] {
struct crate_hash { name: @~str, hash: @~str }
struct crate_hash { name: @~str, vers: @~str, hash: @~str }
let mut result = ~[];

let extern_mod_crate_map = cstore.extern_mod_crate_map;
for extern_mod_crate_map.each_value |&cnum| {
let cdata = cstore::get_crate_data(cstore, cnum);
let hash = decoder::get_crate_hash(cdata.data);
debug!("Add hash[%s]: %s", *cdata.name, *hash);
let vers = decoder::get_crate_vers(cdata.data);
debug!("Add hash[%s]: %s %s", *cdata.name, *vers, *hash);
result.push(crate_hash {
name: cdata.name,
vers: vers,
hash: hash
});
}

let sorted = std::sort::merge_sort(result, |a, b| a.name <= b.name);
let sorted = do std::sort::merge_sort(result) |a, b| {
(a.name, a.vers, a.hash) <= (b.name, b.vers, b.hash)
};

debug!("sorted:");
for sorted.each |x| {
Expand Down

5 comments on commit a919e5e

@bors
Copy link
Contributor

@bors bors commented on a919e5e Mar 26, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on a919e5e Mar 26, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging thestinger/rust/oldmap = a919e5e into auto

@bors
Copy link
Contributor

@bors bors commented on a919e5e Mar 26, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thestinger/rust/oldmap = a919e5e merged ok, testing candidate = b48e699

@bors
Copy link
Contributor

@bors bors commented on a919e5e Mar 26, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on a919e5e Mar 26, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding incoming to auto = b48e699

Please sign in to comment.