From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id E0BB11382C5 for ; Sun, 7 Mar 2021 11:42:23 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id A35BCE0814; Sun, 7 Mar 2021 11:42:22 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 36D42E0814 for ; Sun, 7 Mar 2021 11:42:22 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 9AD1F33BEDE for ; Sun, 7 Mar 2021 11:42:20 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 063E54A8 for ; Sun, 7 Mar 2021 11:42:19 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <1615109427.6eafeb89fb4d17326d6ffa1d6ca83e5407890d42.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: lib/portage/dbapi/ X-VCS-Repository: proj/portage X-VCS-Files: lib/portage/dbapi/vartree.py X-VCS-Directories: lib/portage/dbapi/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 6eafeb89fb4d17326d6ffa1d6ca83e5407890d42 X-VCS-Branch: master Date: Sun, 7 Mar 2021 11:42:19 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 0993d206-1b87-4d99-a5f5-ec3a3ac0381c X-Archives-Hash: eb73d0090fc7f1ca795945b3624afe24 commit: 6eafeb89fb4d17326d6ffa1d6ca83e5407890d42 Author: Zac Medico gentoo org> AuthorDate: Sun Mar 7 09:03:33 2021 +0000 Commit: Zac Medico gentoo org> CommitDate: Sun Mar 7 09:30:27 2021 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=6eafeb89 dblink: add _format_contents_line method Signed-off-by: Zac Medico gentoo.org> lib/portage/dbapi/vartree.py | 42 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/lib/portage/dbapi/vartree.py b/lib/portage/dbapi/vartree.py index 2c75be4a1..826083eae 100644 --- a/lib/portage/dbapi/vartree.py +++ b/lib/portage/dbapi/vartree.py @@ -5045,7 +5045,14 @@ class dblink: % (relative_path, myabsto)]) showMessage("%s %s -> %s\n" % (zing, mydest, myto)) - outfile.write("sym "+myrealdest+" -> "+myto+" "+str(mymtime // 1000000000)+"\n") + outfile.write( + self._format_contents_line( + node_type="sym", + abs_path=myrealdest, + symlink_target=myto, + mtime_ns=mymtime, + ) + ) else: showMessage(_("!!! Failed to move file.\n"), level=logging.ERROR, noiselevel=-1) @@ -5146,7 +5153,9 @@ class dblink: except OSError: pass - outfile.write("dir "+myrealdest+"\n") + outfile.write( + self._format_contents_line(node_type="dir", abs_path=myrealdest) + ) # recurse and merge this directory mergelist.extend(join(relative_path, child) for child in os.listdir(join(srcroot, relative_path))) @@ -5194,7 +5203,14 @@ class dblink: pass if mymtime != None: - outfile.write("obj "+myrealdest+" "+mymd5+" "+str(mymtime // 1000000000)+"\n") + outfile.write( + self._format_contents_line( + node_type="obj", + abs_path=myrealdest, + md5_digest=mymd5, + mtime_ns=mymtime, + ) + ) showMessage("%s %s\n" % (zing,mydest)) else: # we are merging a fifo or device node @@ -5214,9 +5230,13 @@ class dblink: else: return 1 if stat.S_ISFIFO(mymode): - outfile.write("fif %s\n" % myrealdest) + outfile.write( + self._format_contents_line(node_type="fif", abs_path=myrealdest) + ) else: - outfile.write("dev %s\n" % myrealdest) + outfile.write( + self._format_contents_line(node_type="dev", abs_path=myrealdest) + ) showMessage(zing + " " + mydest + "\n") def _protect(self, cfgfiledict, protect_if_modified, src_md5, @@ -5278,6 +5298,18 @@ class dblink: return dest, protected, move_me + def _format_contents_line( + self, node_type, abs_path, md5_digest=None, symlink_target=None, mtime_ns=None + ): + fields = [node_type, abs_path] + if md5_digest is not None: + fields.append(md5_digest) + elif symlink_target is not None: + fields.append("-> {}".format(symlink_target)) + if mtime_ns is not None: + fields.append(str(mtime_ns // 1000000000)) + return "{}\n".format(" ".join(fields)) + def _merged_path(self, path, lstatobj, exists=True): previous_path = self._device_path_map.get(lstatobj.st_dev) if previous_path is None or previous_path is False or \