Mercurial > hgsubversion
annotate hgsubversion/compathacks.py @ 1599:7bb6562feb85
compathacks: drop branchset() which is compat code for hg<2.9
author | Pulkit Goyal <pulkit@yandex-team.ru> |
---|---|
date | Tue, 27 Nov 2018 14:08:11 +0300 |
parents | 51e105c7f0c6 |
children | 5d8603f080c5 |
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 |
1218
68e6927fa387
compathacks: add wrapper for memfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
1103
diff
changeset
|
8 def pickle_load(f): |
68e6927fa387
compathacks: add wrapper for memfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
1103
diff
changeset
|
9 import cPickle as pickle |
68e6927fa387
compathacks: add wrapper for memfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
1103
diff
changeset
|
10 f.seek(0) |
68e6927fa387
compathacks: add wrapper for memfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
1103
diff
changeset
|
11 return pickle.load(f) |
68e6927fa387
compathacks: add wrapper for memfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
1103
diff
changeset
|
12 |
1549
8410a978c650
compathacks: be compatible with upstream 8a0cac20a1ad memfilectx change
Jun Wu <quark@fb.com>
parents:
1405
diff
changeset
|
13 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
|
14 """Return a memfilectx |
68e6927fa387
compathacks: add wrapper for memfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
1103
diff
changeset
|
15 |
1549
8410a978c650
compathacks: be compatible with upstream 8a0cac20a1ad memfilectx change
Jun Wu <quark@fb.com>
parents:
1405
diff
changeset
|
16 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
|
17 """ |
68e6927fa387
compathacks: add wrapper for memfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
1103
diff
changeset
|
18 from mercurial import context |
68e6927fa387
compathacks: add wrapper for memfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
1103
diff
changeset
|
19 try: |
1549
8410a978c650
compathacks: be compatible with upstream 8a0cac20a1ad memfilectx change
Jun Wu <quark@fb.com>
parents:
1405
diff
changeset
|
20 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
|
21 islink=islink, isexec=isexec, copied=copied, |
8410a978c650
compathacks: be compatible with upstream 8a0cac20a1ad memfilectx change
Jun Wu <quark@fb.com>
parents:
1405
diff
changeset
|
22 changectx=memctx) |
1218
68e6927fa387
compathacks: add wrapper for memfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
1103
diff
changeset
|
23 except TypeError: |
1549
8410a978c650
compathacks: be compatible with upstream 8a0cac20a1ad memfilectx change
Jun Wu <quark@fb.com>
parents:
1405
diff
changeset
|
24 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
|
25 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
|
26 |
4ed0855d211f
compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents:
1228
diff
changeset
|
27 def filectxfn_deleted(memctx, path): |
4ed0855d211f
compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents:
1228
diff
changeset
|
28 """ |
4ed0855d211f
compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents:
1228
diff
changeset
|
29 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
|
30 |
4ed0855d211f
compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents:
1228
diff
changeset
|
31 Call as: |
4ed0855d211f
compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents:
1228
diff
changeset
|
32 |
4ed0855d211f
compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents:
1228
diff
changeset
|
33 if path_missing: |
4ed0855d211f
compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents:
1228
diff
changeset
|
34 return compathacks.filectxfn_deleted(memctx, path) |
4ed0855d211f
compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents:
1228
diff
changeset
|
35 |
4ed0855d211f
compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents:
1228
diff
changeset
|
36 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
|
37 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
|
38 IOError. |
4ed0855d211f
compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents:
1228
diff
changeset
|
39 """ |
4ed0855d211f
compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents:
1228
diff
changeset
|
40 if getattr(memctx, '_returnnoneformissingfiles', False): |
4ed0855d211f
compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents:
1228
diff
changeset
|
41 return None |
4ed0855d211f
compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents:
1228
diff
changeset
|
42 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
|
43 |
4ed0855d211f
compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents:
1228
diff
changeset
|
44 def filectxfn_deleted_reraise(memctx): |
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 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
|
47 |
4ed0855d211f
compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents:
1228
diff
changeset
|
48 Call as: |
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 try: |
4ed0855d211f
compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents:
1228
diff
changeset
|
51 # 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
|
52 except IOError: |
4ed0855d211f
compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents:
1228
diff
changeset
|
53 return compathacks.filectxfn_deleted_reraise(memctx) |
4ed0855d211f
compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents:
1228
diff
changeset
|
54 |
4ed0855d211f
compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents:
1228
diff
changeset
|
55 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
|
56 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
|
57 IOError. |
4ed0855d211f
compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents:
1228
diff
changeset
|
58 """ |
4ed0855d211f
compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents:
1228
diff
changeset
|
59 exc_info = sys.exc_info() |
4ed0855d211f
compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents:
1228
diff
changeset
|
60 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
|
61 getattr(memctx, '_returnnoneformissingfiles', False)): |
4ed0855d211f
compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents:
1228
diff
changeset
|
62 return None |
4ed0855d211f
compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents:
1228
diff
changeset
|
63 # preserve traceback info |
4ed0855d211f
compathacks: add hacks for filectxfn deletion contract changing
Siddharth Agarwal <sid0@fb.com>
parents:
1228
diff
changeset
|
64 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
|
65 |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
66 # copied from hg 3.8 |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
67 class _funcregistrarbase(object): |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
68 """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
|
69 |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
70 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
|
71 |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
72 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
|
73 for example:: |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
74 |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
75 class keyword(_funcregistrarbase): |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
76 _docformat = ":%s: %s" |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
77 |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
78 This should be used as below: |
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 keyword = registrar.keyword() |
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 @keyword('bar') |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
83 def barfunc(*args, **kwargs): |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
84 '''Explanation of bar keyword .... |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
85 ''' |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
86 pass |
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 In this case: |
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 - '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
|
91 - 'barfunc.__doc__' becomes ":bar: Explanation of bar keyword" |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
92 """ |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
93 def __init__(self, table=None): |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
94 if table is None: |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
95 self._table = {} |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
96 else: |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
97 self._table = table |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
98 |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
99 def __call__(self, decl, *args, **kwargs): |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
100 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
|
101 |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
102 def _doregister(self, func, decl, *args, **kwargs): |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
103 name = self._getname(decl) |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
104 |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
105 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
|
106 doc = func.__doc__.strip() |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
107 func._origdoc = doc |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
108 func.__doc__ = self._formatdoc(decl, doc) |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
109 |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
110 self._table[name] = func |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
111 self._extrasetup(name, func, *args, **kwargs) |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
112 |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
113 return func |
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 def _parsefuncdecl(self, decl): |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
116 """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
|
117 """ |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
118 i = decl.find('(') |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
119 if i >= 0: |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
120 return decl[:i] |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
121 else: |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
122 return decl |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
123 |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
124 def _getname(self, decl): |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
125 """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
|
126 |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
127 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
|
128 descriptive 'decl' string than just a name. |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
129 """ |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
130 return decl |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
131 |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
132 _docformat = None |
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 _formatdoc(self, decl, doc): |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
135 """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
|
136 |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
137 'doc' is '__doc__.strip()' of the registered function. |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
138 """ |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
139 return self._docformat % (decl, doc) |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
140 |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
141 def _extrasetup(self, name, func): |
c5b7fb8911c0
compathacks: copy _funcregistrarbase for older mercurial
Sean Farley <sean@farley.io>
parents:
1237
diff
changeset
|
142 """Execute exra setup for registered function, if needed |
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 pass |
1572
51e105c7f0c6
compathacks: deal with removed aliases in mercurial.util
Augie Fackler <raf@durin42.com>
parents:
1549
diff
changeset
|
145 |
51e105c7f0c6
compathacks: deal with removed aliases in mercurial.util
Augie Fackler <raf@durin42.com>
parents:
1549
diff
changeset
|
146 try: |
51e105c7f0c6
compathacks: deal with removed aliases in mercurial.util
Augie Fackler <raf@durin42.com>
parents:
1549
diff
changeset
|
147 binary = util.binary |
51e105c7f0c6
compathacks: deal with removed aliases in mercurial.util
Augie Fackler <raf@durin42.com>
parents:
1549
diff
changeset
|
148 except AttributeError: |
51e105c7f0c6
compathacks: deal with removed aliases in mercurial.util
Augie Fackler <raf@durin42.com>
parents:
1549
diff
changeset
|
149 from mercurial.utils import stringutil |
51e105c7f0c6
compathacks: deal with removed aliases in mercurial.util
Augie Fackler <raf@durin42.com>
parents:
1549
diff
changeset
|
150 binary = stringutil.binary |
51e105c7f0c6
compathacks: deal with removed aliases in mercurial.util
Augie Fackler <raf@durin42.com>
parents:
1549
diff
changeset
|
151 |
51e105c7f0c6
compathacks: deal with removed aliases in mercurial.util
Augie Fackler <raf@durin42.com>
parents:
1549
diff
changeset
|
152 try: |
51e105c7f0c6
compathacks: deal with removed aliases in mercurial.util
Augie Fackler <raf@durin42.com>
parents:
1549
diff
changeset
|
153 datestr = util.datestr |
51e105c7f0c6
compathacks: deal with removed aliases in mercurial.util
Augie Fackler <raf@durin42.com>
parents:
1549
diff
changeset
|
154 except AttributeError: |
51e105c7f0c6
compathacks: deal with removed aliases in mercurial.util
Augie Fackler <raf@durin42.com>
parents:
1549
diff
changeset
|
155 from mercurial.utils import dateutil |
51e105c7f0c6
compathacks: deal with removed aliases in mercurial.util
Augie Fackler <raf@durin42.com>
parents:
1549
diff
changeset
|
156 datestr = dateutil.datestr |