From patchwork Wed May 6 15:29:52 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2275 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1778081439; bh=GgiuS0OZV92ahw2ch8YDmRtEl59PXGGP3aRsaxw+HJ8=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=QFQw7O5eOn9Sy0NE7K5tK1F5rXVP858c+0RTwPFD+T3rc+mSEmBpHjSchF5+2xfHe D73U53me5xucfZ7jY42/IPh2vUHKL33riPHDPl/HPWf8V0Nh7B0bDaM7EGfct2XuPC lQWqJXh7O+N+4YYhcXBnBrdY6ukcZpM7ap8jjsUs= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6CCEB6A950 for ; Wed, 6 May 2026 09:30:39 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 83HH6SmmNQ4x for ; Wed, 6 May 2026 09:30:39 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1778081438; bh=GgiuS0OZV92ahw2ch8YDmRtEl59PXGGP3aRsaxw+HJ8=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=ZzC4Cl22ni6feUPY3OCv6Xrkf6lLf2POY8hoHd6EUCCm0hhFyr4wn6leGQyN/+aQZ SS0SFyLxLwvXai/aUjqE0y6jykUMrACBYj7SpX8jTt+s7PQP/v6Y9YNlWsYYWls4UX 1Y2xFamNmbcoFEf66Pe5GBi0rhBp+UIHK6JGo6OM= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 639386A949 for ; Wed, 6 May 2026 09:30:38 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1778081436; bh=DjxCuNpMSHKN4ysSaf31ytzbk1Jusn1PI9QCywyGyyw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cN1hLFZnML/VZbvr8RQ9iqxTu58zt1NZUjbT/fNlVB7wH7WAzwtua0Hd0ll/iPy/f x0OgjuBEgQBBHFjf4eD4G0EwIvUWJ/4zHmD8ZzcxXq+w9DtQxntmB0rCgIYR80T9Sh uZuJ4zxwKdEn/eQ84LwTgV7/iOv1rumbEpVofnUY= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CC24B6A937; Wed, 6 May 2026 09:30:36 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id 8KSR2YAp3v4R; Wed, 6 May 2026 09:30:36 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1778081436; bh=gwIHDwE/jF9QIrDB8qspF6QQW1HOVH7ty+G4kbg+Ngo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n9748C9m+ubMkuFknZxIKhtqImee8YFBTQY89HMWrnvn3/dYyBf3mKrbkM/Sa0nJD 3/Al0ImGy2l5Wwqcaj7s3BpQDbMgG7ozOgS5B5KAYxx76wEa8pCu3FxTDUboDwbv/L B1/8wCk3lJPBOtTu4ikRL7F1AuTr2+Buibc6+n+k= Received: from u-boot.org (unknown [174.51.25.52]) by mail.u-boot.org (Postfix) with ESMTPSA id 35C0E6A87B; Wed, 6 May 2026 09:30:36 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 6 May 2026 09:29:52 -0600 Message-ID: <20260506153006.529909-4-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260506153006.529909-1-sjg@u-boot.org> References: <20260506153006.529909-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: RNRPPHK65JLPYKGY3HUPWFQ3AYGW7LWW X-Message-ID-Hash: RNRPPHK65JLPYKGY3HUPWFQ3AYGW7LWW X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 3/6] patman: Allow overriding the database directory with PATMAN_DB_DIR List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass The database location is hardcoded to .patman.db in the top of the current git repo, so running 'patman review' (or any other patman command) in a second worktree or unrelated repo creates and uses a fresh database there. Combined with the new WAL support, it would be nice to keep a single 'main' database and reach it from anywhere. Provide a PATMAN_DB_DIR environment variable that, when set, names the directory in which patman looks for .patman.db, mirroring the default layout. The override applies only to the database; git operations still run against the current repo, so for example:: export PATMAN_DB_DIR=~/u-boot cd ~/some-other-tree patman review -s my-series uses the main database while applying patches in the other tree. The value is passed through os.path.expanduser() so '~' works. Signed-off-by: Simon Glass --- tools/patman/cser_helper.py | 9 ++++++++- tools/patman/patman.rst | 11 +++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/tools/patman/cser_helper.py b/tools/patman/cser_helper.py index 0ce59e8ecc0..0274e28f42b 100644 --- a/tools/patman/cser_helper.py +++ b/tools/patman/cser_helper.py @@ -106,7 +106,14 @@ class CseriesHelper: if not self.topdir: raise ValueError('No git repo detected in current directory') self.gitdir = os.path.join(self.topdir, '.git') - fname = f'{self.topdir}/.patman.db' + + # PATMAN_DB_DIR lets the user keep a single 'main' database while + # running patman in other repos. Only the DB path is overridden; + # git operations still run against the current repo. Use 'or' (not + # os.environ.get(key, default)) so an empty PATMAN_DB_DIR='' falls + # back to topdir rather than producing '/.patman.db' + db_dir = os.environ.get('PATMAN_DB_DIR') or self.topdir + fname = os.path.join(os.path.expanduser(db_dir), '.patman.db') # For the first instance, start it up with the expected schema self.db, is_new = Database.get_instance(fname) diff --git a/tools/patman/patman.rst b/tools/patman/patman.rst index ef8e2e2025c..98a51bcfc6f 100644 --- a/tools/patman/patman.rst +++ b/tools/patman/patman.rst @@ -1465,6 +1465,17 @@ Patman stores series tracking, review and workflow state in a SQLite database (``.patman.db``) in the top-level git directory. The schema is versioned and auto-migrated on startup (currently at v10). +Set the ``PATMAN_DB_DIR`` environment variable to use a database elsewhere +(``~`` is expanded). The variable names a *directory* in which patman looks +for ``.patman.db``, mirroring the default layout. This is useful if you keep +a single 'main' patman database in one repo but want to run, for example, +``patman review`` in another worktree or repo: the DB path is overridden but +git operations still run against the current repo. For instance:: + + export PATMAN_DB_DIR=~/u-boot + cd ~/some-other-tree + patman review -s my-series + The connection is opened in WAL mode (``journal_mode=WAL``, ``synchronous=NORMAL``) with a 30-second busy timeout, which lets multiple patman invocations share the database safely: concurrent readers do not block