> > > class releasenotessections(object): > > - def __init__(self, ui): > > - # TODO support defining custom sections from config. > > - self._sections = list(DEFAULT_SECTIONS) > > + def __init__(self, repo, revs, ui): > > + custom_sections = self.getcustomadmonitions(repo, revs, ui) > > + if custom_sections: > > + self._sections = custom_sections > > + else: > > + self._sections = list(DEFAULT_SECTIONS) + custom_sections > ^^^^^^^^^^^^^^^ > > Here custom_sections is empty, right?
Yes. I made a mistake here. For the if condition I'll take the summation of both of them and else would just have default_sections. Later, I'll just override the key, value pairs in case there is something common between the two. > > + custom_sections = list() > > + for rev in revs: > > + ctx = repo[rev] > > What do you want to do here? Processing all revs or just taking the last > rev? > I was discussing this with Pulkit. And just repo['.'] would be enough here. > > > + p = config.config() > > + repo = ctx.repo() > > + > > + def read(f, sections=None, remap=None): > > + if f in ctx: > > + try: > > + data = ctx[f].data() > > + > > + except IOError as err: > > + if err.errno != errno.ENOENT: > > + raise > > + ui.warn(_("warning: .hgadmonitions file \'%s\' not > found\n") % > > + repo.pathto(f)) > > + return > > + p.parse(f, data, sections, remap, read) > > + sectiondict = p.__getitem__(sections) > ^^^^^^^^^^^^^^^^^^^^^^^ > p[sections] > > BTW, this sections should not be the same as the sections passed to > parse(). > Perhaps, you would just need to parse the all sections in config file, and > pick the one you want. > Yes. This is a better approach. That way I can use it in case we plan to add other type of configs also. > p.parse(src, data) > return p.items('releasenotes.sections') > > > + sectionlist = list() > > + for key, value in sectiondict.iteritems(): > > + temp = (key, value) > > + sectionlist.append(temp) > > + else: > > + raise error.Abort(_(".hgadmonitions file \'%s\' not > found") % > > + repo.pathto(f)) > > + return sectionlist > > + if '.hgadmonitions' in ctx: > > + custom_sections = read('.hgadmonitions', > 'releasenotes.sections') > > .hgadmonitions sounds too obscure. .hgreleasenotes is probably better, and > the section name could be just [sections] or [admonitions]. > > > + return custom_sections > > + > > def parsenotesfromrevisions(repo, directives, revs): > > notes = parsedreleasenotes() > > > > @@ -396,9 +432,9 @@ > > that file. A particular use case for this is to tweak the wording > of a > > release note after it has been added to the release notes file. > > """ > > - sections = releasenotessections(ui) > > + revs = scmutil.revrange(repo, [rev or 'not public()']) > > > > - revs = scmutil.revrange(repo, [rev or 'not public()']) > > + sections = releasenotessections(repo, revs, ui) > > I doubt it's correct to read all .hgadmonitions files. Maybe we would > simply > want to use the latest config for the revision you're generating a release > note? > I guess now that I'll use repo['.'] this problem is answered. > > > - > > + print(incoming) > > :) > > Oops! Totally forgot about it. And, can you write some tests? Sure. ᐧ
_______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel