No subject


Wed Jan 7 15:56:51 UTC 2009


backward traversal.

BTW, now that I am testing with them hg log, I find it very handy to have the
distance from the last tag. It could give back some landmarks to people used
to central VCS.

> > +            ctx = self.repo[r]
> > +
> > +            tags = [t for t in ctx.tags() if t not in excltags]
> > +            if tags and not (r>= qbase and r<= qtip):
> >    
> 
> This seems to be a very clever way to skip all tags after qbase. 
> Couldn't it be made simpler and more explicit? Perhaps by letting qbase 
> default to sys.maxint?

I will use repo.tagtype(tag) == "global" to simplify all this.
Thanks to Abderrahim for the tips.

> 
> > +                ltmap[r] = ctx.date(), tags[0], 0
> > +            else:
> > +                # trick: use tuple comparison to sort by latest date first
> > +                # and if the dates (and by construction also the tag) are
> > +                # equal, by longuest path.
> >    
> 
> Dates shouldn't be used for anything; they are not guaranteed to be 
> monotonic.
> 
> Matt suggested the name "lasttag", but defined it as "nearest tag". That 
> is also a strong hint that "nearesttag" might be a better name.
> 
> "Nearest tag" hints at a breath-first search through ancestors, stopping 
> at the first tagged node.
> 
> IMHO: If there is more than one possible nearest tag candidate then 
> there is no really good way to decide which one to use. Always using the 
> tipmost tagged ancestor would be fine (and simple and efficient) too.
> 

Matt answered quite nicely about that.
A simple breath first search would not be stable across push/pull order.
The latest tag by date in ancestors ensures more consistent result and probably
closer from the user's expectations.

> > +                lasttag = reduce(max,
> > +                                 [ltmap[p.rev()] for p in ctx.parents()],
> > +                                 defvalue)
> > +                ldate, ltag, ldist = lasttag
> > +                # if no previous tag, nothing to do (leave default value)
> > +                if ltag:
> > +                    ltmap[r] = ldate, ltag, ldist + 1
> > +
> > +        return ltmap
> > +
> >       def use_template(self, t):
> >           '''set template string to use'''
> >           self.t.cache['changeset'] = t
> 





More information about the Mercurial-devel mailing list