Show More
@@ -15,6 +15,10 b' from mercurial import (' | |||||
15 | smartset, |
|
15 | smartset, | |
16 | ) |
|
16 | ) | |
17 |
|
17 | |||
|
18 | import sortedcontainers | |||
|
19 | ||||
|
20 | SortedSet = sortedcontainers.SortedSet | |||
|
21 | ||||
18 | revsetpredicate = registrar.revsetpredicate() |
|
22 | revsetpredicate = registrar.revsetpredicate() | |
19 |
|
23 | |||
20 |
|
24 | |||
@@ -78,7 +82,7 b' def scratch(repo, subset, x):' | |||||
78 | n = revsetlang.getinteger(n, _(b"scratch expects a number")) |
|
82 | n = revsetlang.getinteger(n, _(b"scratch expects a number")) | |
79 |
|
83 | |||
80 | selected = set() |
|
84 | selected = set() | |
81 |
heads = |
|
85 | heads = SortedSet() | |
82 | children_count = collections.defaultdict(lambda: 0) |
|
86 | children_count = collections.defaultdict(lambda: 0) | |
83 | parents = repo.changelog._uncheckedparentrevs |
|
87 | parents = repo.changelog._uncheckedparentrevs | |
84 |
|
88 | |||
@@ -102,9 +106,7 b' def scratch(repo, subset, x):' | |||||
102 | for x in range(n): |
|
106 | for x in range(n): | |
103 | if not heads: |
|
107 | if not heads: | |
104 | break |
|
108 | break | |
105 |
pick |
|
109 | pick = rand.choice(heads) | |
106 | pickable.sort() |
|
|||
107 | pick = rand.choice(pickable) |
|
|||
108 | heads.remove(pick) |
|
110 | heads.remove(pick) | |
109 | assert pick not in selected |
|
111 | assert pick not in selected | |
110 | selected.add(pick) |
|
112 | selected.add(pick) |
General Comments 0
You need to be logged in to leave comments.
Login now