Skip to content

[main] Rewrite rootcp in C++#20536

Merged
silverweed merged 13 commits intoroot-project:masterfrom
silverweed:rootcp_cxx
Jan 22, 2026
Merged

[main] Rewrite rootcp in C++#20536
silverweed merged 13 commits intoroot-project:masterfrom
silverweed:rootcp_cxx

Conversation

@silverweed
Copy link
Contributor

This Pull request:

Depends on #20531.

Replaces rootcp.py with a native version in C++.
Like for rootls and rootbrowse, this makes rootcp available even without python and, as a bonus, makes the tool significantly faster (the python version takes about 500ms just to start).

The behaviour should be the same as the python version and it has the benefit of not crashing when trying to copy RNTuples (although RNTuple is not handled yet).

The new rootcp has been currently mostly tested with our own roottest suite, but probably we want some more thorough testing before merging, especially if rootcp is used in experiments workflows.

Other significant changes

  • Some code was put in common between rootls and rootcp (will also be useful for rootmv and likely rootmkdir): this is the code that basically converts a path like "file.root:a/b/*" to a tree of objects and directories.

Checklist:

  • tested changes locally
  • updated the docs (if necessary)

@silverweed silverweed self-assigned this Nov 26, 2025
@silverweed silverweed force-pushed the rootcp_cxx branch 3 times, most recently from ad80460 to a6e4556 Compare November 26, 2025 13:37
@silverweed silverweed marked this pull request as draft November 26, 2025 15:04
@github-actions
Copy link

github-actions bot commented Nov 26, 2025

Test Results

    21 files      21 suites   3d 5h 5m 53s ⏱️
 3 764 tests  3 764 ✅ 0 💤 0 ❌
71 218 runs  71 218 ✅ 0 💤 0 ❌

Results for commit 9daafe2.

♻️ This comment has been updated with latest results.

@silverweed silverweed force-pushed the rootcp_cxx branch 2 times, most recently from 001245d to 76da6da Compare November 27, 2025 14:02
@silverweed silverweed force-pushed the rootcp_cxx branch 2 times, most recently from f96b407 to 666a298 Compare December 8, 2025 07:22
@silverweed silverweed marked this pull request as ready for review December 10, 2025 12:25
Copy link
Member

@vepadulano vepadulano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, thanks! Some questions from my side.

@silverweed silverweed force-pushed the rootcp_cxx branch 2 times, most recently from 45566a0 to 784e022 Compare January 12, 2026 13:13
@silverweed silverweed requested a review from vepadulano January 13, 2026 08:01
Copy link
Member

@vepadulano vepadulano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, all clear for me!

@silverweed silverweed merged commit 2438120 into root-project:master Jan 22, 2026
28 of 30 checks passed
@silverweed silverweed deleted the rootcp_cxx branch January 22, 2026 08:14
Comment on lines +89 to +92
std::cerr << "WARNING: Several versions of '" << key->GetName() << "' are present in '" << fileName
<< "'. Only the most recent will be considered.\n";
continue;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this an error? Having backup keys is the common case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just a warning, and it was like this in rootcp.py so I kept it as-is

Comment on lines +69 to +70
std::sort(keys.begin(), keys.end(),
[](const auto *a, const auto *b) { return strcmp(a->GetName(), b->GetName()) < 0; });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this intermediary step needed? (And it seems it might also shuffle the ordering of the keys that corresponding to the same name).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we want to show the keys sorted by name? I'm not sure I understand the question

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants