Export the built tree as git repo #9
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "add_export"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The repo does not contain any files yet, it's just a list of empty commits building up the tree as git commits.
This outgrew the intended scope of this PR by a lot - but I enjoyed the silence of the bride day and parts of the public holidays (getting up at 6 and having until 12 until the family crawls out of bed is just too productive :)
@ -115,3 +92,3 @@
if not args.repodir:
args.repodir = pathlib.Path(args.package)
args.repodir = pathlib.Path("repos/" + args.package)
if in L47 use a type pathlib.Path, like in L52, you will be sure that a path is given, and this line can be
args.repodir = "repos" / args.package
But we need package for more than that
@ -205,0 +211,4 @@
to_delete = []
if current_rev:
for entry in current_rev.files_list(db):
old_files[entry["name"]] = f"{entry['md5']}-{entry['size']}"
The last two lines:
old_files = {e["name"]: f"{e['md5']}-{e['size']}" for e in current_rev.files_list(db)}
But current_rev is optional - no matter what you make out of it :)
still the
for
two lines can be replacedah
@ -202,6 +204,24 @@ class DBRevision:
self._files.sort(key=lambda x: x["name"])
return self._files
def calc_delta(self, db: DB, current_rev=None):
Reading the code seems that
current_rev
is not optional.There is a
if current_rev
- and it's treated as empty dict if there is nothing before.but not in the call?
well, the
=None
is not needed as there is always a variable passed. I guess nowadays I can make itcurrent_rev: Optional[DbRevision]
. Would that be more of your liking?What I am wondering is the semantic of the function.
calc_delta
seems to be from some status toself
. When the other status is notNone
theold_files
is empty making all to download, when I would expect that none would be listed to download.That makes me wonder if
current_rev
can be optional.I even added documentation! :)
self
is the revision to download andcurrent_rev
is the state of the repository. If it'sNone
, there is no state and everything needs to be downloaded.@ -205,0 +209,4 @@
old_files = dict()
to_download = []
to_delete = []
if current_rev:
(no optional)
@ -205,0 +213,4 @@
for entry in current_rev.files_list(db):
old_files[entry["name"]] = f"{entry['md5']}-{entry['size']}"
for entry in self.files_list(db):
if old_files.get(entry["name"], "") != f"{entry['md5']}-{entry['size']}":
old_files.get(entry["name"]) != ...
, will returnNone
if missing.true, but an old database afine developer doesn't like comparing None with strings :)
@ -205,0 +215,4 @@
for entry in self.files_list(db):
if old_files.get(entry["name"], "") != f"{entry['md5']}-{entry['size']}":
logging.debug(f"Download {entry['name']}")
to_download.append(entry["name"])
That's outputting an array, which I don't want.
right, the last line can be replaced with a
for
, but this change is for thefor
andif
linesWhat would be the benefit? I don't see it as more readable
I extended the API documentation of the function now.
(more later)
@ -0,0 +3,4 @@
find interface classes preferable (java school)"""
def call(self, node, is_source):
pass
https://docs.python.org/3/library/abc.html
That confuses me more than it helps, but I'll dig into it :)
@ -205,0 +219,4 @@
old_files.pop(entry["name"], None)
for entry in old_files.keys():
logging.debug(f"Delete {entry}")
to_delete.append(entry)
same
@ -0,0 +11,4 @@
def __str__(self) -> str:
p1_str = ""
if self.parent1:
p1_str = f" p1:{self.parent1.short_string()}"
p1_str = f" p1:{self.parent1.short_string()}" if self.parent1 else ""
@ -0,0 +37,4 @@
if self.rebase_devel and node.parent and node.parent.merged_into:
self.add("devel", node.revision, node.parent.merged_into.revision)
return
if node.parent:
making it
elif
can remove thereturn
@ -0,0 +123,4 @@
def limit_download(self, file):
if file.endswith(".spec") or file.endswith(".changes"):
return True
return False
return file.endswith((".spec", ".changes"))
But today it is better if all files are pathlib.Path objects, so you can do
return file.suffix in (".spec", ".changes")
Created https://gitea.opensuse.org/importers/git-importer/pulls/10 for the fixes - #9 was merged so that @nkrapp can base #2 on new code