• 
      

    Always provide revision-related headers for Mercurial diffs.

    Review Request #11151 — Created Aug. 30, 2020 and submitted

    Information

    RBTools
    release-2.0.x

    Reviewers

    Git-style Mercurial diffs lack any useful information for specifying the
    revisions of files. This meant that Review Board couldn't normally
    extract any useful identifying information for any file fetches. We had
    worked around this in the past by utilizing the diff upload API's
    base_commit_id field, but that still meant that some information was
    missing.

    This triggered a breakage whenever a change consisted of a moved file.
    Since the revision information wasn't available, the original file
    couldn't be fetched correctly, since the base_commit_id wasn't enough
    to help look it up.

    Fortunately, Review Board does include support for extracting special
    Mercurial headers containing this information. Those are only natively
    generated in an hg export (see
    https://bz.mercurial-scm.org/show_bug.cgi?id=6400), but adding this to
    RBTools-generated Mercurial diffs is trivial.

    This change implements these headers when generating diffs. We now
    always generate a Git-style diff (which was effectively the behavior
    for any modern version of Review Board anyway) and prepend these headers
    to it.

    All diff-related unit tests have been rewritten to carefully ensure that
    we're generating these diffs correctly and that they have the exact
    output we expect.

    Unit tests passed.

    Verified that generated diffs contained revision information and that
    Review Board successfully used that to locate files, even when modifying
    changes moved in a parent diff.

    Summary ID
    Always provide revision-related headers for Mercurial diffs.
    Git-style Mercurial diffs lack any useful information for specifying the revisions of files. This meant that Review Board couldn't normally extract any useful identifying information for any file fetches. We had worked around this in the past by utilizing the diff upload API's `base_commit_id` field, but that still meant that some information was missing. This triggered a breakage whenever a change consisted of a moved file. Since the revision information wasn't available, the original file couldn't be fetched correctly, since the `base_commit_id` wasn't enough to help look it up. Fortunately, Review Board does include support for extracting special Mercurial headers containing this information. Those are only natively generated in an `hg export` (see https://bz.mercurial-scm.org/show_bug.cgi?id=6400), but adding this to RBTools-generated Mercurial diffs is trivial. This change implements these headers when generating diffs. We now *always* generate a Git-style diff (which was effectively the behavior for any modern version of Review Board anyway) and prepend these headers to it. All diff-related unit tests have been rewritten to carefully ensure that we're generating these diffs correctly and that they have the exact output we expect.
    b2ae7d96d368b2dd4ae02a3ea464491832a5978d
    Description From Last Updated

    F841 local variable 'commit_id1' is assigned to but never used

    reviewbotreviewbot

    F841 local variable 'commit_id1' is assigned to but never used

    reviewbotreviewbot
    Checks run (1 failed, 1 succeeded)
    flake8 failed.
    JSHint passed.

    flake8

    chipx86
    misery
    1. 
        
    2. Tested with my script... it works! Thanks!

    3. 
        
    david
    1. Ship It!
    2. 
        
    chipx86
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to master (497cf1c)