D7570: match: resolve filesets against the passed `cwd`, not the current one

mharbison72 (Matt Harbison) phabricator at mercurial-scm.org
Wed Dec 11 09:48:28 EST 2019


mharbison72 added a comment.


  In D7570#111783 <https://phab.mercurial-scm.org/D7570#111783>, @martinvonz wrote:
  
  > In D7570#111295 <https://phab.mercurial-scm.org/D7570#111295>, @yuja wrote:
  >
  >>>   if listsubrepos:
  >>>       for subpath in ctx.substate:
  >>>
  >>> - sm = ctx.sub(subpath).matchfileset(pat, badfn=badfn)
  >>>
  >>> +                    sm = ctx.sub(subpath).matchfileset(
  >>> +                        pat, badfn=badfn, cwd=cwd
  >>> +                    )
  >>
  >> Might have to adjust cwd since it may be relative to the parent's repo.root.
  
  Is this case any different from `hg -R path/to/repo ...`?
  
  > Do you think this patch is making it worse or can we leave it as is for now and let someone who cares about subrepos fix it?
  
  I'll look and see how easy it is to drop the subrepo stuff for now.  It isn't operative until somebody adds a `-S` or support for breaking paths on a subrepo boundary to the command anyway.
  
  The real trap here is catching all of the subrepo references in the parent.  Say you have a repo that maps like this:
  
    2 -> S1
    1 -> S1
  
  If you `hg fix -r 2` and it edits S1, that will cause parent rev 1 to be dangling.  I guess we could modify `.hgsubstate` in 1 too without running fixers there.  But what if 1 is already public?  The preflight checks will be extensive.  That said, I'd like to get this sort of thing working because the UX with editing a subrepo is *really* bad, especially if you're editing anything other than the subrepo tip.
  
  >>> class matchctx(object):
  >>>
  >>> - def __init__(self, basectx, ctx, badfn=None):
  >>>
  >>> +    def __init__(self, basectx, ctx, badfn=None, cwd=None):
  >>>
  >>>   self._basectx = basectx
  >>>   self.ctx = ctx
  >>>   self._badfn = badfn
  >>>   self._match = None
  >>>   self._status = None
  >>>
  >>> +        self.cwd = cwd
  >>>
  >>>   def narrowed(self, match):
  >>>       """Create matchctx for a sub-tree narrowed by the given matcher"""
  >>
  >> Perhaps self.cwd would have to be copied to the matchctx objects created
  >> by itself.
  >> One option to detect this kind of bugs is to remove the default parameters.
  >
  > Good idea, I've updated Matt's patch with that suggestion.
  
  Thanks!

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7570/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7570

To: mharbison72, #hg-reviewers
Cc: hooper, yuja, martinvonz, mercurial-devel


More information about the Mercurial-devel mailing list