Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Paste
P9435
compare-meta-refs.py
Active
Public
Actions
Authored by
hashar
on Oct 22 2019, 1:16 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Referenced Files
F30875382: raw.txt
Oct 22 2019, 1:16 PM
2019-10-22 13:16:13 (UTC+0)
Subscribers
None
#!/usr/bin/env python3
import
re
import
unittest
from
collections
import
defaultdict
def
parse_path
(
path
):
# Example:
# ./eventlogging.git/refs/changes/44/544144/meta:b6950bfe08fd59a63dfbcc4ff3b5ecfa5da43dcd
m
=
re
.
match
(
'^./(.*)\.git/(.+/meta)$'
,
path
)
# (repo, ref)
return
(
m
[
1
],
m
[
2
])
def
parse_file
(
fname
):
stuff
=
defaultdict
(
dict
)
with
open
(
fname
)
as
f
:
print
(
"Reading
%s
"
%
fname
)
for
line
in
f
.
readlines
():
(
path
,
sha1
)
=
line
.
rstrip
()
.
split
(
':'
)
(
repo
,
ref
)
=
parse_path
(
path
)
stuff
[
repo
][
ref
]
=
sha1
return
stuff
refs
=
{}
repos
=
set
()
for
host
in
(
'cobalt'
,
'gerrit1001'
):
refs
[
host
]
=
parse_file
(
'
%s
-meta-files.txt'
%
host
)
repos
=
repos
.
union
(
set
(
refs
[
host
]
.
keys
()))
print
(
'Found
%s
repositories.'
%
len
(
repos
))
for
repo
in
sorted
(
repos
):
testcase
=
unittest
.
TestCase
()
testcase
.
maxDiff
=
None
try
:
testcase
.
assertDictEqual
(
refs
[
'cobalt'
][
repo
],
refs
[
'gerrit1001'
][
repo
])
except
AssertionError
as
e
:
print
(
"FAIL
%s
:
%s
"
%
(
repo
,
e
))
pass
else
:
print
(
"OK
%s
"
%
repo
)
Event Timeline
hashar
created this paste.
Oct 22 2019, 1:16 PM
2019-10-22 13:16:13 (UTC+0)
hashar
mentioned this in
P9436 (An Untitled Masterwork)
.
Oct 22 2019, 1:18 PM
2019-10-22 13:18:14 (UTC+0)
Comment Actions
That is for
T236114
. Output is
P9436
hashar
mentioned this in
T236114: check and fix some Gerrit revs
.
Oct 22 2019, 1:18 PM
2019-10-22 13:18:51 (UTC+0)
Log In to Comment