[PATCH 1 of 4 V2] histedit: add a method to cleanup nodes safely

Jun Wu quark at fb.com
Sat Mar 18 11:34:19 EDT 2017


Excerpts from Yuya Nishihara's message of 2017-03-18 14:12:24 +0900:
> On Fri, 17 Mar 2017 20:17:48 -0700, Jun Wu wrote:
> > # HG changeset patch
> > # User Jun Wu <quark at fb.com>
> > # Date 1489464645 25200
> > #      Mon Mar 13 21:10:45 2017 -0700
> > # Node ID 19a0f5164fcd28240327beffc3c90cdddfb17123
> > # Parent  96929bd6e58d29bc3d44e1db7c1283f224bd1dc1
> > # Available At https://bitbucket.org/quark-zju/hg-draft 
> > #              hg pull https://bitbucket.org/quark-zju/hg-draft  -r 19a0f5164fcd
> > histedit: add a method to cleanup nodes safely
> > 
> > The new method will decide between:
> > 
> >   - cleanupnode, which calls the unsafe repair.strip
> >   - create obsmarkers
> > 
> > Ideally, nobody calls "cleanupnode" directly except for "safecleanupnode".
> > 
> > diff --git a/hgext/histedit.py b/hgext/histedit.py
> > --- a/hgext/histedit.py
> > +++ b/hgext/histedit.py
> > @@ -1575,4 +1575,32 @@ def cleanupnode(ui, repo, name, nodes):
> >              repair.strip(ui, repo, c)
> >  
> > +def safecleanupnode(ui, repo, name, nodes):
> > +    """strip or obsolete nodes
> > +
> > +    nodes could be either a set or dict which maps to replacements.
> > +    nodes could be unknown (outside the repo).
> > +    """
> > +    supportsmarkers = obsolete.isenabled(repo, obsolete.createmarkersopt)
> > +    if supportsmarkers:
> > +        if util.safehasattr(nodes, 'get'):
> > +            # nodes is a dict-like mapping
> > +            # use unfiltered repo for successors in case they are hidden
> > +            urepo = repo.unfiltered()
> > +            def getmarker(prec):
> > +                succs = (urepo[n] for n in nodes.get(prec, ()))
> > +                return (repo[prec], succs)
> 
> Still a generator?

Sorry. Was thinking about immutable config stuff. Seems I cannot
multi-thread.


More information about the Mercurial-devel mailing list