This is an archive of the discontinued Mercurial Phabricator instance.

dirstate: add explicit methods for querying directories (API)
ClosedPublic

Authored by mbthomas on Nov 8 2017, 12:31 PM.

Details

Summary

The set-like object returned by dirstate.dirs may be difficult for other
implementations of the dirstate to provide, and is unnecessary as it is
only ever used for contains. Instead, provide an explicit method for
testing for a directory.

.. api::

dirstate no longer provides a `dirs()` method.  To test for the existence of
a directory in the dirstate, use `dirstate.hasdir(dirname)`.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

mbthomas created this revision.Nov 8 2017, 12:31 PM
mbolin added a subscriber: mbolin.Nov 9 2017, 8:24 PM
mbolin added inline comments.
mercurial/dirstate.py
393

Can you just use hasdir here instead so there's only one thing to override?

397

Here too?

mbthomas updated this revision to Diff 3442.Nov 13 2017, 7:18 AM
durin42 accepted this revision.Nov 13 2017, 5:48 PM
durin42 added a subscriber: durin42.

Looks good. For bonus points do one more upload with the right .. api:: annotation for the releasenotes extension.

This revision is now accepted and ready to land.Nov 13 2017, 5:48 PM
mbthomas added inline comments.Nov 15 2017, 3:56 AM
mercurial/dirstate.py
393

The external dirstate object only provides hasdir(), however the internal object needs to provide two objects as there are two behaviours it needs to expose:

hastrackeddir() considers only files that are not marked as removed. This is used almost everywhere.

hasdir() additionally considers directories that contain only removed files. This is used in one place below (line 803). I don't understand what _walkexplicit is trying to do, so I haven't changed it. I'm not convinced _walkexplicit is correct, though.

mbthomas edited the summary of this revision. (Show Details)Nov 15 2017, 4:08 AM
mbthomas retitled this revision from dirstate: add explicit methods for querying directories to dirstate: add explicit methods for querying directories (API).
mbthomas updated this revision to Diff 3519.
durin42 accepted this revision.Nov 17 2017, 5:22 PM
This revision was automatically updated to reflect the committed changes.