Subclassing notify
Benoit Boissinot
benoit.boissinot at ens-lyon.org
Sat Apr 4 07:06:43 CDT 2009
On Fri, Apr 03, 2009 at 07:17:05PM +0200, Ulrich Pfeifer wrote:
> Hello,
>
> I tried to subclass notify to overwrite the part displaying a single
> change set in the incoming hook:
>
> else:
> count = 1
> n.node(node)
> - n.diff(node, node)
> + n.diff_single(node)
> data = ui.popbuffer()
> n.send(node, count, data)
>
> were diff_single differs from diff by this:
>
> - def diff(self, node, ref):
> + def diff_single(self, node):
> maxdiff = int(self.ui.config('notify', 'maxdiff', 300))
> prev = self.repo.changelog.parents(node)[0]
>
> - chunks = patch.diff(self.repo, prev, ref,
> opts=patch.diffopts(self.ui))
> + chunks = patch.diff(self.repo, prev, node,
> opts=patch.diffopts(self.ui))
> difflines = ''.join(chunks).splitlines()
>
> + if len(self.repo.changelog.parents(node)) > 1:
> + right = self.repo.changelog.parents(node)[1]
> + chunks = patch.diff(self.repo, right, node,
> opts=patch.diffopts(self.ui))
> + difflines_right = ''.join(chunks).splitlines()
> + self.ui.debug(_('\nleft=%s right=%s\nLeft %d lines, right
> %d lines\n') % (short(prev), short(right), len(difflines),
> len(difflines_right)))
> + if len(difflines_right) < len(difflines):
> + difflines = difflines_right
> +
> if self.ui.configbool('notify', 'diffstat', True):
> s = patch.diffstat(difflines)
> # s may be nil, don't include the header if it is
> if s:
>
> Basically in the merge case this is emitting the shorter diff. This
> is far from perfect - but a start of what I wanted to do.
>
> My problem now is, that with a fairly big repository (manifest has
> about 65mb) the hg process bloats to above 750mb main memory.
The diff to the other parent can be really huge, can you check if this
is a leak (is the memory recovered when exiting the function).
Otherwise you could try:
- an heuristic based on the DAG (how far are the parents from the least
common ancestor)
- use the size of the binary diff instead of building a "real" textual
diff.
regards,
Benoit
--
:wq
More information about the Mercurial
mailing list