author | Alexander Sauta <demosito@gmail.com> |
Tue, 31 Jan 2012 12:30:54 +0400 | |
branch | stable |
changeset 16045 | 0f99e709ce08 |
parent 15648 | 79cc89de5be1 |
child 17075 | 28ed1c4511ce |
permissions | -rw-r--r-- |
11367 | 1 |
# pushkey.py - dispatching for pushing and pulling keys |
2 |
# |
|
3 |
# Copyright 2010 Matt Mackall <mpm@selenic.com> |
|
4 |
# |
|
5 |
# This software may be used and distributed according to the terms of the |
|
6 |
# GNU General Public License version 2 or any later version. |
|
7 |
||
15648
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
13353
diff
changeset
|
8 |
import bookmarks, phases |
13353
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
11367
diff
changeset
|
9 |
|
11367 | 10 |
def _nslist(repo): |
11 |
n = {} |
|
12 |
for k in _namespaces: |
|
13 |
n[k] = "" |
|
14 |
return n |
|
15 |
||
13353
689bf32b3bbd
bookmarks: move pushkey functions into core
Matt Mackall <mpm@selenic.com>
parents:
11367
diff
changeset
|
16 |
_namespaces = {"namespaces": (lambda *x: False, _nslist), |
15648
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
13353
diff
changeset
|
17 |
"bookmarks": (bookmarks.pushbookmark, bookmarks.listbookmarks), |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
13353
diff
changeset
|
18 |
"phases": (phases.pushphase, phases.listphases), |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
13353
diff
changeset
|
19 |
} |
11367 | 20 |
|
21 |
def register(namespace, pushkey, listkeys): |
|
22 |
_namespaces[namespace] = (pushkey, listkeys) |
|
23 |
||
24 |
def _get(namespace): |
|
25 |
return _namespaces.get(namespace, (lambda *x: False, lambda *x: {})) |
|
26 |
||
27 |
def push(repo, namespace, key, old, new): |
|
28 |
'''should succeed iff value was old''' |
|
29 |
pk = _get(namespace)[0] |
|
30 |
return pk(repo, key, old, new) |
|
31 |
||
32 |
def list(repo, namespace): |
|
33 |
'''return a dict''' |
|
34 |
lk = _get(namespace)[1] |
|
35 |
return lk(repo) |
|
36 |