Skip to content

Implement the ~ merge operation - #234

Merged
psss merged 1 commit into
mainfrom
merge-regexp
Jun 5, 2024
Merged

psss merged 1 commit into
mainfrom
merge-regexp

Conversation

@lukaszachy

@lukaszachy lukaszachy commented Apr 18, 2024 •

Copy link
Copy Markdown
Contributor

WDYT?

Todo:

  • find BETTER_NAME for this helper function
  • Documentation
  • smuggle '-~' operator (delete if matches regexp)

@lukaszachy lukaszachy added this to the 1.4 milestone Apr 18, 2024
@lukaszachy lukaszachy added enhancement New feature or request tree labels Apr 18, 2024
Comment thread fmf/utils.py Resolved
Comment thread examples/merge/parent.fmf Resolved
@lukaszachy
lukaszachy requested review from happz and psss April 18, 2024 16:17
@lukaszachy

lukaszachy commented Apr 22, 2024 •

Copy link
Copy Markdown
Contributor Author

~ should be done now

I'll add tests and docs for -~ tomorrow.

Comment thread tests/unit/test_utils.py Resolved
@lukaszachy
lukaszachy marked this pull request as ready for review April 23, 2024 13:52
@psss psss changed the title Add '~' merge operation Implement the ~ merge operation May 13, 2024
Comment thread docs/features.rst Resolved
Comment thread fmf/base.py Resolved
@thrix

thrix commented May 28, 2024

Copy link
Copy Markdown
Contributor

@LecrisUT can you resolve comments which you are happy about pls?

Comment thread docs/features.rst Resolved

@thrix thrix left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@LecrisUT

Copy link
Copy Markdown
Member

@LecrisUT can you resolve comments which you are happy about pls?

Issue is that I can't. I can only resolve comments on PRs that I have opened.

I'll give it one more look again tomorrow, but I think all of the issues are resolved. I think the only part is about "\\1", which might be better replaced with '\1' to be inline with the comment:

In the fmf file it is better to use single quotes ``'`` as they do not need such intensive escaping::

(actually maybe should still keep at least one case with "\\1" to be extra safe)

@lukaszachy

Copy link
Copy Markdown
Contributor Author

Issue is that I can't. I can only resolve comments on PRs that I have opened.

Yeah. This limitation from github is really strange:/ I have no idea that why anyone who can comment is not suddenly allowed to resolve conversation they started.

@lukaszachy

Copy link
Copy Markdown
Contributor Author

/examples/merge/parent.fmf now uses also single quotes so the \1 doesn't need to be escaped

@LecrisUT LecrisUT left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry for the late review, just a few minor touches and it's all 👍. You can resolve all of my previous discussions.

Comment thread fmf/base.py Resolved
Comment thread fmf/utils.py Resolved
Comment thread tests/unit/test_utils.py Resolved
@martinhoyer

Copy link
Copy Markdown
Contributor

I like the functionality, but this might be too much regex magic from my PoV. It might get messy with the escapes, etc.
That said, I'm sure you all regex wizards know what you're doing :) Fwiw though, I'd be willing to rewrite it without usage of re module.

@LecrisUT

LecrisUT commented Jun 3, 2024

Copy link
Copy Markdown
Member

I like the functionality, but this might be too much regex magic from my PoV. It might get messy with the escapes, etc.

That was an initial concern for me as well, but check the implementation of fmf.utils.split_pattern_repl. There there is no escaping (other than that coming from yaml, but that's why there is is the documentation suggestion of using ' to reduce escaping).

Fwiw though, I'd be willing to rewrite it without usage of re module

Problem would be with regex groups (named/unnamed). I think that's an important feature to support for this.

@martinhoyer

Copy link
Copy Markdown
Contributor

Problem would be with regex groups (named/unnamed). I think that's an important feature to support for this.

@LecrisUT No idea what what those are. Any chance you could enlighten me by pointing to how are they being used here, pretty please?

@LecrisUT

LecrisUT commented Jun 3, 2024

Copy link
Copy Markdown
Member

Problem would be with regex groups (named/unnamed). I think that's an important feature to support for this.

