Issue #9 resolved

hg diff

Anonymous created an issue

I think that it misses the hg diff command ? How can I retrieve the current diff of my current working ?

Comments (5)

  1. Fredrik Håård repo owner

    This is a missing feature right now; a workaround would be to use hg_command directly:

        repo.hg_command(['diff'])
    

    This will give you the raw diff as a string. I'll add a proper implementation in the next version (might be a week or two).

  2. Fredrik Håård repo owner

    I'm not, when thinking more about it, sure what kind of a diff an API should have; if anyone has a use-case to work from it'd be easier to implement it right.

  3. Alexis Dimitriadis

    Fredrik, here's a simple use case: I've received a file A that I keep under version control, but it's been distributed and modified. I don't know which revision was distributed, so I want to diff A with each of its versions and find the closest match / count the diff lines / display the diff / filter and display parts of the diff. So, I need to compare a disk file against (each of) a range or list of diffs, and receive the results in a form I can process further. (For the output part, I'd suggest matching python's difflib interface.)

    Another use case: I need a list of all the files that differ between two specified revisions. I might then ask for a pairwise diff of each file.

    And a fancier one: I'm interested in watching how a stretch of code evolved; I can specify it as a line range at a particular revision, and the API should allow me to (somehow) extract the matching window from each version of the file, or show me revisions that affect that range, or whatever. (But I don't see an obvious way to do this with difflib, so maybe it's beyond the scope of the API as well).

    Hope that gives you some ideas!

  4. Fredrik Håård repo owner

    I will implement this in two ways; I'll add a hg_diff command that will just give a list of diffs as output. I plan to allow fetching diffs between different versions of a file using difflib (thanks for the pointer, Alexis Dimitriadis), but need to think about the API design for that one.

    The simple version is available in 1.4.2 on PyPI.

  5. Log in to comment