Mercurial > evolve
annotate hgext3rd/topic/compat.py @ 5617:0d5c344c0ba4 stable
test-compat: back out changeset 4da1d21231ae
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Fri, 08 May 2020 19:22:36 +0800 |
parents | e4c7d4a03de7 |
children | dd9dba7c1d00 |
rev | line source |
---|---|
2922
66357d4d03b2
topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
1 # Copyright 2017 FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
66357d4d03b2
topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
2 # |
66357d4d03b2
topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
3 # This software may be used and distributed according to the terms of the |
66357d4d03b2
topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
4 # GNU General Public License version 2 or any later version. |
66357d4d03b2
topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
5 """ |
66357d4d03b2
topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
6 Compatibility module |
66357d4d03b2
topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
7 """ |
66357d4d03b2
topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
8 from __future__ import absolute_import |
66357d4d03b2
topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
9 |
3094
e11e018e8338
compat: add an abstraction for 'scmutil.cleanupnodes'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3064
diff
changeset
|
10 from mercurial import ( |
4743
92e3db149d7d
py3: call branchmap.items() on py3 and continue to call iteritems() on py2
Martin von Zweigbergk <martinvonz@google.com>
parents:
3701
diff
changeset
|
11 pycompat, |
4894
f9743b13de6d
help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents:
4810
diff
changeset
|
12 registrar, |
4957
e8302f760a54
compat: compatibility for cl.nodemap.get vs cl.index.get_rev
Anton Shestakov <av6@dwimlabs.net>
parents:
4810
diff
changeset
|
13 util, |
3094
e11e018e8338
compat: add an abstraction for 'scmutil.cleanupnodes'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3064
diff
changeset
|
14 ) |
2922
66357d4d03b2
topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
15 |
4743
92e3db149d7d
py3: call branchmap.items() on py3 and continue to call iteritems() on py2
Martin von Zweigbergk <martinvonz@google.com>
parents:
3701
diff
changeset
|
16 if pycompat.ispy3: |
92e3db149d7d
py3: call branchmap.items() on py3 and continue to call iteritems() on py2
Martin von Zweigbergk <martinvonz@google.com>
parents:
3701
diff
changeset
|
17 def branchmapitems(branchmap): |
92e3db149d7d
py3: call branchmap.items() on py3 and continue to call iteritems() on py2
Martin von Zweigbergk <martinvonz@google.com>
parents:
3701
diff
changeset
|
18 return branchmap.items() |
92e3db149d7d
py3: call branchmap.items() on py3 and continue to call iteritems() on py2
Martin von Zweigbergk <martinvonz@google.com>
parents:
3701
diff
changeset
|
19 else: |
4810
03690f8d2b0a
python3: add ignore block around python 2 compatibility if branch
Raphaël Gomès <rgomes@octobus.net>
parents:
4743
diff
changeset
|
20 # py3-transform: off |
4743
92e3db149d7d
py3: call branchmap.items() on py3 and continue to call iteritems() on py2
Martin von Zweigbergk <martinvonz@google.com>
parents:
3701
diff
changeset
|
21 def branchmapitems(branchmap): |
92e3db149d7d
py3: call branchmap.items() on py3 and continue to call iteritems() on py2
Martin von Zweigbergk <martinvonz@google.com>
parents:
3701
diff
changeset
|
22 return branchmap.iteritems() |
4810
03690f8d2b0a
python3: add ignore block around python 2 compatibility if branch
Raphaël Gomès <rgomes@octobus.net>
parents:
4743
diff
changeset
|
23 # py3-transform: on |
4957
e8302f760a54
compat: compatibility for cl.nodemap.get vs cl.index.get_rev
Anton Shestakov <av6@dwimlabs.net>
parents:
4810
diff
changeset
|
24 |
4894
f9743b13de6d
help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents:
4810
diff
changeset
|
25 # help category compatibility |
f9743b13de6d
help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents:
4810
diff
changeset
|
26 # hg <= 4.7 (c303d65d2e34) |
f9743b13de6d
help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents:
4810
diff
changeset
|
27 def helpcategorykwargs(categoryname): |
f9743b13de6d
help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents:
4810
diff
changeset
|
28 """Backwards-compatible specification of the helpategory argument.""" |
f9743b13de6d
help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents:
4810
diff
changeset
|
29 category = getattr(registrar.command, categoryname, None) |
f9743b13de6d
help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents:
4810
diff
changeset
|
30 if not category: |
f9743b13de6d
help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents:
4810
diff
changeset
|
31 return {} |
f9743b13de6d
help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents:
4810
diff
changeset
|
32 return {'helpcategory': category} |
4929
bb2b4f6c99dc
compat: compatibility for cl.nodemap.get vs cl.index.get_rev
Anton Shestakov <av6@dwimlabs.net>
parents:
4894
diff
changeset
|
33 |
4957
e8302f760a54
compat: compatibility for cl.nodemap.get vs cl.index.get_rev
Anton Shestakov <av6@dwimlabs.net>
parents:
4810
diff
changeset
|
34 # nodemap.get and index.[has_node|rev|get_rev] |
5193
a4d081923c81
compat: update hg-X.Y compat comments and test them
Anton Shestakov <av6@dwimlabs.net>
parents:
4963
diff
changeset
|
35 # hg <= 5.2 (02802fa87b74) |
4957
e8302f760a54
compat: compatibility for cl.nodemap.get vs cl.index.get_rev
Anton Shestakov <av6@dwimlabs.net>
parents:
4810
diff
changeset
|
36 def getgetrev(cl): |
e8302f760a54
compat: compatibility for cl.nodemap.get vs cl.index.get_rev
Anton Shestakov <av6@dwimlabs.net>
parents:
4810
diff
changeset
|
37 """Returns index.get_rev or nodemap.get (for pre-5.3 Mercurial).""" |
e8302f760a54
compat: compatibility for cl.nodemap.get vs cl.index.get_rev
Anton Shestakov <av6@dwimlabs.net>
parents:
4810
diff
changeset
|
38 if util.safehasattr(cl.index, 'get_rev'): |
e8302f760a54
compat: compatibility for cl.nodemap.get vs cl.index.get_rev
Anton Shestakov <av6@dwimlabs.net>
parents:
4810
diff
changeset
|
39 return cl.index.get_rev |
e8302f760a54
compat: compatibility for cl.nodemap.get vs cl.index.get_rev
Anton Shestakov <av6@dwimlabs.net>
parents:
4810
diff
changeset
|
40 return cl.nodemap.get |
5429
e4c7d4a03de7
topic: compatibility with sparse phaseroots and phasesets in 5.5
Joerg Sonnenberger <joerg@bec.de>
parents:
5193
diff
changeset
|
41 |
e4c7d4a03de7
topic: compatibility with sparse phaseroots and phasesets in 5.5
Joerg Sonnenberger <joerg@bec.de>
parents:
5193
diff
changeset
|
42 # hg <= 5.4 (e2d17974a869) |
e4c7d4a03de7
topic: compatibility with sparse phaseroots and phasesets in 5.5
Joerg Sonnenberger <joerg@bec.de>
parents:
5193
diff
changeset
|
43 def nonpublicphaseroots(repo): |
e4c7d4a03de7
topic: compatibility with sparse phaseroots and phasesets in 5.5
Joerg Sonnenberger <joerg@bec.de>
parents:
5193
diff
changeset
|
44 if util.safehasattr(repo._phasecache, 'nonpublicphaseroots'): |
e4c7d4a03de7
topic: compatibility with sparse phaseroots and phasesets in 5.5
Joerg Sonnenberger <joerg@bec.de>
parents:
5193
diff
changeset
|
45 return repo._phasecache.nonpublicphaseroots(repo) |
e4c7d4a03de7
topic: compatibility with sparse phaseroots and phasesets in 5.5
Joerg Sonnenberger <joerg@bec.de>
parents:
5193
diff
changeset
|
46 return set().union( |
e4c7d4a03de7
topic: compatibility with sparse phaseroots and phasesets in 5.5
Joerg Sonnenberger <joerg@bec.de>
parents:
5193
diff
changeset
|
47 *[roots for roots in repo._phasecache.phaseroots[1:] if roots] |
e4c7d4a03de7
topic: compatibility with sparse phaseroots and phasesets in 5.5
Joerg Sonnenberger <joerg@bec.de>
parents:
5193
diff
changeset
|
48 ) |