Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tor
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
jarl
tor
Commits
e81951c4
Commit
e81951c4
authored
9 years ago
by
Nick Mathewson
Browse files
Options
Downloads
Patches
Plain Diff
Add collation/splitting support to sortChanges script
parent
f61088ce
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/maint/sortChanges.py
+40
-7
40 additions, 7 deletions
scripts/maint/sortChanges.py
with
40 additions
and
7 deletions
scripts/maint/sortChanges.py
+
40
−
7
View file @
e81951c4
...
...
@@ -5,8 +5,6 @@
"""
This script sorts a bunch of changes files listed on its command
line into roughly the order in which they should appear in the
changelog.
TODO: collation support.
"""
import
re
...
...
@@ -19,7 +17,7 @@ def fetch(fn):
return
s
def
score
(
s
,
fname
=
None
):
m
=
re
.
match
(
r
'
^ +o (
.*)
'
,
s
)
m
=
re
.
match
(
r
'
^ +o (
[^\n]*)\n(.*)
'
,
s
,
re
.
M
|
re
.
S
)
if
not
m
:
print
>>
sys
.
stderr
,
"
Can
'
t score %r from %s
"
%
(
s
,
fname
)
lw
=
m
.
group
(
1
).
lower
()
...
...
@@ -38,12 +36,47 @@ def score(s,fname=None):
else
:
score
=
100
return
(
score
,
lw
,
s
)
return
(
score
,
lw
,
m
.
group
(
1
),
m
.
group
(
2
))
def
splitChanges
(
s
):
this_entry
=
[]
for
line
in
s
.
split
(
"
\n
"
):
if
line
.
strip
()
==
""
:
continue
if
re
.
match
(
r
"
+o
"
,
line
):
if
len
(
this_entry
)
>
2
:
yield
""
.
join
(
this_entry
)
curHeader
=
line
this_entry
=
[
curHeader
,
"
\n
"
]
continue
elif
re
.
match
(
r
"
+-
"
,
line
):
if
len
(
this_entry
)
>
2
:
yield
""
.
join
(
this_entry
)
this_entry
=
[
curHeader
,
"
\n
"
]
this_entry
.
append
(
line
)
this_entry
.
append
(
"
\n
"
)
if
len
(
this_entry
)
>
2
:
yield
""
.
join
(
this_entry
)
changes
=
[
score
(
fetch
(
fn
),
fn
)
for
fn
in
sys
.
argv
[
1
:]
if
not
fn
.
endswith
(
'
~
'
)
]
changes
=
[]
for
fn
in
sys
.
argv
[
1
:]:
if
fn
.
endswith
(
'
~
'
):
continue
for
change
in
splitChanges
(
fetch
(
fn
)):
changes
.
append
(
score
(
change
,
fn
))
changes
.
sort
()
for
_
,
_
,
s
in
changes
:
print
s
last_lw
=
"
this is not a header
"
for
_
,
lw
,
header
,
rest
in
changes
:
if
lw
==
last_lw
:
print
rest
,
else
:
print
print
"
o
"
,
header
print
rest
,
last_lw
=
lw
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment