Inconsistent HG_PENDING handling

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Wed Feb 15 10:51:11 EST 2017


At Thu, 16 Feb 2017 00:01:05 +0900,
FUJIWARA Katsunori wrote:
> 
> At Mon, 13 Feb 2017 18:19:35 -0500,
> Augie Fackler wrote:
> > 
> > (+foozy, marmoute for transaction musing)
> > 
> > On Sun, Feb 12, 2017 at 07:06:49PM -0500, timeless wrote:
> > > bookmarks.py
> > >     if 'HG_PENDING' in encoding.environ:
> > >         try:
> > >             bkfile = repo.vfs('bookmarks.pending')
> > >
> > > dirstate.py
> > > def _trypending(root, vfs, filename):
> > >     '''Open  file to be read according to HG_PENDING environment variable
> > >
> > >     This opens '.pending' of specified 'filename' only when HG_PENDING
> > >     is equal to 'root'.
> > >
> > >     This returns '(fp, is_pending_opened)' tuple.
> > >     '''
> > >     if root == encoding.environ.get('HG_PENDING'):
> > >
> > > localrepo.py
> > >         if 'HG_PENDING' in encoding.environ:
> > >             p = encoding.environ['HG_PENDING']
> > >             if p.startswith(self.root):
> > >                 c.readpending('00changelog.i.a')
> > >
> > > it /seems/ like the dirstate code is designed so that it shows the
> > > dirstate for a given repository based on pending
> > > so, if i have a hg hook that deals w/ HG_PENDING
> > >
> > > and there are 2 hg things triggering pending
> > > and thus two repositories running hooks that deal w/ pending
> > > and for some reason one of them runs an hg command in the other repository
> > > that second repository will afaict not report the pending dirstate,
> > > since it checks carefully
> > > but will report the pending bookmark, since afaict it checks carelessly
> > >
> > > the same incorrect behavior appears to be present for phases too
> > >
> > > but that should mean a nested repo could see a pending something
> > >
> > > if i have a repo w/ a registered subrepo, and someone does a "push" to
> > > my repo, is the subrepo directory modified as part of the step leading
> > > to my push-pretxn hook?
> > 
> > This looks correct to me - there's one easy-to-fix bug in bookmarks,
> > and one hard-to-fix bug related to nested repositories. Can I at least
> > get you to draft a change for bookmarks to make it more sound?
> > 
> > Thanks!
> 
> I understand:
> 
>   - a transaction covers only one repository
> 
>   - an external hook with HG_PENDING can't see any pending changes in
>     other repositories, even if they are outer ones of subrepo nesting
> 
> IMHO, making HG_PENDING check in bookmarks.py, phases.py, and
> localrepo.py strict is enough.

Oops, I overlooked the case that transactions across repositories (!=
structural nesting) hide pending changes of outer transaction, because
current implementation holds only one repository root in HG_PENDING.

How about steps below to fix issues ?

  1. centralize the logic to strictly read pending file according to
     HG_PENDING

     at this point, only simple "dirty read" issue is fixed.

  2. make the logic above aware of transactions across repositories

     maybe, putting concatenated repo roots into HG_PENDING ?


> BTW, I have pending patches to make HG_PENDING check strict by
> centralizing "read file in according to HG_PENDING" logic (as a part
> of followup for DirstateTransactionPlan), in fact. I'll post them,
> soon :-)
> 
> 
> > > _______________________________________________
> > > Mercurial-devel mailing list
> > > Mercurial-devel at mercurial-scm.org
> > > https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
> > 
> 
> -- 
> ----------------------------------------------------------------------
> [FUJIWARA Katsunori]                             foozy at lares.dti.ne.jp
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

-- 
----------------------------------------------------------------------
[FUJIWARA Katsunori]                             foozy at lares.dti.ne.jp


More information about the Mercurial-devel mailing list