This is an archive of the discontinued Mercurial Phabricator instance.

sparse: use correct cwd-prepending with patterns
ClosedPublic

Authored by ikostia on Aug 4 2017, 6:16 AM.
Tags
None
Subscribers

Details

Summary

Change fb-hgext's sparse to treat patterns correctly (this was brought to
my attention by @martinvonz on the mailing list).

This patch makes sure that:

reporoot/subdir$ hg --include **/file

results in subdir/**/file being included rather than subdir/.

Test Plan

rt

Diff Detail

Repository
rFBHGX Facebook Mercurial Extensions
Branch
default
Lint
Lint OK
Unit
Unit Test Errors

Event Timeline

ikostia created this revision.Aug 4 2017, 6:16 AM
Herald added a reviewer: Restricted Project. · View Herald TranscriptAug 4 2017, 6:16 AM
ikostia updated this revision to Diff 533.Aug 4 2017, 6:43 AM

resubmitting to avoid UT problems

ikostia updated this revision to Diff 534.Aug 4 2017, 6:45 AM

resubmitting to avoid UT problems 2

mjpieters requested changes to this revision.Aug 4 2017, 7:02 AM
mjpieters added inline comments.
hgext3rd/sparse.py
779–780

Nit: don't use backslash for line continuations when you could use (...) parentheses instead:

ap = ((kind + ':' if kind else '') +
         pathutil.canonpath(root, cwd, pat))

You also have a logic error here. You are filtering out patterns that are already absolute; if pats = ['glob:*.py', 'path:cwd/path'] you only retain ['glob:cwd/*.py'].

This revision now requires changes to proceed.Aug 4 2017, 7:02 AM
ikostia edited edge metadata.Aug 4 2017, 8:28 AM
ikostia updated this revision to Diff 535.

fix logic error

ikostia marked an inline comment as done.Aug 4 2017, 8:37 AM
mjpieters accepted this revision.Aug 4 2017, 9:02 AM
mjpieters added inline comments.
hgext3rd/sparse.py
779–783

Nit: just assign back to kindpat and drop the else: (un-indenting that line):

for kindpat in pats:
    kind, pat = matchmod._patsplit(kindpat, None)
    if kind in cwdrealtivepatkinds or kind is None:
        kindpat = ((kind + ':' if kind else '') +
                   pathutil.canonpath(root, cwd, pat))
    abspats.append(kindpat)
This revision is now accepted and ready to land.Aug 4 2017, 9:02 AM
This revision was automatically updated to reflect the committed changes.