Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Commit-Analysis-ML
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ahmad, Rawel
Commit-Analysis-ML
Commits
7e5810f6
Commit
7e5810f6
authored
Sep 4, 2023
by
Rawel
Browse files
Options
Downloads
Patches
Plain Diff
Made the removing of initial commits more general to include also chromium
parent
4a7ba5ab
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Data/Database/db_repository.py
+21
-8
21 additions, 8 deletions
Data/Database/db_repository.py
Data/Utils/CleanupUtils.py
+1
-1
1 addition, 1 deletion
Data/Utils/CleanupUtils.py
with
22 additions
and
9 deletions
Data/Database/db_repository.py
+
21
−
8
View file @
7e5810f6
...
...
@@ -11,6 +11,15 @@ from Data.Database.constants import MYSQL_CONFIG
class
DBRepository
:
"""
Class that abstracts DB operations
"""
initial_commits
=
[
# Linux
"
1da177e4c3f41524e886b7f1b8a0c1fc7321cac2
"
,
# Chromium
"
09911bf300f1a419907a9412154760efd0b7abc3
"
,
# Chromium
"
a814a8d55429605fe6d7045045cd25b6bf624580
"
,
]
def
__init__
(
self
):
self
.
_open
()
...
...
@@ -475,7 +484,6 @@ class DBRepository:
cursor
=
self
.
cnx
.
cursor
()
try
:
# cursor.execute("SET FOREIGN_KEY_CHECKS = 0;")
# Update the mapping if it exists
update
=
(
"
UPDATE `link_fixing_commit_vcc`
"
...
...
@@ -494,7 +502,6 @@ class DBRepository:
"
mapping_id
"
:
mapping_id
,
},
)
# cursor.execute("SET FOREIGN_KEY_CHECKS = 1;")
self
.
cnx
.
commit
()
except
mysql
.
connector
.
Error
as
err
:
...
...
@@ -585,29 +592,35 @@ class DBRepository:
return
result
def
remove_
linux_
initial_commit
(
self
):
def
remove_initial_commit
s
(
self
):
"""
Removes the initial commit
of the Linux kernel
from the database.
Removes the initial commit
s
from the database.
A significant portion of commits in the data point to the Linux kernel
'
s initial commit.
This initial commit comprises over 6 million changes across more than 17 thousand files,
rendering it unsuitable for use as a practical VCC.
Consequently, remove this commit from the database where it was utilized.
This also counts for the initial commit of the Chromium project that also comprises a lot of changes.
In general removed all initial commits which are defined in the ``initial_commits`` list.
"""
if
not
self
.
cnx
.
is_connected
():
self
.
_open
()
cursor
=
self
.
cnx
.
cursor
()
initial_commit
=
"
1da177e4c3f41524e886b7f1b8a0c1fc7321cac2
"
# Get the initial commit of the Chromium project
initial_commits
=
tuple
(
i
for
i
in
self
.
initial_commits
)
try
:
# We have to disable foreign key checks to be able to update the table
cursor
.
execute
(
"
SET FOREIGN_KEY_CHECKS = 0;
"
)
update_vcc
=
(
"
UPDATE `link_fixing_commit_vcc` SET `vcc_sha` = NULL, `determined_by_heuristic` = TRUE
"
"
WHERE `vcc_sha` = %(initial_commit)s
"
"
UPDATE `link_fixing_commit_vcc` SET `vcc_sha` = NULL, `determined_by_heuristic` = TRUE WHERE
"
f
"
{
'
`vcc_sha` = %s OR
'
*
(
len
(
initial_commits
)
-
1
)
}
`vcc_sha` = %s;
"
)
cursor
.
execute
(
update_vcc
,
initial_commits
,
)
cursor
.
execute
(
update_vcc
,
{
"
initial_commit
"
:
initial_commit
})
cursor
.
execute
(
"
SET FOREIGN_KEY_CHECKS = 1;
"
)
self
.
cnx
.
commit
()
except
mysql
.
connector
.
Error
as
err
:
...
...
This diff is collapsed.
Click to expand it.
Data/Utils/CleanupUtils.py
+
1
−
1
View file @
7e5810f6
...
...
@@ -3,7 +3,7 @@ from Data.Database.db_repository import DBRepository
def
main
():
db_repo
=
DBRepository
()
db_repo
.
remove_
linux_
initial_commit
()
db_repo
.
remove_initial_commit
s
()
if
__name__
==
"
__main__
"
:
...
...
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