Mercurial > hg
view tests/test-custom-filters.t @ 20713:6a1a4c212d50
revset: improve head revset performance
Previously the head() revset would iterate over every item in the subset and
check if it was a head. Since the subset is often the entire repo, this was
slow on large repos. Now we iterate over each item in the head list and check if
it's in the subset, which results in much less work.
hg log -r 'head()' on a large repo:
Before: 0.95s
After: 0.28s
author | Durham Goode <durham@fb.com> |
---|---|
date | Thu, 13 Mar 2014 13:47:21 -0700 |
parents | 4134686b83e1 |
children | 56b2bcea2529 |
line wrap: on
line source
$ hg init $ cat > .hg/hgrc <<EOF > [extensions] > prefixfilter = prefix.py > [encode] > *.txt = stripprefix: Copyright 2046, The Masters > [decode] > *.txt = insertprefix: Copyright 2046, The Masters > EOF $ cat > prefix.py <<EOF > from mercurial import util > def stripprefix(s, cmd, filename, **kwargs): > header = '%s\n' % cmd > if s[:len(header)] != header: > raise util.Abort('missing header "%s" in %s' % (cmd, filename)) > return s[len(header):] > def insertprefix(s, cmd): > return '%s\n%s' % (cmd, s) > def reposetup(ui, repo): > repo.adddatafilter('stripprefix:', stripprefix) > repo.adddatafilter('insertprefix:', insertprefix) > EOF $ cat > .hgignore <<EOF > .hgignore > prefix.py > prefix.pyc > EOF $ cat > stuff.txt <<EOF > Copyright 2046, The Masters > Some stuff to ponder very carefully. > EOF $ hg add stuff.txt $ hg ci -m stuff Repository data: $ hg cat stuff.txt Some stuff to ponder very carefully. Fresh checkout: $ rm stuff.txt $ hg up -C 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ cat stuff.txt Copyright 2046, The Masters Some stuff to ponder very carefully. $ echo "Very very carefully." >> stuff.txt $ hg stat M stuff.txt $ echo "Unauthorized material subject to destruction." > morestuff.txt Problem encoding: $ hg add morestuff.txt $ hg ci -m morestuff abort: missing header "Copyright 2046, The Masters" in morestuff.txt [255] $ hg stat M stuff.txt A morestuff.txt