annotate hgsubversion/compathacks.py @ 1572:51e105c7f0c6

compathacks: deal with removed aliases in mercurial.util
author Augie Fackler <raf@durin42.com>
date Sun, 27 May 2018 00:29:38 -0400
parents 8410a978c650
children 7bb6562feb85
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1139
d1bd52202c6d compathacks: specify for generic compatibility hacks
Sean Farley <sean.michael.farley@gmail.com>
parents: 1138
diff changeset
1 """Functions to work around API changes."""
1103
6e1dbf6cbc92 compathacks: new module to collect hacks to work around hg internals changing
Augie Fackler <raf@durin42.com>
parents:
diff changeset
2
1237
4ed0855d211f compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents: 1228
diff changeset
3 import errno
4ed0855d211f compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents: 1228
diff changeset
4 import sys
1103
6e1dbf6cbc92 compathacks: new module to collect hacks to work around hg internals changing
Augie Fackler <raf@durin42.com>
parents:
diff changeset
5
1405
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
6 from mercurial import util
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
7
1103
6e1dbf6cbc92 compathacks: new module to collect hacks to work around hg internals changing
Augie Fackler <raf@durin42.com>
parents:
diff changeset
8 def branchset(repo):
1218
68e6927fa387 compathacks: add wrapper for memfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents: 1103
diff changeset
9 """Return the set of branches present in a repo.
68e6927fa387 compathacks: add wrapper for memfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents: 1103
diff changeset
10
68e6927fa387 compathacks: add wrapper for memfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents: 1103
diff changeset
11 Works around branchtags() vanishing between 2.8 and 2.9.
68e6927fa387 compathacks: add wrapper for memfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents: 1103
diff changeset
12 """
68e6927fa387 compathacks: add wrapper for memfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents: 1103
diff changeset
13 try:
68e6927fa387 compathacks: add wrapper for memfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents: 1103
diff changeset
14 return set(repo.branchmap())
68e6927fa387 compathacks: add wrapper for memfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents: 1103
diff changeset
15 except AttributeError:
68e6927fa387 compathacks: add wrapper for memfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents: 1103
diff changeset
16 return set(repo.branchtags())
68e6927fa387 compathacks: add wrapper for memfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents: 1103
diff changeset
17
68e6927fa387 compathacks: add wrapper for memfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents: 1103
diff changeset
18 def pickle_load(f):
68e6927fa387 compathacks: add wrapper for memfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents: 1103
diff changeset
19 import cPickle as pickle
68e6927fa387 compathacks: add wrapper for memfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents: 1103
diff changeset
20 f.seek(0)
68e6927fa387 compathacks: add wrapper for memfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents: 1103
diff changeset
21 return pickle.load(f)
68e6927fa387 compathacks: add wrapper for memfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents: 1103
diff changeset
22
1549
8410a978c650 compathacks: be compatible with upstream 8a0cac20a1ad memfilectx change
Jun Wu <quark@fb.com>
parents: 1405
diff changeset
23 def makememfilectx(repo, memctx, path, data, islink, isexec, copied):
1218
68e6927fa387 compathacks: add wrapper for memfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents: 1103
diff changeset
24 """Return a memfilectx
68e6927fa387 compathacks: add wrapper for memfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents: 1103
diff changeset
25
1549
8410a978c650 compathacks: be compatible with upstream 8a0cac20a1ad memfilectx change
Jun Wu <quark@fb.com>
parents: 1405
diff changeset
26 Works around API change by 8a0cac20a1ad (first in 4.5).
1218
68e6927fa387 compathacks: add wrapper for memfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents: 1103
diff changeset
27 """
68e6927fa387 compathacks: add wrapper for memfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents: 1103
diff changeset
28 from mercurial import context
68e6927fa387 compathacks: add wrapper for memfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents: 1103
diff changeset
29 try:
1549
8410a978c650 compathacks: be compatible with upstream 8a0cac20a1ad memfilectx change
Jun Wu <quark@fb.com>
parents: 1405
diff changeset
30 return context.memfilectx(repo=repo, path=path, data=data,
8410a978c650 compathacks: be compatible with upstream 8a0cac20a1ad memfilectx change
Jun Wu <quark@fb.com>
parents: 1405
diff changeset
31 islink=islink, isexec=isexec, copied=copied,
8410a978c650 compathacks: be compatible with upstream 8a0cac20a1ad memfilectx change
Jun Wu <quark@fb.com>
parents: 1405
diff changeset
32 changectx=memctx)
1218
68e6927fa387 compathacks: add wrapper for memfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents: 1103
diff changeset
33 except TypeError:
1549
8410a978c650 compathacks: be compatible with upstream 8a0cac20a1ad memfilectx change
Jun Wu <quark@fb.com>
parents: 1405
diff changeset
34 return context.memfilectx(repo=repo, path=path, data=data,
8410a978c650 compathacks: be compatible with upstream 8a0cac20a1ad memfilectx change
Jun Wu <quark@fb.com>
parents: 1405
diff changeset
35 islink=islink, isexec=isexec, copied=copied)
1237
4ed0855d211f compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents: 1228
diff changeset
36
4ed0855d211f compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents: 1228
diff changeset
37 def filectxfn_deleted(memctx, path):
4ed0855d211f compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents: 1228
diff changeset
38 """
4ed0855d211f compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents: 1228
diff changeset
39 Return None or raise an IOError as necessary if path is deleted.
4ed0855d211f compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents: 1228
diff changeset
40
4ed0855d211f compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents: 1228
diff changeset
41 Call as:
4ed0855d211f compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents: 1228
diff changeset
42
4ed0855d211f compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents: 1228
diff changeset
43 if path_missing:
4ed0855d211f compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents: 1228
diff changeset
44 return compathacks.filectxfn_deleted(memctx, path)
4ed0855d211f compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents: 1228
diff changeset
45
4ed0855d211f compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents: 1228
diff changeset
46 Works around filectxfn's contract changing between 3.1 and 3.2: 3.2 onwards,
4ed0855d211f compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents: 1228
diff changeset
47 for deleted files, filectxfn should return None rather than returning
4ed0855d211f compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents: 1228
diff changeset
48 IOError.
4ed0855d211f compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents: 1228
diff changeset
49 """
4ed0855d211f compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents: 1228
diff changeset
50 if getattr(memctx, '_returnnoneformissingfiles', False):
4ed0855d211f compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents: 1228
diff changeset
51 return None
4ed0855d211f compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents: 1228
diff changeset
52 raise IOError(errno.ENOENT, '%s is deleted' % path)
4ed0855d211f compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents: 1228
diff changeset
53
4ed0855d211f compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents: 1228
diff changeset
54 def filectxfn_deleted_reraise(memctx):
4ed0855d211f compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents: 1228
diff changeset
55 """
4ed0855d211f compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents: 1228
diff changeset
56 Return None or reraise exc as necessary.
4ed0855d211f compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents: 1228
diff changeset
57
4ed0855d211f compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents: 1228
diff changeset
58 Call as:
4ed0855d211f compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents: 1228
diff changeset
59
4ed0855d211f compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents: 1228
diff changeset
60 try:
4ed0855d211f compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents: 1228
diff changeset
61 # code that raises IOError if the path is missing
4ed0855d211f compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents: 1228
diff changeset
62 except IOError:
4ed0855d211f compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents: 1228
diff changeset
63 return compathacks.filectxfn_deleted_reraise(memctx)
4ed0855d211f compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents: 1228
diff changeset
64
4ed0855d211f compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents: 1228
diff changeset
65 Works around filectxfn's contract changing between 3.1 and 3.2: 3.2 onwards,
4ed0855d211f compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents: 1228
diff changeset
66 for deleted files, filectxfn should return None rather than returning
4ed0855d211f compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents: 1228
diff changeset
67 IOError.
4ed0855d211f compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents: 1228
diff changeset
68 """
4ed0855d211f compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents: 1228
diff changeset
69 exc_info = sys.exc_info()
4ed0855d211f compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents: 1228
diff changeset
70 if (exc_info[1].errno == errno.ENOENT and
4ed0855d211f compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents: 1228
diff changeset
71 getattr(memctx, '_returnnoneformissingfiles', False)):
4ed0855d211f compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents: 1228
diff changeset
72 return None
4ed0855d211f compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents: 1228
diff changeset
73 # preserve traceback info
4ed0855d211f compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents: 1228
diff changeset
74 raise exc_info[0], exc_info[1], exc_info[2]
1405
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
75
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
76 # copied from hg 3.8
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
77 class _funcregistrarbase(object):
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
78 """Base of decorator to register a fuction for specific purpose
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
79
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
80 This decorator stores decorated functions into own dict 'table'.
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
81
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
82 The least derived class can be defined by overriding 'formatdoc',
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
83 for example::
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
84
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
85 class keyword(_funcregistrarbase):
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
86 _docformat = ":%s: %s"
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
87
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
88 This should be used as below:
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
89
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
90 keyword = registrar.keyword()
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
91
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
92 @keyword('bar')
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
93 def barfunc(*args, **kwargs):
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
94 '''Explanation of bar keyword ....
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
95 '''
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
96 pass
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
97
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
98 In this case:
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
99
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
100 - 'barfunc' is stored as 'bar' in '_table' of an instance 'keyword' above
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
101 - 'barfunc.__doc__' becomes ":bar: Explanation of bar keyword"
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
102 """
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
103 def __init__(self, table=None):
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
104 if table is None:
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
105 self._table = {}
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
106 else:
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
107 self._table = table
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
108
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
109 def __call__(self, decl, *args, **kwargs):
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
110 return lambda func: self._doregister(func, decl, *args, **kwargs)
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
111
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
112 def _doregister(self, func, decl, *args, **kwargs):
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
113 name = self._getname(decl)
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
114
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
115 if func.__doc__ and not util.safehasattr(func, '_origdoc'):
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
116 doc = func.__doc__.strip()
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
117 func._origdoc = doc
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
118 func.__doc__ = self._formatdoc(decl, doc)
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
119
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
120 self._table[name] = func
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
121 self._extrasetup(name, func, *args, **kwargs)
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
122
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
123 return func
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
124
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
125 def _parsefuncdecl(self, decl):
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
126 """Parse function declaration and return the name of function in it
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
127 """
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
128 i = decl.find('(')
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
129 if i >= 0:
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
130 return decl[:i]
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
131 else:
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
132 return decl
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
133
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
134 def _getname(self, decl):
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
135 """Return the name of the registered function from decl
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
136
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
137 Derived class should override this, if it allows more
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
138 descriptive 'decl' string than just a name.
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
139 """
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
140 return decl
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
141
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
142 _docformat = None
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
143
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
144 def _formatdoc(self, decl, doc):
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
145 """Return formatted document of the registered function for help
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
146
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
147 'doc' is '__doc__.strip()' of the registered function.
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
148 """
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
149 return self._docformat % (decl, doc)
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
150
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
151 def _extrasetup(self, name, func):
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
152 """Execute exra setup for registered function, if needed
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
153 """
c5b7fb8911c0 compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents: 1237
diff changeset
154 pass
1572
51e105c7f0c6 compathacks: deal with removed aliases in mercurial.util
Augie Fackler <raf@durin42.com>
parents: 1549
diff changeset
155
51e105c7f0c6 compathacks: deal with removed aliases in mercurial.util
Augie Fackler <raf@durin42.com>
parents: 1549
diff changeset
156 try:
51e105c7f0c6 compathacks: deal with removed aliases in mercurial.util
Augie Fackler <raf@durin42.com>
parents: 1549
diff changeset
157 binary = util.binary
51e105c7f0c6 compathacks: deal with removed aliases in mercurial.util
Augie Fackler <raf@durin42.com>
parents: 1549
diff changeset
158 except AttributeError:
51e105c7f0c6 compathacks: deal with removed aliases in mercurial.util
Augie Fackler <raf@durin42.com>
parents: 1549
diff changeset
159 from mercurial.utils import stringutil
51e105c7f0c6 compathacks: deal with removed aliases in mercurial.util
Augie Fackler <raf@durin42.com>
parents: 1549
diff changeset
160 binary = stringutil.binary
51e105c7f0c6 compathacks: deal with removed aliases in mercurial.util
Augie Fackler <raf@durin42.com>
parents: 1549
diff changeset
161
51e105c7f0c6 compathacks: deal with removed aliases in mercurial.util
Augie Fackler <raf@durin42.com>
parents: 1549
diff changeset
162 try:
51e105c7f0c6 compathacks: deal with removed aliases in mercurial.util
Augie Fackler <raf@durin42.com>
parents: 1549
diff changeset
163 datestr = util.datestr
51e105c7f0c6 compathacks: deal with removed aliases in mercurial.util
Augie Fackler <raf@durin42.com>
parents: 1549
diff changeset
164 except AttributeError:
51e105c7f0c6 compathacks: deal with removed aliases in mercurial.util
Augie Fackler <raf@durin42.com>
parents: 1549
diff changeset
165 from mercurial.utils import dateutil
51e105c7f0c6 compathacks: deal with removed aliases in mercurial.util
Augie Fackler <raf@durin42.com>
parents: 1549
diff changeset
166 datestr = dateutil.datestr