author | Rodrigo Damazio <rdamazio@google.com> |
Sun, 06 Oct 2019 02:30:12 -0400 | |
changeset 4894 | f9743b13de6d |
parent 4810 | 03690f8d2b0a |
child 4929 | bb2b4f6c99dc |
permissions | -rw-r--r-- |
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 ( |
e11e018e8338
compat: add an abstraction for 'scmutil.cleanupnodes'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3064
diff
changeset
|
11 |
obsolete, |
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
|
12 |
pycompat, |
4894
f9743b13de6d
help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents:
4810
diff
changeset
|
13 |
registrar, |
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 |
|
66357d4d03b2
topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
16 |
getmarkers = None |
66357d4d03b2
topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
17 |
successorssets = None |
66357d4d03b2
topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
18 |
try: |
66357d4d03b2
topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
19 |
from mercurial import obsutil |
66357d4d03b2
topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
20 |
getmarkers = getattr(obsutil, 'getmarkers', None) |
66357d4d03b2
topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
21 |
successorssets = getattr(obsutil, 'successorssets', None) |
66357d4d03b2
topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
22 |
except ImportError: |
66357d4d03b2
topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
23 |
pass |
66357d4d03b2
topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
24 |
|
66357d4d03b2
topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
25 |
if getmarkers is None: |
66357d4d03b2
topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
26 |
getmarkers = obsolete.getmarkers |
66357d4d03b2
topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
27 |
if successorssets is None: |
66357d4d03b2
topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff
changeset
|
28 |
successorssets = obsolete.successorssets |
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
|
29 |
|
92e3db149d7d
py3: call branchmap.items() on py3 and continue to call iteritems() on py2
Martin von Zweigbergk <martinvonz@google.com>
parents:
3701
diff
changeset
|
30 |
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
|
31 |
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
|
32 |
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
|
33 |
else: |
4810
03690f8d2b0a
python3: add ignore block around python 2 compatibility if branch
Raphaël Gomès <rgomes@octobus.net>
parents:
4743
diff
changeset
|
34 |
# 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
|
35 |
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
|
36 |
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
|
37 |
# py3-transform: on |
4894
f9743b13de6d
help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents:
4810
diff
changeset
|
38 |
|
f9743b13de6d
help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents:
4810
diff
changeset
|
39 |
# help category compatibility |
f9743b13de6d
help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents:
4810
diff
changeset
|
40 |
# hg <= 4.7 (c303d65d2e34) |
f9743b13de6d
help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents:
4810
diff
changeset
|
41 |
def helpcategorykwargs(categoryname): |
f9743b13de6d
help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents:
4810
diff
changeset
|
42 |
"""Backwards-compatible specification of the helpategory argument.""" |
f9743b13de6d
help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents:
4810
diff
changeset
|
43 |
category = getattr(registrar.command, categoryname, None) |
f9743b13de6d
help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents:
4810
diff
changeset
|
44 |
if not category: |
f9743b13de6d
help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents:
4810
diff
changeset
|
45 |
return {} |
f9743b13de6d
help: categorizing evolve and topic commands
Rodrigo Damazio <rdamazio@google.com>
parents:
4810
diff
changeset
|
46 |
return {'helpcategory': category} |