tests/test-hg-parseurl.py
author Durham Goode <durham@fb.com>
Mon, 07 Mar 2016 17:26:47 -0800
changeset 28364 f1460af18c50
parent 13897 375872fdadba
child 28745 8a23f88131c3
permissions -rw-r--r--
branchmap: check node against changelog instead of repo Testing 'node in repo' requires constructing a changectx, which is a little expensive. Testing 'repo.changelog.hasnode(node)' is notably faster. This saves 10-20ms off of every command, when testing a few thousand nodes from the branch cache. I considered changing the implementation of localrepository.__contains__ so every place would benefit from the change, but since localrepository.__contains__ uses changectx to check if the commit exists, it means it supports a wider range of possible inputs (like revs, hashes, '.', etc), so it seemed unnecessarily risky.

from mercurial.hg import parseurl

def testparse(url, branch=[]):
    print '%s, branches: %r' % parseurl(url, branch)

testparse('http://example.com/no/anchor')
testparse('http://example.com/an/anchor#foo')
testparse('http://example.com/no/anchor/branches', branch=['foo'])
testparse('http://example.com/an/anchor/branches#bar', branch=['foo'])
testparse('http://example.com/an/anchor/branches-None#foo', branch=None)
testparse('http://example.com/')
testparse('http://example.com')
testparse('http://example.com#foo')