Mercurial > hg
annotate tests/revnamesext.py @ 33299:41448fc51510
sparse: variable to track if sparse is enabled
Currently, the sparse extension sniffs repo instances for
attributes defined by the sparse extension to determine if
sparse is enabled. As we move code away from repo instances,
these checks will be a bit more brittle.
We introduce a module-level variable to track whether sparse is
enabled as a temporary workaround.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Thu, 06 Jul 2017 12:06:37 -0700 |
parents | 46fa46608ca5 |
children | 086fc71fbb09 |
rev | line source |
---|---|
33048
46fa46608ca5
namespaces: record and expose whether namespace is built-in
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1 # Dummy extension to define a namespace containing revision names |
46fa46608ca5
namespaces: record and expose whether namespace is built-in
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
2 |
46fa46608ca5
namespaces: record and expose whether namespace is built-in
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
3 from __future__ import absolute_import |
46fa46608ca5
namespaces: record and expose whether namespace is built-in
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
4 |
46fa46608ca5
namespaces: record and expose whether namespace is built-in
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
5 from mercurial import ( |
46fa46608ca5
namespaces: record and expose whether namespace is built-in
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
6 namespaces, |
46fa46608ca5
namespaces: record and expose whether namespace is built-in
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
7 ) |
46fa46608ca5
namespaces: record and expose whether namespace is built-in
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
8 |
46fa46608ca5
namespaces: record and expose whether namespace is built-in
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
9 def reposetup(ui, repo): |
46fa46608ca5
namespaces: record and expose whether namespace is built-in
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
10 names = {'r%d' % rev: repo[rev].node() for rev in repo} |
46fa46608ca5
namespaces: record and expose whether namespace is built-in
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
11 namemap = lambda r, name: names.get(name) |
46fa46608ca5
namespaces: record and expose whether namespace is built-in
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
12 nodemap = lambda r, node: ['r%d' % repo[node].rev()] |
46fa46608ca5
namespaces: record and expose whether namespace is built-in
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
13 |
46fa46608ca5
namespaces: record and expose whether namespace is built-in
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
14 ns = namespaces.namespace('revnames', templatename='revname', |
46fa46608ca5
namespaces: record and expose whether namespace is built-in
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
15 logname='revname', |
46fa46608ca5
namespaces: record and expose whether namespace is built-in
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
16 listnames=lambda r: names.keys(), |
46fa46608ca5
namespaces: record and expose whether namespace is built-in
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
17 namemap=namemap, nodemap=nodemap) |
46fa46608ca5
namespaces: record and expose whether namespace is built-in
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
18 repo.names.addnamespace(ns) |