mercurial/pushkey.py
author Joel Rosdahl <joel@rosdahl.net>
Thu, 08 Jul 2010 22:44:15 +0200
branchstable
changeset 11562 efbc09fdefd8
parent 11367 ca4fc993087c
child 13353 689bf32b3bbd
permissions -rw-r--r--
test-log: Add test for "hg log -pf" (issue647) To test f786fc4b8764 we analyze this repo: 0 | 1 | 2 | 3 | 4 a ------------> b \ b -> dir/b -------> e d We follow dir/b and expects rev 0, 1 and 2. A log following b will surprisingly report rev 0 and 1. That's because the content and the parents are the same in rev 1 and rev 3, and the revlog entry from rev 1 is thus reused in rev 3 even though the revlink is incorrect. Note that if we follow e then we will get all revs, including rev 3, because b gets added to the set of interesting filenames we are following through all revisions. That might be surprising, but that's (currently) how it is. Original test case by Joel Rosdahl <joel@rosdahl.net> Original test reviewed by Nicolas Dumazet <nicdumz@gmail.com>

# pushkey.py - dispatching for pushing and pulling keys
#
# Copyright 2010 Matt Mackall <mpm@selenic.com>
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.

def _nslist(repo):
    n = {}
    for k in _namespaces:
        n[k] = ""
    return n

_namespaces = {"namespaces": (lambda *x: False, _nslist)}

def register(namespace, pushkey, listkeys):
    _namespaces[namespace] = (pushkey, listkeys)

def _get(namespace):
    return _namespaces.get(namespace, (lambda *x: False, lambda *x: {}))

def push(repo, namespace, key, old, new):
    '''should succeed iff value was old'''
    pk = _get(namespace)[0]
    return pk(repo, key, old, new)

def list(repo, namespace):
    '''return a dict'''
    lk = _get(namespace)[1]
    return lk(repo)