Skip to content

Dynamic context adjustment #1

@Cerenia

Description

@Cerenia

Current behavior

Feature-patch iterates over all the marked files (contact points) in a preprocessing step. There already is a guardrail to check if all the brackets are matched (every 'start' comment has a matching 'end' comment) when the files are enumerated.

After the container repository is updated to the new version and the subrepository reinserted to the container, feature-patch iterates over the contact points and creates the runtime log. This records the path of the contact point file, the path of the matching file in the container repository (or a placeholder if the file is to be copied instead of needing to patch), and a flag for repeated executions of the script (so that we don't have to redo work that was successful if the script happens to crash somewhere).

If the files are to be patched, diff-match-patch needs to be told how much context (#of lines) to take into account (currently statically defined in the config file diff_context_lines) to match where the code should be inserted.
This is not ideal for all files. Sometimes the #of lines should be increased or decreased.

Desired behavior

This limit could be dynamically adapted in the preprocessing step (e.g., looking at the minimum # of lines between any 'end' and 'start' brackets and setting the context to this limit, thought there may be a better algorithm) and saved alongside the the paths and flags in the runtime log and then picked up by the tool while patching.

The tasks are:

  • Determine a good algorithm for deciding the dynamic line limit per file
  • Add this to the preprocessing step and save the dynamic limit in the runtime log
  • Use the dynamic limit in the runtime log instead of the statically defined number in the configuration
  • Remove or repurpose the static diff_context_lines value

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions