Mercurial > hg
view contrib/builddeb @ 27784:432242f41d9f
obsolete: make _computeobsoleteset much faster
This patch makes _computeobsoleteset much faster by looping
over the draft and secrets as opposed to looping over the
successors.
This works because "number of draft and secret" is typically
way smaller(<100) than the number of successor in the repo (~90k in
my checkout of core mercurial as of today). And also because
it is very fast to compute "not public()".
I timed the code with the following setup:
"""
from mercurial import hg, ui, obsolete
ui = ui.ui()
repo = hg.repository(ui, "~/hg")
l = repo.obsstore.successors # This caches the result
"""
With about 90k successors.
k=obsolete._computeobsoleteset(repo) before this patch:
10 loops, best of 3: 33.9 ms per loop
k=obsolete._computeobsoleteset(repo) after this patch:
10000 loops, best of 3: 83.3 µs per loop
author | Laurent Charignon <lc2817@columbia.edu> |
---|---|
date | Wed, 13 Jan 2016 21:52:26 -0800 |
parents | ef9301ce6046 |
children | 4f1dac94b53f |
line wrap: on
line source
#!/bin/sh -e # # Build a Mercurial debian package from the current repo # # Tested on Jessie (stable as of original script authoring.) . $(dirname $0)/packagelib.sh BUILD=1 CLEANUP=1 DISTID=`(lsb_release -is 2> /dev/null | tr '[:upper:]' '[:lower:]') || echo debian` CODENAME=`lsb_release -cs 2> /dev/null || echo unknown` while [ "$1" ]; do case "$1" in --distid ) shift DISTID="$1" shift ;; --codename ) shift CODENAME="$1" shift ;; --cleanup ) shift BUILD= ;; --build ) shift CLEANUP= ;; * ) echo "Invalid parameter $1!" 1>&2 exit 1 ;; esac done trap "if [ '$CLEANUP' ] ; then rm -r '$PWD/debian' ; fi" EXIT set -u if [ ! -d .hg ]; then echo 'You are not inside a Mercurial repository!' 1>&2 exit 1 fi gethgversion debver="$version" if [ -n "$type" ] ; then debver="$debver~$type" fi if [ -n "$distance" ] ; then debver="$debver+$distance-$node" fi control=debian/control changelog=debian/changelog if [ "$BUILD" ]; then if [ -d debian ] ; then echo "Error! debian control directory already exists!" exit 1 fi cp -r $PWD/contrib/debian debian chmod -R 0755 debian # This looks like sed -i, but sed -i behaves just differently enough # between BSD and GNU sed that I gave up and did the dumb thing. sed "s/__VERSION__/$debver/" < $changelog > $changelog.tmp date=$(date --rfc-2822) sed "s/__DATE__/$date/" < $changelog.tmp > $changelog rm $changelog.tmp debuild -us -uc -b if [ $? != 0 ]; then echo 'debuild failed!' exit 1 fi fi if [ "$CLEANUP" ] ; then echo OUTPUTDIR=${OUTPUTDIR:=packages/$DISTID-$CODENAME} mkdir -p "$OUTPUTDIR" find ../mercurial*.deb ../mercurial_*.build ../mercurial_*.changes \ -type f -newer $control -print0 | \ xargs -Inarf -0 mv narf "$OUTPUTDIR" echo "Built packages for $debver:" find "$OUTPUTDIR" -type f -newer $control -name '*.deb' fi