tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 9204ac856314243af7b7bc2c88b0cf96fbc4e02c
parent c6233e288413772bdb9df5c4fca0318541d444ef
Author: Steve Fink <sfink@mozilla.com>
Date:   Tue,  7 Oct 2025 18:55:51 +0000

Bug 1992685 - Fix path handling in <repo>.diff_stream() (for mach clang-format) r=ahochheiden

My patch in bug 1985174 was overcomplicated and unnecessary: `jj diff --from REV- --to REV` can be done with `jj diff -r REV`, which implicitly compares against REV's parent(s). But the main bug here was that `glob:"*.cpp"` is not recursive; it needs to be `glob:"**/*.cpp"`.

Differential Revision: https://phabricator.services.mozilla.com/D267714

Diffstat:
Mpython/mozversioncontrol/mozversioncontrol/repo/jj.py | 4++--
Mpython/mozversioncontrol/test/test_diff_stream.py | 47++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 48 insertions(+), 3 deletions(-)

diff --git a/python/mozversioncontrol/mozversioncontrol/repo/jj.py b/python/mozversioncontrol/mozversioncontrol/repo/jj.py @@ -227,10 +227,10 @@ class JujutsuRepository(Repository): def diff_stream(self, rev=None, extensions=(), exclude_file=None, context=8): if rev is None: rev = self.HEAD_REVSET - args = ["diff", "--from", f"roots({rev})-", "--to", f"heads({rev})", "--git"] + args = ["diff", "-r", rev, "--git"] # File patterns to include - patterns = [f'glob:"*{dot_extension}"' for dot_extension in extensions] + patterns = [f'glob:"**/*{dot_extension}"' for dot_extension in extensions] if not patterns: patterns = ["all()"] diff --git a/python/mozversioncontrol/test/test_diff_stream.py b/python/mozversioncontrol/test/test_diff_stream.py @@ -22,6 +22,17 @@ STEPS = { hg commit -m "FIRST PATCH" echo bar > file1.txt """, + # Create some files for path testing. + """ + mkdir subdir + mkdir subdir/another + echo content > subdir/another/file.c + echo content > subdir/another/file.json + echo content > top.cpp + echo content > top.md + hg add top.* subdir/another/file.* + hg commit -m "Set up some files for path testing" + """, ], "git": [ """ @@ -39,6 +50,17 @@ STEPS = { echo bar > file1.txt git add file1.txt """, + # Create some files for path testing. + """ + mkdir subdir + mkdir subdir/another + echo content > subdir/another/file.c + echo content > subdir/another/file.json + echo content > top.cpp + echo content > top.md + git add top.* subdir/another/file.* + git commit -m "Set up some files for path testing" + """, ], "jj": [ # Make a base commit. @@ -58,6 +80,16 @@ STEPS = { jj new -m "resolve conflict" echo merged > file1.txt """, + # Create some files for path testing. + """ + mkdir subdir + mkdir subdir/another + echo content > subdir/another/file.c + echo content > subdir/another/file.json + echo content > top.cpp + echo content > top.md + jj commit -m "Set up some files for path testing" + """, ], } @@ -75,7 +107,7 @@ def test_diff_stream(repo): def changed_files(stream): files = set() for line in stream: - print(line) + print(line, end="") if m := re.match(r"diff --git \w/(\S+)", line): files.add(m[1]) return files @@ -107,6 +139,19 @@ def test_diff_stream(repo): assert "anotherfile.txt" in files assert "constant.txt" not in files + # Create some files in a subdir + repo.execute_next_step() + + files = changed_files( + vcs.diff_stream( + vcs.head_ref, extensions=(".cpp", ".c", ".cc", ".h", ".m", ".mm") + ) + ) + assert "top.cpp" in files + assert "top.md" not in files + assert "subdir/another/file.c" in files + assert "subdir/another/file.json" not in files + if __name__ == "__main__": mozunit.main()