@LecrisUT No idea what what those are. Any chance you could enlighten me by pointing to how are they being used here, pretty please?

An example is worth a hundred words :P. See the () in the search string and the $1 in the replace.

@martinhoyer

Copy link
Copy Markdown
Contributor

Problem would be with regex groups (named/unnamed). I think that's an important feature to support for this.

@LecrisUT No idea what what those are. Any chance you could enlighten me by pointing to how are they being used here, pretty please?

An example is worth a hundred words :P. See the () in the search string and the $1 in the replace.

Thanks. I still don't get why it's needed, but guessing it is important when you want the users to be able to use regex. I was thinking more about allowing just some "simple" substitutions. :)

@psss

psss commented Jun 4, 2024

Copy link
Copy Markdown
Member

Fixed a few typos and proposing some minor adjustments in 3a8ee40.

@psss psss left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just a few minor suggestions.

Comment thread fmf/utils.py Resolved
Comment thread fmf/base.py Resolved
Comment thread fmf/base.py Resolved
@lukaszachy

Copy link
Copy Markdown
Contributor Author

Does someone explain how can fedora-40 and c9s fail on TypeError: adjust() got an unexpected keyword argument 'additional_rules' but rawhide and f-39 pass?

@LecrisUT

LecrisUT commented Jun 4, 2024

Copy link
Copy Markdown
Member

Could be a race condition. Packit uses the merge commit and not the source commit iirc. But the srpm should be the same for all builds so not quite sure

@lukaszachy

Copy link
Copy Markdown
Contributor Author

@thrix ? The passing job https://artifacts.dev.testing-farm.io/156d927c-3f15-47f6-8729-adcd97d0ef5f/#artifacts-/plans/features has

git -C testcode fetch https://github.com/teemtee/fmf 33c920df4b1481e14c0c707b0c5469961736a88e:gluetool/33c920df4b1481e14c0c707b0c5469961736a88e
git -C testcode checkout gluetool/33c920df4b1481e14c0c707b0c5469961736a88e
git -C testcode fetch https://github.com/teemtee/fmf 3a8ee401fbaa776f112a7d7948aa8eef935d0743:gluetool/3a8ee401fbaa776f112a7d7948aa8eef935d0743
git -C testcode merge --no-edit gluetool/3a8ee401fbaa776f112a7d7948aa8eef935d0743

but failing one https://artifacts.dev.testing-farm.io/9db4c21f-82b9-4f8d-bceb-806577dec328/#artifacts-/plans/features has

git -C testcode fetch https://github.com/teemtee/fmf 673c83ca1cb35256690677c1cddc88a4a2025586:gluetool/673c83ca1cb35256690677c1cddc88a4a2025586
git -C testcode checkout gluetool/673c83ca1cb35256690677c1cddc88a4a2025586
git -C testcode fetch https://github.com/teemtee/fmf 3a8ee401fbaa776f112a7d7948aa8eef935d0743:gluetool/3a8ee401fbaa776f112a7d7948aa8eef935d0743
git -C testcode merge --no-edit gluetool/3a8ee401fbaa776f112a7d7948aa8eef935d0743

Shouldn't be it the same?

@lukaszachy

Copy link
Copy Markdown
Contributor Author

Could be a race condition. Packit uses the merge commit and not the source commit iirc. But the srpm should be the same for all builds so not quite sure

Ah, I guess you are right. Job ran 4h ago and merge (introducing additional_rules) happened also around that time.

@lukaszachy

Copy link
Copy Markdown
Contributor Author

@psss I used 'repl' because re.sub(pattern, repl, string, count=0, flags=0) is used in Python itself. But OK to keep longer name.

@lukaszachy
lukaszachy requested a review from psss June 5, 2024 07:14
Comment thread docs/features.rst Resolved

@psss psss left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for all the adjustments!

Co-authored-by: Cristian Le <[email protected]>
Co-authored-by: Petr Šplíchal <[email protected]>
@psss psss self-assigned this Jun 5, 2024
@psss
psss merged commit bf511f5 into main Jun 5, 2024
@psss
psss deleted the merge-regexp branch June 5, 2024 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request tree

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants