In Mercurial 3.2 the locate command was deprecated in favor of files command. This change updates the DiffusionLowLevelMercurialPathsQuery command to conditionally use locate or files based on the version of Mercurial used.
Closes T7375
Differential D14253
Conditionally use `hg files` vs. `hg locate` depending on version of Mercurial cspeckmim on Oct 11 2015, 6:59 PM. Authored by Tags None Referenced Files
Subscribers
Details
In Mercurial 3.2 the locate command was deprecated in favor of files command. This change updates the DiffusionLowLevelMercurialPathsQuery command to conditionally use locate or files based on the version of Mercurial used. Closes T7375 My test/develop Phabricator instance is setup to run Mercurial 3.5.1. The test procedure to verify valid file listings are being returned:
{ "0": "README", "1": "alpha/beta/trifle", "2": "test/Chupacabra.cow", "3": "test/socket.ks" } I repeated the above steps after setting up Mercurial 2.6.2, which I installed in the following manner:
With the Multimeter application active
Diff Detail
Event TimelineComment Actions
Comment Actions I believe I have tested this successfully. I will update the Test Plan to describe what steps I took. I used the following commit to understand where hg locate is used: I started searching around for other areas where it might be used and came across: I'm not familiar with Multimeter -- wasn't sure what would be needed to update that, if at all. Comment Actions For Multimeter, I think you should just add files to the list: 'files' => true, What that's doing is whitelisting CLI arguments for building this view: By default, we show only the name of the binary, because we want to: (a) aggregate similar commands together and (b) not leak sensitive information. For example, a hypothetical rm <path> command would have a different path every time and prevent meaningful aggregation, and a hypothetical set-password <password> would leak sensitive information. By default, we would record these as bin.rm and bin.set-password. So, by default, hg files will be lumped into all other default invocations of hg that aren't explicitly whitelisted. For comparison, see how git diff and git log are separate, but git is also present. Those are separated because of the whitelisting of diff and log near the code you linked to: when we run git diff or git log it gets split out, and when we run git <anything not on the whitelist> it gets bucked into git. Since hg files is useful to separate, meaningful for aggregation, and not sensitive, adding files to the map will improve the quality of the Multimeter samples a little bit. You don't need to bother testing that, but theoretically you'd do it like this:
Comment Actions Maybe a slightly cleaner way to structure this is to expose a method like SomethingSomething::isMercurialFilesCommandAvailable($mercurial_version), and then keep the files vs locate logic private inside DiffusionLowLevelMercurialPathsQuery? Structuring the version test like that lets you write a more pure unit test (no preg_match stuff), have a cleaner API (no implicit "expects to be run with 2 arguments" stuff), and might be useful to other callsites in the future. Structured like the current diff, the files vs locate logic is a little better localized, but the API and test feel a lot messier to me, and I can't imagine any other callsite ever invoking this method.
Comment Actions OK - when adding these unit tests I did wonder a bit about how to make it testable, but also wasn't sure about needing to make the method public in order to be callable by the UT -- I struggled for a few minutes not sure whether the actual command string should be returned from the method or defined by the caller. I like the structure you propose.
Comment Actions Updated based on feedback
|