diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1349,7 +1349,7 @@ def commit(ui, repo, *pats, **opts): if not opts.get('close_branch'): for r in parents: - if r.extra().get('close') and r.branch() == branch: + if r.closesbranch() and r.branch() == branch: ui.status(_('reopening closed branch head %d\n') % r) if ui.debugflag: @@ -5414,7 +5414,7 @@ def summary(ui, repo, **opts): t += _(' (merge)') elif branch != parents[0].branch(): t += _(' (new branch)') - elif (parents[0].extra().get('close') and + elif (parents[0].closesbranch() and pnode in repo.branchheads(branch, closed=True)): t += _(' (head closed)') elif not (st[0] or st[1] or st[2] or st[3] or st[4] or st[9]): diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -186,6 +186,8 @@ class changectx(object): return self._changeset[4] def branch(self): return encoding.tolocal(self._changeset[5].get("branch")) + def closesbranch(self): + return 'close' in self._changeset[5] def extra(self): return self._changeset[5] def tags(self): @@ -895,6 +897,8 @@ class workingctx(changectx): return self._clean def branch(self): return encoding.tolocal(self._extra['branch']) + def closesbranch(self): + return 'close' in self._extra def extra(self): return self._extra diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py +++ b/mercurial/hgweb/webcommands.py @@ -441,7 +441,7 @@ def branches(web, req, tmpl): tips = (web.repo[n] for t, n in web.repo.branchtags().iteritems()) heads = web.repo.heads() parity = paritygen(web.stripecount) - sortkey = lambda ctx: ('close' not in ctx.extra(), ctx.rev()) + sortkey = lambda ctx: (not ctx.closesbranch(), ctx.rev()) def entries(limit, **map): count = 0 diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -511,7 +511,7 @@ class localrepository(repo.repository): '''return the tipmost branch head in heads''' tip = heads[-1] for h in reversed(heads): - if 'close' not in self.changelog.read(h)[5]: + if not self[h].closesbranch(): tip = h break return tip @@ -1555,8 +1555,7 @@ class localrepository(repo.repository): fbheads = set(self.changelog.nodesbetween([start], bheads)[2]) bheads = [h for h in bheads if h in fbheads] if not closed: - bheads = [h for h in bheads if - ('close' not in self.changelog.read(h)[5])] + bheads = [h for h in bheads if not self[h].closesbranch()] return bheads def branches(self, nodes): @@ -2206,7 +2205,7 @@ class localrepository(repo.repository): heads = cl.heads() dh = len(heads) - len(oldheads) for h in heads: - if h not in oldheads and 'close' in self[h].extra(): + if h not in oldheads and self[h].closesbranch(): dh -= 1 htext = "" if dh: diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -395,7 +395,7 @@ def closed(repo, subset, x): """ # i18n: "closed" is a keyword getargs(x, 0, 0, _("closed takes no arguments")) - return [r for r in subset if repo[r].extra().get('close')] + return [r for r in subset if repo[r].closesbranch()] def contains(repo, subset, x): """``contains(pattern)``