Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
Poulpe
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
octobus
Poulpe
Commits
00f612a8
Commit
00f612a8
authored
6 years ago
by
Boris Feld
Browse files
Options
Downloads
Patches
Plain Diff
Add script to recompute reference tar benchrepo data
parent
06523a7e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
repo-scripts/update-benchrepo
+92
-0
92 additions, 0 deletions
repo-scripts/update-benchrepo
tests/test-update-benchrepo.t
+165
-0
165 additions, 0 deletions
tests/test-update-benchrepo.t
with
257 additions
and
0 deletions
repo-scripts/update-benchrepo
0 → 100755
+
92
−
0
View file @
00f612a8
#!/usr/bin/env python
"""
Update a benchrepo reference tar with the repo format data
Accept a tar archive containing a benchrepo and the repository, untar the
repository, recompute the stats and update the benchrepo file in the tar
archive in-place
"""
import
argparse
import
os
import
os.path
import
shutil
import
sys
import
tarfile
import
tempfile
from
os.path
import
abspath
,
basename
,
dirname
,
join
import
yaml
parent_dir
=
abspath
(
join
(
dirname
(
abspath
(
__file__
)),
"
..
"
))
sys
.
path
.
insert
(
0
,
join
(
parent_dir
,
"
lib
"
))
from
scmperf_lib
import
gather_repo_stats
# isort:skip
def
_main
(
reference_archive_path
,
tmp_directory
):
# Extract the files
print
(
"
Extracting the tar.
"
)
with
tarfile
.
open
(
reference_archive_path
,
"
r
"
)
as
reference_archive
:
reference_archive
.
extractall
(
tmp_directory
)
# Find the benchrepo file
topdir_file
=
os
.
listdir
(
tmp_directory
)
assert
len
(
topdir_file
)
==
2
benchrepo
=
[
x
for
x
in
topdir_file
if
x
.
endswith
(
"
.benchrepo
"
)]
assert
len
(
benchrepo
)
==
1
benchrepo
=
benchrepo
[
0
]
benchrepo_path
=
join
(
tmp_directory
,
benchrepo
)
topdir_file
.
remove
(
benchrepo
)
repository
=
topdir_file
[
0
]
repository_path
=
join
(
tmp_directory
,
repository
)
# Read the benchrepo file
print
(
"
Reading the original benchrepo file.
"
)
with
open
(
benchrepo_path
)
as
benchrepo_file
:
benchrepo_data
=
yaml
.
load
(
benchrepo_file
.
read
())
# Compute the new stats
print
(
"
Gathering the new benchrepo data.
"
)
new_benchrepo_data
=
gather_repo_stats
(
repository_path
,
benchrepo_data
[
"
reference-repo
"
][
"
id
"
],
benchrepo_data
[
"
reference-repo
"
][
"
source
"
],
)
# And write it
with
open
(
benchrepo_path
,
"
w
"
)
as
new_benchrepo_file
:
new_benchrepo_file
.
write
(
yaml
.
dump
(
new_benchrepo_data
,
default_flow_style
=
False
)
)
# Write the new stats in the tar
print
(
"
Archiving the new benchrepo file.
"
)
with
tarfile
.
open
(
join
(
tmp_directory
,
"
tmp.tar
"
),
"
w
"
)
as
new_tar_file
:
new_tar_file
.
add
(
benchrepo_path
,
arcname
=
benchrepo
)
new_tar_file
.
add
(
repository_path
,
arcname
=
repository
)
# And finally overwrite the original tar in place
print
(
"
Overwriting the original archive
"
)
shutil
.
move
(
join
(
tmp_directory
,
"
tmp.tar
"
),
reference_archive_path
)
def
main
(
args
):
parser
=
argparse
.
ArgumentParser
(
description
=
__doc__
.
splitlines
(
1
)[
0
])
parser
.
add_argument
(
"
reference_archive.tar
"
)
args
=
parser
.
parse_args
(
args
)
reference_archive_path
=
getattr
(
args
,
"
reference_archive.tar
"
)
tmp_directory
=
tempfile
.
mkdtemp
()
try
:
_main
(
reference_archive_path
,
tmp_directory
)
finally
:
print
(
"
Removing the temporary directory.
"
)
shutil
.
rmtree
(
tmp_directory
)
if
__name__
==
"
__main__
"
:
main
(
sys
.
argv
[
1
:])
This diff is collapsed.
Click to expand it.
tests/test-update-benchrepo.t
0 → 100644
+
165
−
0
View file @
00f612a8
======================================
Test
for
the
`
update benchrepo
`
script
======================================
Setup
$
export
PATH
=
$TESTDIR
/../
repo
-
scripts
/
:
$
{
PATH
}
$
mkdir
some
-
dir
$
hg
init
some
-
dir
/
my
-
source
-
repo
$
cd
some
-
dir
/
$
hg
-
R
my
-
source
-
repo
debugbuilddag
--
new
-
file
'
.+5:brancha$.+11:branchb$.+30:branchc<brancha+2<branchb+2
'
$
cat
<<
EOF
>
my
-
source
-
repo
.
benchrepo
>
reference
-
repo:
>
id:
my
-
reference
>
source:
some
-
dir
/
my
-
source
-
repo
>
EOF
$
cat
my
-
source
-
repo
.
benchrepo
reference
-
repo:
id:
my
-
reference
source:
some
-
dir
/
my
-
source
-
repo
$
tar
cf
"
my-reference.tar
"
"
my-source-repo.benchrepo
"
"
my-source-repo
"
Wrong
call
----------
$
update
-
benchrepo
--
help
usage:
update
-
benchrepo
[
-
h
]
reference_archive
.
tar
Update
a
benchrepo
reference
tar
with
the
repo
format
data
positional
arguments:
reference_archive
.
tar
optional
arguments:
-
h
,
--
help
show
this
help
message
and
exit
$
update
-
benchrepo
usage:
update
-
benchrepo
[
-
h
]
reference_archive
.
tar
update
-
benchrepo:
error:
too
few
arguments
[
2
]
Actual
call
-----------
$
update
-
benchrepo
my
-
reference
.
tar
Extracting
the
tar
.
Reading
the
original
benchrepo
file
.
Gathering
the
new
benchrepo
data
.
Archiving
the
new
benchrepo
file
.
Overwriting
the
original
archive
Removing
the
temporary
directory
.
$
cd
..
$
cat
my
-
source
-
repo
.
benchrepo
cat:
my
-
source
-
repo
.
benchrepo:
No
such
file
or
directory
[
1
]
$
tar
tf
some
-
dir
/
my
-
reference
.
tar
|
sort
my
-
source
-
repo
.
benchrepo
my
-
source
-
repo
/
my
-
source
-
repo
/.hg/
my
-
source
-
repo
/.hg/
00
changelog
.
i
my
-
source
-
repo
/.hg/cac
he
/
my
-
source
-
repo
/.hg/cac
he
/
branch2
-
served
my
-
source
-
repo
/.hg/cac
he
/
manifestfulltextcache
my
-
source
-
repo
/.hg/cac
he
/
rbc
-
names
-
v1
my
-
source
-
repo
/.hg/cac
he
/
rbc
-
revs
-
v1
my
-
source
-
repo
/.hg/di
rstate
my
-
source
-
repo
/.hg/local
tags
my
-
source
-
repo
/.hg/
requires
my
-
source
-
repo
/.hg/s
tore
/
my
-
source
-
repo
/.hg/s
tore
/
00
changelog
.
i
my
-
source
-
repo
/.hg/s
tore
/
00
manifest
.
i
my
-
source
-
repo
/.hg/s
tore
/data/
my
-
source
-
repo
/.hg/s
tore
/data/n
f0
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f1
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f10
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f11
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f12
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f13
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f14
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f15
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f16
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f17
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f18
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f19
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f2
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f20
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f21
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f22
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f23
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f24
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f25
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f26
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f27
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f28
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f29
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f3
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f30
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f31
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f32
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f33
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f34
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f35
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f36
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f37
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f38
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f39
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f4
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f40
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f41
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f42
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f43
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f44
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f45
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f46
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f47
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f48
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f49
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f5
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f50
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f51
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f52
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f6
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f7
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f8
.
i
my
-
source
-
repo
/.hg/s
tore
/data/n
f9
.
i
my
-
source
-
repo
/.hg/s
tore
/
fncache
my
-
source
-
repo
/.hg/s
tore
/
phaseroots
my
-
source
-
repo
/.hg/s
tore
/
undo
my
-
source
-
repo
/.hg/s
tore
/
undo
.
backupfiles
my
-
source
-
repo
/.hg/s
tore
/
undo
.
phaseroots
my
-
source
-
repo
/.hg/undo
.
bookmarks
my
-
source
-
repo
/.hg/undo
.
branch
my
-
source
-
repo
/.hg/undo
.
desc
my
-
source
-
repo
/.hg/undo
.
dirstate
my
-
source
-
repo
/.hg/
wcache
/
$
tar
-
xf
some
-
dir
/
my
-
reference
.
tar
my
-
source
-
repo
.
benchrepo
$
cat
my
-
source
-
repo
.
benchrepo
reference
-
repo:
enabled:
true
format
-
info:
compression:
zlib
dotencode:
true
fncache:
true
generaldelta:
true
plain
-
cl
-
delta:
true
sparserevlog:
true
hg
-
version:
*
(
glob
)
id:
my
-
reference
number
-
heads:
all:
3
visible:
3
number
-
named
-
branch:
all:
1
visible:
1
number
-
revisions:
all:
53
visible:
53
source:
some
-
dir
/
my
-
source
-
repo
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