Mercurial > hgrepos > DevTools > mercurial-extensions
annotate extensions/kwarchive.py @ 436:111aa1d44ffd
Put the copyright symbol © into the copyright message instead of (C)
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Sat, 30 May 2026 13:11:51 +0200 |
| parents | 7fd26761565b |
| children |
| rev | line source |
|---|---|
|
28
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
1 # -*- coding: utf-8 -*- |
|
125
fb7e1e4e4d2c
Provide some SCCS markers also to be able to search with "what(1)" also
Franz Glasner <hg@dom66.de>
parents:
124
diff
changeset
|
2 # @(#) $HGheader$ |
|
315
e9ded6c1db41
Add a copyright and license note to the revinfo and kwarchive modules and to the README also.
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
3 # $HGnodeid$ |
|
336
eb1e0f129963
More compliance with the private style guide for Mercurial extensions for the metadata of the extensions
Franz Glasner <fzglas.hg@dom66.de>
parents:
332
diff
changeset
|
4 # :- |
|
436
111aa1d44ffd
Put the copyright symbol © into the copyright message instead of (C)
Franz Glasner <fzglas.hg@dom66.de>
parents:
435
diff
changeset
|
5 # :Copyright: © 2017-2026 Franz Glasner <fzglas.hg@dom66.de> |
|
315
e9ded6c1db41
Add a copyright and license note to the revinfo and kwarchive modules and to the README also.
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
6 # :License: This software may be used and distributed according to the |
|
e9ded6c1db41
Add a copyright and license note to the revinfo and kwarchive modules and to the README also.
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
7 # terms of the GNU General Public License version 2 or any |
|
e9ded6c1db41
Add a copyright and license note to the revinfo and kwarchive modules and to the README also.
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
8 # later version. |
|
e9ded6c1db41
Add a copyright and license note to the revinfo and kwarchive modules and to the README also.
Franz Glasner <fzglas.hg@dom66.de>
parents:
314
diff
changeset
|
9 # The license is incorporated herein by reference. |
|
336
eb1e0f129963
More compliance with the private style guide for Mercurial extensions for the metadata of the extensions
Franz Glasner <fzglas.hg@dom66.de>
parents:
332
diff
changeset
|
10 # :- |
|
34
7c4addd60935
Put keyword into the extensions itself
Franz Glasner <hg@dom66.de>
parents:
33
diff
changeset
|
11 # |
| 60 | 12 """like :hg:`archive` but with keyword expansion within selected files |
|
33
dc8db9693262
kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents:
32
diff
changeset
|
13 |
|
129
51a4f1f5df09
Docu: enhanced the docu of "kwarchive"
Franz Glasner <hg@dom66.de>
parents:
126
diff
changeset
|
14 Configuration is done in a versioned ``.hgkwarchive`` configuration |
|
51a4f1f5df09
Docu: enhanced the docu of "kwarchive"
Franz Glasner <hg@dom66.de>
parents:
126
diff
changeset
|
15 file. This file uses the same syntax as all other Mercurial |
|
33
dc8db9693262
kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents:
32
diff
changeset
|
16 configuration files. |
|
dc8db9693262
kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents:
32
diff
changeset
|
17 |
|
129
51a4f1f5df09
Docu: enhanced the docu of "kwarchive"
Franz Glasner <hg@dom66.de>
parents:
126
diff
changeset
|
18 The ``[patterns]`` section specifies which files should have the |
|
51a4f1f5df09
Docu: enhanced the docu of "kwarchive"
Franz Glasner <hg@dom66.de>
parents:
126
diff
changeset
|
19 keywords expanded and possibly the style of expansion. The keys are |
|
51a4f1f5df09
Docu: enhanced the docu of "kwarchive"
Franz Glasner <hg@dom66.de>
parents:
126
diff
changeset
|
20 Mercurial file name patterns as described in :hg:`patterns`. |
|
33
dc8db9693262
kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents:
32
diff
changeset
|
21 |
|
dc8db9693262
kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents:
32
diff
changeset
|
22 Example:: |
|
dc8db9693262
kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents:
32
diff
changeset
|
23 |
|
120
9ed197b60e99
Prepare a [keywords] section with a whitelist of considered keywords and/or aliases
Franz Glasner <hg@dom66.de>
parents:
119
diff
changeset
|
24 # |
| 299 | 25 # Determine which files are considered for keyword expansion in |
|
120
9ed197b60e99
Prepare a [keywords] section with a whitelist of considered keywords and/or aliases
Franz Glasner <hg@dom66.de>
parents:
119
diff
changeset
|
26 # which style |
|
9ed197b60e99
Prepare a [keywords] section with a whitelist of considered keywords and/or aliases
Franz Glasner <hg@dom66.de>
parents:
119
diff
changeset
|
27 # |
|
33
dc8db9693262
kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents:
32
diff
changeset
|
28 [patterns] |
| 299 | 29 # |
| 30 # Expand keywords in every python file except those matching "x*" | |
| 31 # using the default RCS style expansion format | |
| 32 # | |
| 33 **.py = | |
| 34 x* = NO | |
| 35 # This file has reStructuredText style keyword expansion "|VCS<kw>|" only | |
| 36 path:VERSION = reST | |
| 37 # This file has reStructuredText style and RCS style keyword expansion | |
| 38 path:README = reST, RCS | |
|
33
dc8db9693262
kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents:
32
diff
changeset
|
39 |
|
246
d23d3d97c106
FIX: Typo in docu: [keyword] -> [keywords]
Franz Glasner <hg@dom66.de>
parents:
160
diff
changeset
|
40 The ``[keywords]`` section specifies which keywords are expanded. Aliases |
|
129
51a4f1f5df09
Docu: enhanced the docu of "kwarchive"
Franz Glasner <hg@dom66.de>
parents:
126
diff
changeset
|
41 can be defined also. By default the pre-defined set of RCC/CVS/SVN-like |
|
51a4f1f5df09
Docu: enhanced the docu of "kwarchive"
Franz Glasner <hg@dom66.de>
parents:
126
diff
changeset
|
42 keywords is expanded. A non-empty ``[keyword]`` section defines an |
|
51a4f1f5df09
Docu: enhanced the docu of "kwarchive"
Franz Glasner <hg@dom66.de>
parents:
126
diff
changeset
|
43 explicit white-list of expanded keywords and/or aliases. |
|
51a4f1f5df09
Docu: enhanced the docu of "kwarchive"
Franz Glasner <hg@dom66.de>
parents:
126
diff
changeset
|
44 |
|
51a4f1f5df09
Docu: enhanced the docu of "kwarchive"
Franz Glasner <hg@dom66.de>
parents:
126
diff
changeset
|
45 Example:: |
|
51a4f1f5df09
Docu: enhanced the docu of "kwarchive"
Franz Glasner <hg@dom66.de>
parents:
126
diff
changeset
|
46 |
|
120
9ed197b60e99
Prepare a [keywords] section with a whitelist of considered keywords and/or aliases
Franz Glasner <hg@dom66.de>
parents:
119
diff
changeset
|
47 # |
|
9ed197b60e99
Prepare a [keywords] section with a whitelist of considered keywords and/or aliases
Franz Glasner <hg@dom66.de>
parents:
119
diff
changeset
|
48 # Determine which keywords are expanded. |
|
9ed197b60e99
Prepare a [keywords] section with a whitelist of considered keywords and/or aliases
Franz Glasner <hg@dom66.de>
parents:
119
diff
changeset
|
49 # A missing and/or empty section means that all predefined keywords |
|
9ed197b60e99
Prepare a [keywords] section with a whitelist of considered keywords and/or aliases
Franz Glasner <hg@dom66.de>
parents:
119
diff
changeset
|
50 # are expanded. |
|
9ed197b60e99
Prepare a [keywords] section with a whitelist of considered keywords and/or aliases
Franz Glasner <hg@dom66.de>
parents:
119
diff
changeset
|
51 # |
|
124
46b7d34ef0b2
Enhanced the module documentation of "kwarchive"
Franz Glasner <hg@dom66.de>
parents:
122
diff
changeset
|
52 # Consisting of key-value pairs with of the form |
|
46b7d34ef0b2
Enhanced the module documentation of "kwarchive"
Franz Glasner <hg@dom66.de>
parents:
122
diff
changeset
|
53 # |
|
46b7d34ef0b2
Enhanced the module documentation of "kwarchive"
Franz Glasner <hg@dom66.de>
parents:
122
diff
changeset
|
54 # Alias = PreDefinedKeyword |
|
46b7d34ef0b2
Enhanced the module documentation of "kwarchive"
Franz Glasner <hg@dom66.de>
parents:
122
diff
changeset
|
55 # |
|
46b7d34ef0b2
Enhanced the module documentation of "kwarchive"
Franz Glasner <hg@dom66.de>
parents:
122
diff
changeset
|
56 # An empty `PreDefinedKeyword' means the identity. |
|
46b7d34ef0b2
Enhanced the module documentation of "kwarchive"
Franz Glasner <hg@dom66.de>
parents:
122
diff
changeset
|
57 # |
|
120
9ed197b60e99
Prepare a [keywords] section with a whitelist of considered keywords and/or aliases
Franz Glasner <hg@dom66.de>
parents:
119
diff
changeset
|
58 [keywords] |
|
122
e6037655967b
Implemented a keyword white-list including aliases.
Franz Glasner <hg@dom66.de>
parents:
120
diff
changeset
|
59 # `Revision' and possibly the `VCSRevision' keyword is expanded |
|
120
9ed197b60e99
Prepare a [keywords] section with a whitelist of considered keywords and/or aliases
Franz Glasner <hg@dom66.de>
parents:
119
diff
changeset
|
60 Revision = |
|
124
46b7d34ef0b2
Enhanced the module documentation of "kwarchive"
Franz Glasner <hg@dom66.de>
parents:
122
diff
changeset
|
61 # |
|
46b7d34ef0b2
Enhanced the module documentation of "kwarchive"
Franz Glasner <hg@dom66.de>
parents:
122
diff
changeset
|
62 # Additionally: `MyKeyword' is expanded with the contents of the |
|
321
103df4b7a0c8
A new more flexible syntax for custom keyword expansion: with Python template format syntax now
Franz Glasner <fzglas.hg@dom66.de>
parents:
315
diff
changeset
|
63 # pre-defined `JustDate' (this is in Python's format syntax). |
|
124
46b7d34ef0b2
Enhanced the module documentation of "kwarchive"
Franz Glasner <hg@dom66.de>
parents:
122
diff
changeset
|
64 # |
|
321
103df4b7a0c8
A new more flexible syntax for custom keyword expansion: with Python template format syntax now
Franz Glasner <fzglas.hg@dom66.de>
parents:
315
diff
changeset
|
65 MyKeyword = {JustDate} |
|
133
8d16138e00af
Implemented substitution type keyword expansion
Franz Glasner <hg@dom66.de>
parents:
131
diff
changeset
|
66 # |
|
321
103df4b7a0c8
A new more flexible syntax for custom keyword expansion: with Python template format syntax now
Franz Glasner <fzglas.hg@dom66.de>
parents:
315
diff
changeset
|
67 # `MyCustomSubstKeyword' is a substitution keyword. |
|
133
8d16138e00af
Implemented substitution type keyword expansion
Franz Glasner <hg@dom66.de>
parents:
131
diff
changeset
|
68 # |
|
321
103df4b7a0c8
A new more flexible syntax for custom keyword expansion: with Python template format syntax now
Franz Glasner <fzglas.hg@dom66.de>
parents:
315
diff
changeset
|
69 MyCustomSubstKeyword = This is my replacement content |
|
120
9ed197b60e99
Prepare a [keywords] section with a whitelist of considered keywords and/or aliases
Franz Glasner <hg@dom66.de>
parents:
119
diff
changeset
|
70 |
|
33
dc8db9693262
kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents:
32
diff
changeset
|
71 A non-existing ``.hgkwarchive`` file deactivates keyword expansion as does |
|
dc8db9693262
kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents:
32
diff
changeset
|
72 an empty ``[patterns]`` section. |
|
dc8db9693262
kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents:
32
diff
changeset
|
73 |
|
130
c3397e670063
Docu: drop a note why templates are not supported in keyword definitions
Franz Glasner <hg@dom66.de>
parents:
129
diff
changeset
|
74 .. note:: Because the keyword expansion is defined in a *versioned* file |
|
c3397e670063
Docu: drop a note why templates are not supported in keyword definitions
Franz Glasner <hg@dom66.de>
parents:
129
diff
changeset
|
75 no templating is supported here. This could lead to remote |
|
c3397e670063
Docu: drop a note why templates are not supported in keyword definitions
Franz Glasner <hg@dom66.de>
parents:
129
diff
changeset
|
76 code execution secnarios because Mercurial templates can execute |
|
c3397e670063
Docu: drop a note why templates are not supported in keyword definitions
Franz Glasner <hg@dom66.de>
parents:
129
diff
changeset
|
77 a big bunch of Python functions. |
|
c3397e670063
Docu: drop a note why templates are not supported in keyword definitions
Franz Glasner <hg@dom66.de>
parents:
129
diff
changeset
|
78 |
|
137
5e502e9dd5e5
As an example: put the |VCSRevision| into the extensions also and print it with the help output
Franz Glasner <hg@dom66.de>
parents:
136
diff
changeset
|
79 (rev |VCSRevision|) |
|
5e502e9dd5e5
As an example: put the |VCSRevision| into the extensions also and print it with the help output
Franz Glasner <hg@dom66.de>
parents:
136
diff
changeset
|
80 |
|
28
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
81 """ |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
82 |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
83 from __future__ import absolute_import |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
84 |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
85 |
|
336
eb1e0f129963
More compliance with the private style guide for Mercurial extensions for the metadata of the extensions
Franz Glasner <fzglas.hg@dom66.de>
parents:
332
diff
changeset
|
86 __revision__ = "|VCSRevision|" |
|
eb1e0f129963
More compliance with the private style guide for Mercurial extensions for the metadata of the extensions
Franz Glasner <fzglas.hg@dom66.de>
parents:
332
diff
changeset
|
87 __date__ = "|VCSJustDate|" |
|
28
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
88 __author__ = "Franz Glasner" |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
89 |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
90 |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
91 import os |
| 332 | 92 import inspect |
|
33
dc8db9693262
kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents:
32
diff
changeset
|
93 import itertools |
|
28
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
94 |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
95 from mercurial.i18n import _ |
|
288
0080dab59fac
Begin tests with subrepos and some preparations for nested subrepos
Franz Glasner <hg@dom66.de>
parents:
287
diff
changeset
|
96 from mercurial import (archival, config, cmdutil, error, match, subrepo, |
|
300
56df37d7878e
Keywords HGlatesttags, HGlatesttagdistance, HGlatesttagdate and HGlatesttagjustdate
Franz Glasner <hg@dom66.de>
parents:
299
diff
changeset
|
97 pycompat, scmutil, templatefilters, templatekw, |
|
307
f8aa592b344e
FIX: Mercurial's "demandimport" defeats the "try: import ...; except ImportError" idiom; temporarily disable demandimport before doing such imports in kwarchive
Franz Glasner <hg@dom66.de>
parents:
304
diff
changeset
|
98 util, node, demandimport) |
|
326
26e617693ae8
FIX: kwarchive and revinfo do not run on versions prior to Mercurial 4.3 after testing this with unit-tests
Franz Glasner <fzglas.hg@dom66.de>
parents:
322
diff
changeset
|
99 with demandimport.deactivated(): |
|
307
f8aa592b344e
FIX: Mercurial's "demandimport" defeats the "try: import ...; except ImportError" idiom; temporarily disable demandimport before doing such imports in kwarchive
Franz Glasner <hg@dom66.de>
parents:
304
diff
changeset
|
100 try: |
|
f8aa592b344e
FIX: Mercurial's "demandimport" defeats the "try: import ...; except ImportError" idiom; temporarily disable demandimport before doing such imports in kwarchive
Franz Glasner <hg@dom66.de>
parents:
304
diff
changeset
|
101 from mercurial import registrar |
|
f8aa592b344e
FIX: Mercurial's "demandimport" defeats the "try: import ...; except ImportError" idiom; temporarily disable demandimport before doing such imports in kwarchive
Franz Glasner <hg@dom66.de>
parents:
304
diff
changeset
|
102 except ImportError: |
|
f8aa592b344e
FIX: Mercurial's "demandimport" defeats the "try: import ...; except ImportError" idiom; temporarily disable demandimport before doing such imports in kwarchive
Franz Glasner <hg@dom66.de>
parents:
304
diff
changeset
|
103 registrar = None |
|
f8aa592b344e
FIX: Mercurial's "demandimport" defeats the "try: import ...; except ImportError" idiom; temporarily disable demandimport before doing such imports in kwarchive
Franz Glasner <hg@dom66.de>
parents:
304
diff
changeset
|
104 # check for new template function API with `(context, mapping)` |
|
f8aa592b344e
FIX: Mercurial's "demandimport" defeats the "try: import ...; except ImportError" idiom; temporarily disable demandimport before doing such imports in kwarchive
Franz Glasner <hg@dom66.de>
parents:
304
diff
changeset
|
105 try: |
|
f8aa592b344e
FIX: Mercurial's "demandimport" defeats the "try: import ...; except ImportError" idiom; temporarily disable demandimport before doing such imports in kwarchive
Franz Glasner <hg@dom66.de>
parents:
304
diff
changeset
|
106 from mercurial import templatefuncs |
|
f8aa592b344e
FIX: Mercurial's "demandimport" defeats the "try: import ...; except ImportError" idiom; temporarily disable demandimport before doing such imports in kwarchive
Franz Glasner <hg@dom66.de>
parents:
304
diff
changeset
|
107 except ImportError: |
|
f8aa592b344e
FIX: Mercurial's "demandimport" defeats the "try: import ...; except ImportError" idiom; temporarily disable demandimport before doing such imports in kwarchive
Franz Glasner <hg@dom66.de>
parents:
304
diff
changeset
|
108 context_mapping_api = False |
|
f8aa592b344e
FIX: Mercurial's "demandimport" defeats the "try: import ...; except ImportError" idiom; temporarily disable demandimport before doing such imports in kwarchive
Franz Glasner <hg@dom66.de>
parents:
304
diff
changeset
|
109 else: |
|
f8aa592b344e
FIX: Mercurial's "demandimport" defeats the "try: import ...; except ImportError" idiom; temporarily disable demandimport before doing such imports in kwarchive
Franz Glasner <hg@dom66.de>
parents:
304
diff
changeset
|
110 # >= 4.6 |
|
f8aa592b344e
FIX: Mercurial's "demandimport" defeats the "try: import ...; except ImportError" idiom; temporarily disable demandimport before doing such imports in kwarchive
Franz Glasner <hg@dom66.de>
parents:
304
diff
changeset
|
111 context_mapping_api = True |
|
f8aa592b344e
FIX: Mercurial's "demandimport" defeats the "try: import ...; except ImportError" idiom; temporarily disable demandimport before doing such imports in kwarchive
Franz Glasner <hg@dom66.de>
parents:
304
diff
changeset
|
112 # some date specific util functions moved to new mercurial.utils.dateutil |
|
f8aa592b344e
FIX: Mercurial's "demandimport" defeats the "try: import ...; except ImportError" idiom; temporarily disable demandimport before doing such imports in kwarchive
Franz Glasner <hg@dom66.de>
parents:
304
diff
changeset
|
113 try: |
|
f8aa592b344e
FIX: Mercurial's "demandimport" defeats the "try: import ...; except ImportError" idiom; temporarily disable demandimport before doing such imports in kwarchive
Franz Glasner <hg@dom66.de>
parents:
304
diff
changeset
|
114 from mercurial.utils import dateutil as _dateutil |
|
f8aa592b344e
FIX: Mercurial's "demandimport" defeats the "try: import ...; except ImportError" idiom; temporarily disable demandimport before doing such imports in kwarchive
Franz Glasner <hg@dom66.de>
parents:
304
diff
changeset
|
115 except ImportError: |
|
f8aa592b344e
FIX: Mercurial's "demandimport" defeats the "try: import ...; except ImportError" idiom; temporarily disable demandimport before doing such imports in kwarchive
Franz Glasner <hg@dom66.de>
parents:
304
diff
changeset
|
116 _dateutil = util |
|
28
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
117 |
|
425
2a062f87f75d
Make "revinfo" and "kwarchive" work on Mercurial 6.
Franz Glasner <fzglas.hg@dom66.de>
parents:
424
diff
changeset
|
118 # some URL specific util functions moved to new mercurial.utils.urlutil |
|
2a062f87f75d
Make "revinfo" and "kwarchive" work on Mercurial 6.
Franz Glasner <fzglas.hg@dom66.de>
parents:
424
diff
changeset
|
119 try: |
|
2a062f87f75d
Make "revinfo" and "kwarchive" work on Mercurial 6.
Franz Glasner <fzglas.hg@dom66.de>
parents:
424
diff
changeset
|
120 from mercurial.utils import urlutil as _urlutil |
|
2a062f87f75d
Make "revinfo" and "kwarchive" work on Mercurial 6.
Franz Glasner <fzglas.hg@dom66.de>
parents:
424
diff
changeset
|
121 except ImportError: |
|
2a062f87f75d
Make "revinfo" and "kwarchive" work on Mercurial 6.
Franz Glasner <fzglas.hg@dom66.de>
parents:
424
diff
changeset
|
122 _urlutil = util |
|
28
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
123 |
|
425
2a062f87f75d
Make "revinfo" and "kwarchive" work on Mercurial 6.
Franz Glasner <fzglas.hg@dom66.de>
parents:
424
diff
changeset
|
124 |
|
432
e036013a4003
Note that the extensions work with Mercurkal 6.9.5
Franz Glasner <fzglas.hg@dom66.de>
parents:
425
diff
changeset
|
125 testedwith = b"4.3.1 4.3.2 4.4.1 4.4.2 4.5.2 4.6.1 4.8.1 4.9 5.0.1 5.1.2 5.2.1 5.5 5.6 5.9.1 6.1.4 6.9.5" |
|
28
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
126 |
|
51
3807a60ee0dd
Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents:
47
diff
changeset
|
127 SHORTENED_HG_SCHEMES = { |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
128 b"ssh": b"hg+ssh", |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
129 b"http": b"hg+http", |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
130 b"https": b"hg+https", |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
131 b"file": b"file", |
|
51
3807a60ee0dd
Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents:
47
diff
changeset
|
132 } |
|
3807a60ee0dd
Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents:
47
diff
changeset
|
133 |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
134 KWARCHIVE_CONFIG = b".hgkwarchive" |
|
156
d92850f876a4
Use a constant to define the ".hgkwarchive" name
Franz Glasner <hg@dom66.de>
parents:
155
diff
changeset
|
135 |
|
28
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
136 cmdtable = {} |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
137 |
|
326
26e617693ae8
FIX: kwarchive and revinfo do not run on versions prior to Mercurial 4.3 after testing this with unit-tests
Franz Glasner <fzglas.hg@dom66.de>
parents:
322
diff
changeset
|
138 if registrar and hasattr(registrar, "command"): |
|
248
436b2db75a34
cmdutil.command is deprecated: use registrar.command instead; also need always a repository for the commands: inferrepo=True
Franz Glasner <hg@dom66.de>
parents:
246
diff
changeset
|
139 command = registrar.command(cmdtable) |
|
436b2db75a34
cmdutil.command is deprecated: use registrar.command instead; also need always a repository for the commands: inferrepo=True
Franz Glasner <hg@dom66.de>
parents:
246
diff
changeset
|
140 else: |
|
436b2db75a34
cmdutil.command is deprecated: use registrar.command instead; also need always a repository for the commands: inferrepo=True
Franz Glasner <hg@dom66.de>
parents:
246
diff
changeset
|
141 command = cmdutil.command(cmdtable) |
|
28
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
142 |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
143 |
|
150
f195b4704726
For each extension: provide a "getversion()" function that will be called by Mercurial to get the module version.
Franz Glasner <hg@dom66.de>
parents:
147
diff
changeset
|
144 def getversion(): |
|
f195b4704726
For each extension: provide a "getversion()" function that will be called by Mercurial to get the module version.
Franz Glasner <hg@dom66.de>
parents:
147
diff
changeset
|
145 """Provide the version information for verbose :hg:`version` output. |
|
f195b4704726
For each extension: provide a "getversion()" function that will be called by Mercurial to get the module version.
Franz Glasner <hg@dom66.de>
parents:
147
diff
changeset
|
146 |
|
f195b4704726
For each extension: provide a "getversion()" function that will be called by Mercurial to get the module version.
Franz Glasner <hg@dom66.de>
parents:
147
diff
changeset
|
147 Read the :file:`VERSION` from the parent of the :file:`extensions` |
|
f195b4704726
For each extension: provide a "getversion()" function that will be called by Mercurial to get the module version.
Franz Glasner <hg@dom66.de>
parents:
147
diff
changeset
|
148 directory. |
|
f195b4704726
For each extension: provide a "getversion()" function that will be called by Mercurial to get the module version.
Franz Glasner <hg@dom66.de>
parents:
147
diff
changeset
|
149 |
|
f195b4704726
For each extension: provide a "getversion()" function that will be called by Mercurial to get the module version.
Franz Glasner <hg@dom66.de>
parents:
147
diff
changeset
|
150 """ |
|
f195b4704726
For each extension: provide a "getversion()" function that will be called by Mercurial to get the module version.
Franz Glasner <hg@dom66.de>
parents:
147
diff
changeset
|
151 import re |
|
f195b4704726
For each extension: provide a "getversion()" function that will be called by Mercurial to get the module version.
Franz Glasner <hg@dom66.de>
parents:
147
diff
changeset
|
152 import os |
|
f195b4704726
For each extension: provide a "getversion()" function that will be called by Mercurial to get the module version.
Franz Glasner <hg@dom66.de>
parents:
147
diff
changeset
|
153 try: |
|
f195b4704726
For each extension: provide a "getversion()" function that will be called by Mercurial to get the module version.
Franz Glasner <hg@dom66.de>
parents:
147
diff
changeset
|
154 fn = __file__ |
|
f195b4704726
For each extension: provide a "getversion()" function that will be called by Mercurial to get the module version.
Franz Glasner <hg@dom66.de>
parents:
147
diff
changeset
|
155 except NameError: |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
156 return b"<unknown>" |
|
150
f195b4704726
For each extension: provide a "getversion()" function that will be called by Mercurial to get the module version.
Franz Glasner <hg@dom66.de>
parents:
147
diff
changeset
|
157 else: |
|
f195b4704726
For each extension: provide a "getversion()" function that will be called by Mercurial to get the module version.
Franz Glasner <hg@dom66.de>
parents:
147
diff
changeset
|
158 try: |
|
157
e12025e46375
Use util.posixfile when reading a custom given .hgkwarchive file for Mercurial portability reasons
Franz Glasner <hg@dom66.de>
parents:
156
diff
changeset
|
159 # this is pure Python standard functionality: no util.posixfile |
|
150
f195b4704726
For each extension: provide a "getversion()" function that will be called by Mercurial to get the module version.
Franz Glasner <hg@dom66.de>
parents:
147
diff
changeset
|
160 verdata = open(os.path.join(os.path.dirname(fn), |
|
f195b4704726
For each extension: provide a "getversion()" function that will be called by Mercurial to get the module version.
Franz Glasner <hg@dom66.de>
parents:
147
diff
changeset
|
161 "../VERSION"), |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
162 "rb").read() |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
163 return re.search(b"^(.*)", verdata,).group(1) |
|
150
f195b4704726
For each extension: provide a "getversion()" function that will be called by Mercurial to get the module version.
Franz Glasner <hg@dom66.de>
parents:
147
diff
changeset
|
164 except OSError: |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
165 return b"<not found>" |
|
150
f195b4704726
For each extension: provide a "getversion()" function that will be called by Mercurial to get the module version.
Franz Glasner <hg@dom66.de>
parents:
147
diff
changeset
|
166 |
|
f195b4704726
For each extension: provide a "getversion()" function that will be called by Mercurial to get the module version.
Franz Glasner <hg@dom66.de>
parents:
147
diff
changeset
|
167 |
|
114
a51822141ccf
Style: handled some more flake8 warnings: consistent command declaration list formatting
Franz Glasner <hg@dom66.de>
parents:
112
diff
changeset
|
168 @command( |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
169 b"kwarchive", |
|
114
a51822141ccf
Style: handled some more flake8 warnings: consistent command declaration list formatting
Franz Glasner <hg@dom66.de>
parents:
112
diff
changeset
|
170 [ |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
171 (b'', b"no-decode", None, _(b"do not pass files through decoders")), |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
172 (b'p', b"prefix", b'', _(b"directory prefix for files in archive"), _(b"PREFIX")), |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
173 (b'r', b"rev", b'', _(b"revision to distribute"), _(b"REV")), |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
174 (b't', b"type", b'', _(b"type of distribution to create"), _(b"TYPE")), |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
175 (b'', b"path", b"default", _(b"the canonical repository to use"), _(b"PATH")), |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
176 (b'', b"kwconfig", b'', _(b"an alternate pattern configuration configuration file (possibly used for subrepos also)"), _(b"PATTERNCONFIG")), |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
177 (b'', b"no-shorten-path", None, _(b"don't shorten the path urls")), |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
178 (b'', b"path-filter", b"short", _(b"determine how the path will be printed")), |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
179 (b'', b"user-filter", b"user", _(b"the part of the user to be printed"), _(b"USERFILTER")) |
|
28
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
180 ] + cmdutil.subrepoopts + cmdutil.walkopts, |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
181 _(b"[OPTION]... DEST"), |
|
248
436b2db75a34
cmdutil.command is deprecated: use registrar.command instead; also need always a repository for the commands: inferrepo=True
Franz Glasner <hg@dom66.de>
parents:
246
diff
changeset
|
182 inferrepo=True) |
|
28
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
183 def kwarchive(ui, repo, dest, **opts): |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
184 '''create an unversioned archive of a repository revision with some keywords expanded |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
185 |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
186 By default, the revision used is the parent of the working |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
187 directory; use -r/--rev to specify a different revision. |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
188 |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
189 The archive type is automatically detected based on file |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
190 extension (to override, use -t/--type). |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
191 |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
192 .. container:: verbose |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
193 |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
194 Examples: |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
195 |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
196 - create a zip file containing the 1.0 release:: |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
197 |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
198 hg archive -r 1.0 project-1.0.zip |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
199 |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
200 - create a tarball excluding .hg files:: |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
201 |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
202 hg archive project.tar.gz -X ".hg*" |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
203 |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
204 Valid types are: |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
205 |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
206 :``files``: a directory full of files (default) |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
207 :``tar``: tar archive, uncompressed |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
208 :``tbz2``: tar archive, compressed using bzip2 |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
209 :``tgz``: tar archive, compressed using gzip |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
210 :``uzip``: zip archive, uncompressed |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
211 :``zip``: zip archive, compressed using deflate |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
212 |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
213 The exact name of the destination archive or directory is given |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
214 using a format string; see :hg:`help export` for details. |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
215 |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
216 Each member added to an archive file has a directory prefix |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
217 prepended. Use -p/--prefix to specify a format string for the |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
218 prefix. The default is the basename of the archive, with suffixes |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
219 removed. |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
220 |
| 41 | 221 Use --path to specify named path information from :hg:`paths` as |
| 222 the canonical repository location. Use ``.`` for the current | |
| 223 repository root root. If no path is given then ``default`` is | |
| 224 assumed. | |
|
35
f29c98e54f50
Implement a "--path" option for kwarchive to select a repository to use as canonical one
Franz Glasner <hg@dom66.de>
parents:
34
diff
changeset
|
225 |
|
51
3807a60ee0dd
Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents:
47
diff
changeset
|
226 Full path URLs are printed somewhat shortened by default. To use |
|
3807a60ee0dd
Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents:
47
diff
changeset
|
227 them as-is use the --no-shorten-path option. |
|
3807a60ee0dd
Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents:
47
diff
changeset
|
228 |
|
65
bdb549d71148
Allow customization of the $Author$ output when expanding keywords.
Franz Glasner <hg@dom66.de>
parents:
64
diff
changeset
|
229 Allowed --user-filter values are: |
|
bdb549d71148
Allow customization of the $Author$ output when expanding keywords.
Franz Glasner <hg@dom66.de>
parents:
64
diff
changeset
|
230 |
|
bdb549d71148
Allow customization of the $Author$ output when expanding keywords.
Franz Glasner <hg@dom66.de>
parents:
64
diff
changeset
|
231 :``user``: the short representation of a user name or email address |
|
bdb549d71148
Allow customization of the $Author$ output when expanding keywords.
Franz Glasner <hg@dom66.de>
parents:
64
diff
changeset
|
232 :``person``: the name before an email address as per RFC 5322 |
|
bdb549d71148
Allow customization of the $Author$ output when expanding keywords.
Franz Glasner <hg@dom66.de>
parents:
64
diff
changeset
|
233 :``email``: the email address |
|
81
e02aceb91a9b
Make "full" a user filter and "none" an alias to "full"
Franz Glasner <hg@dom66.de>
parents:
80
diff
changeset
|
234 :``full``: the complete user information w/o filtering |
|
e02aceb91a9b
Make "full" a user filter and "none" an alias to "full"
Franz Glasner <hg@dom66.de>
parents:
80
diff
changeset
|
235 :``none``: an alias for ``full`` |
|
65
bdb549d71148
Allow customization of the $Author$ output when expanding keywords.
Franz Glasner <hg@dom66.de>
parents:
64
diff
changeset
|
236 |
|
93
fa84debfb50e
Replace "no-shorten-url" by "path-filter"
Franz Glasner <hg@dom66.de>
parents:
92
diff
changeset
|
237 The --path-filter values detemine how the path will be printed: |
|
fa84debfb50e
Replace "no-shorten-url" by "path-filter"
Franz Glasner <hg@dom66.de>
parents:
92
diff
changeset
|
238 |
|
fa84debfb50e
Replace "no-shorten-url" by "path-filter"
Franz Glasner <hg@dom66.de>
parents:
92
diff
changeset
|
239 :``full``: the path will be printed as is (including passwords et al.) |
|
fa84debfb50e
Replace "no-shorten-url" by "path-filter"
Franz Glasner <hg@dom66.de>
parents:
92
diff
changeset
|
240 :``nopwd``: like ``full`` but without passwords |
|
249
e97f6f6ed7c5
Implement a "nouser" option for the path-filter: like no-pwd but without user information also
Franz Glasner <hg@dom66.de>
parents:
248
diff
changeset
|
241 :``nouser``: like ``full`` but without user and password information |
| 101 | 242 :``short``: shorten the path somehow: no user/password information and |
|
93
fa84debfb50e
Replace "no-shorten-url" by "path-filter"
Franz Glasner <hg@dom66.de>
parents:
92
diff
changeset
|
243 only a short server name |
|
100
eed73af1ab79
Implemented a "last" option for the "--path-filter": shorten to the last path component.
Franz Glasner <hg@dom66.de>
parents:
99
diff
changeset
|
244 :``last``: shorten the path to the last component |
|
342
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
245 :``repo``: the repository id will be used as path |
|
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
246 :``reposhort``: the shortened repository id will be used as path |
|
93
fa84debfb50e
Replace "no-shorten-url" by "path-filter"
Franz Glasner <hg@dom66.de>
parents:
92
diff
changeset
|
247 |
|
28
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
248 Returns 0 on success. |
| 41 | 249 |
|
28
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
250 ''' |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
251 |
|
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
252 opts = pycompat.byteskwargs(opts) |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
253 ctx = scmutil.revsingle(repo, opts.get(b"rev")) |
|
28
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
254 if not ctx: |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
255 raise error.Abort(_(b"no Mercurial revision found: please specify a revision")) |
|
28
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
256 node = ctx.node() |
|
103
d6e594644778
Make kwarchive work on Mercurial 4.6+ also: the signature of cmdutil.makefileXXX() have changed
Franz Glasner <hg@dom66.de>
parents:
101
diff
changeset
|
257 dest = makefilename_compat(ctx, dest) |
|
28
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
258 if os.path.realpath(dest) == repo.root: |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
259 raise error.Abort(_(b"repository root cannot be destination")) |
|
28
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
260 |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
261 kind = opts.get(b"type") or archival.guesskind(dest) or b"files" |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
262 prefix = opts.get(b"prefix") |
|
28
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
263 |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
264 if dest == b'-': |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
265 if kind == "files": |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
266 raise error.Abort(_(b"cannot archive plain files to stdout")) |
|
103
d6e594644778
Make kwarchive work on Mercurial 4.6+ also: the signature of cmdutil.makefileXXX() have changed
Franz Glasner <hg@dom66.de>
parents:
101
diff
changeset
|
267 dest = makefileobj_compat(ctx, dest) |
|
28
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
268 if not prefix: |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
269 prefix = os.path.basename(repo.root) + b'-%h' |
|
28
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
270 |
|
103
d6e594644778
Make kwarchive work on Mercurial 4.6+ also: the signature of cmdutil.makefileXXX() have changed
Franz Glasner <hg@dom66.de>
parents:
101
diff
changeset
|
271 prefix = makefilename_compat(ctx, prefix) |
|
28
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
272 matchfn = scmutil.match(ctx, [], opts) |
|
29
58f47399691c
New successful PoC: monkey-patch all relevant archiver's "addfile()" method
Franz Glasner <hg@dom66.de>
parents:
28
diff
changeset
|
273 |
|
58f47399691c
New successful PoC: monkey-patch all relevant archiver's "addfile()" method
Franz Glasner <hg@dom66.de>
parents:
28
diff
changeset
|
274 # |
|
31
0597395e2d18
Comment: better explanation of what is monkey-patched
Franz Glasner <hg@dom66.de>
parents:
30
diff
changeset
|
275 # Monkey patch archival's archivers classes so that an archiver's "addfile()" |
|
29
58f47399691c
New successful PoC: monkey-patch all relevant archiver's "addfile()" method
Franz Glasner <hg@dom66.de>
parents:
28
diff
changeset
|
276 # expands keywords |
|
58f47399691c
New successful PoC: monkey-patch all relevant archiver's "addfile()" method
Franz Glasner <hg@dom66.de>
parents:
28
diff
changeset
|
277 # |
|
32
cfa53f8a6607
Refactor the class' monkey-patching
Franz Glasner <hg@dom66.de>
parents:
31
diff
changeset
|
278 for ac in ("fileit", "tarit", "zipit",): |
|
33
dc8db9693262
kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents:
32
diff
changeset
|
279 patch_archiver_class( |
|
dc8db9693262
kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents:
32
diff
changeset
|
280 ac, |
|
dc8db9693262
kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents:
32
diff
changeset
|
281 make_keyword_filter( |
|
dc8db9693262
kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents:
32
diff
changeset
|
282 ui, |
|
dc8db9693262
kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents:
32
diff
changeset
|
283 ctx, |
|
dc8db9693262
kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents:
32
diff
changeset
|
284 ac, |
|
35
f29c98e54f50
Implement a "--path" option for kwarchive to select a repository to use as canonical one
Franz Glasner <hg@dom66.de>
parents:
34
diff
changeset
|
285 archival.tidyprefix(dest, kind, prefix), |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
286 hgpath=opts.get(b"path"), |
|
136
f470702886b4
Renamed some internal functions to provide a more descriptive name
Franz Glasner <hg@dom66.de>
parents:
134
diff
changeset
|
287 path_filter=get_checked_path_filter_option(opts), |
|
f470702886b4
Renamed some internal functions to provide a more descriptive name
Franz Glasner <hg@dom66.de>
parents:
134
diff
changeset
|
288 user_filter=get_checked_user_filter_option(opts), |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
289 subrepos=opts.get(b"subrepos"), |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
290 kwconfig=opts.get(b"kwconfig"))) |
|
30
1670760f695f
Monkey-patch all current archivers in mercurial.archival: fileit, tarit and ziptit
Franz Glasner <hg@dom66.de>
parents:
29
diff
changeset
|
291 |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
292 archival.archive(repo, dest, node, kind, not opts.get(b"no_decode"), |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
293 matchfn, prefix, subrepos=opts.get(b"subrepos")) |
|
28
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
294 |
|
32
cfa53f8a6607
Refactor the class' monkey-patching
Franz Glasner <hg@dom66.de>
parents:
31
diff
changeset
|
295 # XXX FIXME: Should the original methods be restored here? |
|
cfa53f8a6607
Refactor the class' monkey-patching
Franz Glasner <hg@dom66.de>
parents:
31
diff
changeset
|
296 |
|
46
4a0c26dfef3c
Comment about automatically amending .hg_archival.txt with "path" items.
Franz Glasner <hg@dom66.de>
parents:
45
diff
changeset
|
297 # XXX FIXME: Should we automatically amend ".hg_archival.txt" with a |
|
4a0c26dfef3c
Comment about automatically amending .hg_archival.txt with "path" items.
Franz Glasner <hg@dom66.de>
parents:
45
diff
changeset
|
298 # path item? But this means shat we should know the complete |
|
4a0c26dfef3c
Comment about automatically amending .hg_archival.txt with "path" items.
Franz Glasner <hg@dom66.de>
parents:
45
diff
changeset
|
299 # configuration ("ui.archivemeta") and it's name and some |
|
4a0c26dfef3c
Comment about automatically amending .hg_archival.txt with "path" items.
Franz Glasner <hg@dom66.de>
parents:
45
diff
changeset
|
300 # output match filters (see archival.archive()). |
|
4a0c26dfef3c
Comment about automatically amending .hg_archival.txt with "path" items.
Franz Glasner <hg@dom66.de>
parents:
45
diff
changeset
|
301 |
|
32
cfa53f8a6607
Refactor the class' monkey-patching
Franz Glasner <hg@dom66.de>
parents:
31
diff
changeset
|
302 |
|
114
a51822141ccf
Style: handled some more flake8 warnings: consistent command declaration list formatting
Franz Glasner <hg@dom66.de>
parents:
112
diff
changeset
|
303 @command( |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
304 b"kwprint", |
|
114
a51822141ccf
Style: handled some more flake8 warnings: consistent command declaration list formatting
Franz Glasner <hg@dom66.de>
parents:
112
diff
changeset
|
305 [ |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
306 (b'r', b"rev", b'', _(b"revision to distribute"), _(b"REV")), |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
307 (b'', b"path", b"default", _(b"the canonical repository to use"), _(b"PATH")), |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
308 (b'', b"no-shorten-path", None, _(b"don't shorten the path urls")), |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
309 (b'', b"path-filter", b"short", _(b"determine how the path will be printed")), |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
310 (b'', b"user-filter", b"user", _(b"the part of the user to be printed"), _(b"USERFILTER")), |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
311 (b'', b"reST", None, _(b"output in reST substitution definition syntax")), |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
312 (b'', b"no-file", None, _(b"don't show file-dependent keywords")), |
|
45
c077d30da0ee
Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents:
44
diff
changeset
|
313 ] + cmdutil.subrepoopts + cmdutil.walkopts, |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
314 _(b"[OPTION]..."), |
|
248
436b2db75a34
cmdutil.command is deprecated: use registrar.command instead; also need always a repository for the commands: inferrepo=True
Franz Glasner <hg@dom66.de>
parents:
246
diff
changeset
|
315 inferrepo=True) |
|
45
c077d30da0ee
Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents:
44
diff
changeset
|
316 def kwprint(ui, repo, **opts): |
|
109
be4811239acf
kwprint: print example file-dependent keywords also.
Franz Glasner <hg@dom66.de>
parents:
108
diff
changeset
|
317 '''print the file-independent keywords and for an example file-dependent |
|
be4811239acf
kwprint: print example file-dependent keywords also.
Franz Glasner <hg@dom66.de>
parents:
108
diff
changeset
|
318 keywords |
|
45
c077d30da0ee
Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents:
44
diff
changeset
|
319 |
|
c077d30da0ee
Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents:
44
diff
changeset
|
320 By default, the revision used is the parent of the working |
|
c077d30da0ee
Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents:
44
diff
changeset
|
321 directory; use -r/--rev to specify a different revision. |
|
c077d30da0ee
Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents:
44
diff
changeset
|
322 |
|
c077d30da0ee
Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents:
44
diff
changeset
|
323 Use --path to specify named path information from :hg:`paths` as |
|
c077d30da0ee
Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents:
44
diff
changeset
|
324 the canonical repository location. Use ``.`` for the current |
|
c077d30da0ee
Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents:
44
diff
changeset
|
325 repository root root. If no path is given then ``default`` is |
|
c077d30da0ee
Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents:
44
diff
changeset
|
326 assumed. |
|
c077d30da0ee
Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents:
44
diff
changeset
|
327 |
|
51
3807a60ee0dd
Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents:
47
diff
changeset
|
328 Full path URLs are printed somewhat shortened by default. To use |
|
3807a60ee0dd
Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents:
47
diff
changeset
|
329 them as-is use the --no-shorten-path option. |
|
3807a60ee0dd
Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents:
47
diff
changeset
|
330 |
|
65
bdb549d71148
Allow customization of the $Author$ output when expanding keywords.
Franz Glasner <hg@dom66.de>
parents:
64
diff
changeset
|
331 Allowed --user-filter values are: |
|
bdb549d71148
Allow customization of the $Author$ output when expanding keywords.
Franz Glasner <hg@dom66.de>
parents:
64
diff
changeset
|
332 |
|
bdb549d71148
Allow customization of the $Author$ output when expanding keywords.
Franz Glasner <hg@dom66.de>
parents:
64
diff
changeset
|
333 :``user``: the short representation of a user name or email address |
|
bdb549d71148
Allow customization of the $Author$ output when expanding keywords.
Franz Glasner <hg@dom66.de>
parents:
64
diff
changeset
|
334 :``person``: the name before an email address as per RFC 5322 |
|
bdb549d71148
Allow customization of the $Author$ output when expanding keywords.
Franz Glasner <hg@dom66.de>
parents:
64
diff
changeset
|
335 :``email``: the email address |
|
81
e02aceb91a9b
Make "full" a user filter and "none" an alias to "full"
Franz Glasner <hg@dom66.de>
parents:
80
diff
changeset
|
336 :``full``: the complete user information w/o filtering |
|
85
01ca9e1601a7
All extensions work with Mercurial 4.4.1 also
Franz Glasner <hg@dom66.de>
parents:
84
diff
changeset
|
337 :``none``: an alias for ``full`` |
|
65
bdb549d71148
Allow customization of the $Author$ output when expanding keywords.
Franz Glasner <hg@dom66.de>
parents:
64
diff
changeset
|
338 |
|
93
fa84debfb50e
Replace "no-shorten-url" by "path-filter"
Franz Glasner <hg@dom66.de>
parents:
92
diff
changeset
|
339 The --path-filter values detemine how the path will be printed: |
|
fa84debfb50e
Replace "no-shorten-url" by "path-filter"
Franz Glasner <hg@dom66.de>
parents:
92
diff
changeset
|
340 |
|
fa84debfb50e
Replace "no-shorten-url" by "path-filter"
Franz Glasner <hg@dom66.de>
parents:
92
diff
changeset
|
341 :``full``: the path will be printed as is (including passwords et al.) |
|
fa84debfb50e
Replace "no-shorten-url" by "path-filter"
Franz Glasner <hg@dom66.de>
parents:
92
diff
changeset
|
342 :``nopwd``: like ``full`` but without passwords |
|
249
e97f6f6ed7c5
Implement a "nouser" option for the path-filter: like no-pwd but without user information also
Franz Glasner <hg@dom66.de>
parents:
248
diff
changeset
|
343 :``nouser``: like ``full`` but without user and password information |
| 108 | 344 :``short``: shorten the path somehow: no user/password information and |
|
93
fa84debfb50e
Replace "no-shorten-url" by "path-filter"
Franz Glasner <hg@dom66.de>
parents:
92
diff
changeset
|
345 only a short server name |
|
100
eed73af1ab79
Implemented a "last" option for the "--path-filter": shorten to the last path component.
Franz Glasner <hg@dom66.de>
parents:
99
diff
changeset
|
346 :``last``: shorten the path to the last component |
|
342
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
347 :``repo``: the repository id will be used as path |
|
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
348 :``reposhort``: the shortened repository id will be used as path |
|
93
fa84debfb50e
Replace "no-shorten-url" by "path-filter"
Franz Glasner <hg@dom66.de>
parents:
92
diff
changeset
|
349 |
|
78
743dd4a77b4a
Implemented a "--reST" option for printing reST substitution definitions from keywords
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
350 Use --reST to output the keyword in a format suitable for including |
|
743dd4a77b4a
Implemented a "--reST" option for printing reST substitution definitions from keywords
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
351 in reStructuredText (reST) documents by using it's substitution feature. |
|
743dd4a77b4a
Implemented a "--reST" option for printing reST substitution definitions from keywords
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
352 All revision keyword names have a ``VCS`` prefix. |
|
743dd4a77b4a
Implemented a "--reST" option for printing reST substitution definitions from keywords
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
353 |
|
109
be4811239acf
kwprint: print example file-dependent keywords also.
Franz Glasner <hg@dom66.de>
parents:
108
diff
changeset
|
354 Use --no-file to suppress the output of file-dependent keywords with an |
|
be4811239acf
kwprint: print example file-dependent keywords also.
Franz Glasner <hg@dom66.de>
parents:
108
diff
changeset
|
355 example file. |
|
be4811239acf
kwprint: print example file-dependent keywords also.
Franz Glasner <hg@dom66.de>
parents:
108
diff
changeset
|
356 |
|
45
c077d30da0ee
Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents:
44
diff
changeset
|
357 Returns 0 on success. |
|
c077d30da0ee
Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents:
44
diff
changeset
|
358 |
|
c077d30da0ee
Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents:
44
diff
changeset
|
359 ''' |
|
c077d30da0ee
Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents:
44
diff
changeset
|
360 |
|
c077d30da0ee
Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents:
44
diff
changeset
|
361 opts = pycompat.byteskwargs(opts) |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
362 ctx = scmutil.revsingle(repo, opts.get(b"rev")) |
|
45
c077d30da0ee
Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents:
44
diff
changeset
|
363 if not ctx: |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
364 raise error.Abort(_(b"no Mercurial revision found: please specify a revision")) |
|
45
c077d30da0ee
Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents:
44
diff
changeset
|
365 node = ctx.node() |
|
c077d30da0ee
Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents:
44
diff
changeset
|
366 |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
367 prefix = makefilename_compat(ctx, b'') |
|
45
c077d30da0ee
Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents:
44
diff
changeset
|
368 |
|
c077d30da0ee
Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents:
44
diff
changeset
|
369 keywords = make_node_keywords( |
|
293
75070825d111
- make_node_keywords() and make_keyword_filter() do not need a "repo" argument.
Franz Glasner <hg@dom66.de>
parents:
292
diff
changeset
|
370 ui, ctx, |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
371 hgpath=opts.get(b"path"), |
|
136
f470702886b4
Renamed some internal functions to provide a more descriptive name
Franz Glasner <hg@dom66.de>
parents:
134
diff
changeset
|
372 path_filter=get_checked_path_filter_option(opts), |
|
f470702886b4
Renamed some internal functions to provide a more descriptive name
Franz Glasner <hg@dom66.de>
parents:
134
diff
changeset
|
373 user_filter=get_checked_user_filter_option(opts)) |
|
109
be4811239acf
kwprint: print example file-dependent keywords also.
Franz Glasner <hg@dom66.de>
parents:
108
diff
changeset
|
374 # make file-dependent keywords for an example file |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
375 if not opts.get(b"no_file"): |
|
294
2eb443e77cff
Refactor: put the real keyword printing into a separate function.
Franz Glasner <hg@dom66.de>
parents:
293
diff
changeset
|
376 file_keywords = make_file_keywords( |
|
2eb443e77cff
Refactor: put the real keyword printing into a separate function.
Franz Glasner <hg@dom66.de>
parents:
293
diff
changeset
|
377 keywords, |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
378 b"dir1/dir2/test.file", |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
379 b"a4dd6f4b22e11fec41158eec187630c24a43120a") |
|
294
2eb443e77cff
Refactor: put the real keyword printing into a separate function.
Franz Glasner <hg@dom66.de>
parents:
293
diff
changeset
|
380 else: |
|
2eb443e77cff
Refactor: put the real keyword printing into a separate function.
Franz Glasner <hg@dom66.de>
parents:
293
diff
changeset
|
381 file_keywords = None |
|
2eb443e77cff
Refactor: put the real keyword printing into a separate function.
Franz Glasner <hg@dom66.de>
parents:
293
diff
changeset
|
382 _kwprint_keywords(ui, keywords, file_keywords, |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
383 opts.get(b"reST"), |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
384 opts.get(b"no_file")) |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
385 if opts.get(b"subrepos"): |
|
294
2eb443e77cff
Refactor: put the real keyword printing into a separate function.
Franz Glasner <hg@dom66.de>
parents:
293
diff
changeset
|
386 _kwprint_subrepos(ctx, ui, |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
387 opts.get(b"reST"), |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
388 opts.get(b"no_file"), |
|
294
2eb443e77cff
Refactor: put the real keyword printing into a separate function.
Franz Glasner <hg@dom66.de>
parents:
293
diff
changeset
|
389 path_filter=get_checked_path_filter_option(opts), |
|
2eb443e77cff
Refactor: put the real keyword printing into a separate function.
Franz Glasner <hg@dom66.de>
parents:
293
diff
changeset
|
390 user_filter=get_checked_user_filter_option(opts)) |
|
2eb443e77cff
Refactor: put the real keyword printing into a separate function.
Franz Glasner <hg@dom66.de>
parents:
293
diff
changeset
|
391 |
|
2eb443e77cff
Refactor: put the real keyword printing into a separate function.
Franz Glasner <hg@dom66.de>
parents:
293
diff
changeset
|
392 |
|
2eb443e77cff
Refactor: put the real keyword printing into a separate function.
Franz Glasner <hg@dom66.de>
parents:
293
diff
changeset
|
393 def _kwprint_keywords(ui, keywords, file_keywords, rest, no_file): |
|
2eb443e77cff
Refactor: put the real keyword printing into a separate function.
Franz Glasner <hg@dom66.de>
parents:
293
diff
changeset
|
394 """Print all the prepared keywords into the output""" |
|
45
c077d30da0ee
Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents:
44
diff
changeset
|
395 for key in sorted(keywords.keys()): |
|
294
2eb443e77cff
Refactor: put the real keyword printing into a separate function.
Franz Glasner <hg@dom66.de>
parents:
293
diff
changeset
|
396 if rest: |
|
140
02126a3ad162
FIX: for empty keyword values: write a non-breaking space in reST mode instead of a bogus empty "replace::" value
Franz Glasner <hg@dom66.de>
parents:
137
diff
changeset
|
397 if keywords[key]: |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
398 ui.write(b".. |VCS%s| replace:: %s\n" % (key, keywords[key])) |
|
140
02126a3ad162
FIX: for empty keyword values: write a non-breaking space in reST mode instead of a bogus empty "replace::" value
Franz Glasner <hg@dom66.de>
parents:
137
diff
changeset
|
399 else: |
|
02126a3ad162
FIX: for empty keyword values: write a non-breaking space in reST mode instead of a bogus empty "replace::" value
Franz Glasner <hg@dom66.de>
parents:
137
diff
changeset
|
400 # |
|
02126a3ad162
FIX: for empty keyword values: write a non-breaking space in reST mode instead of a bogus empty "replace::" value
Franz Glasner <hg@dom66.de>
parents:
137
diff
changeset
|
401 # empty replacements are not allowed: |
|
02126a3ad162
FIX: for empty keyword values: write a non-breaking space in reST mode instead of a bogus empty "replace::" value
Franz Glasner <hg@dom66.de>
parents:
137
diff
changeset
|
402 # write a non-breaking space instead |
|
02126a3ad162
FIX: for empty keyword values: write a non-breaking space in reST mode instead of a bogus empty "replace::" value
Franz Glasner <hg@dom66.de>
parents:
137
diff
changeset
|
403 # |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
404 ui.write(b".. |VCS%s| unicode:: 0xA0\n" % key) |
|
78
743dd4a77b4a
Implemented a "--reST" option for printing reST substitution definitions from keywords
Franz Glasner <hg@dom66.de>
parents:
76
diff
changeset
|
405 else: |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
406 ui.write(b"$%s: %s $\n" % (key, keywords[key])) |
|
294
2eb443e77cff
Refactor: put the real keyword printing into a separate function.
Franz Glasner <hg@dom66.de>
parents:
293
diff
changeset
|
407 if not no_file: |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
408 ui.write(b"\n") |
|
109
be4811239acf
kwprint: print example file-dependent keywords also.
Franz Glasner <hg@dom66.de>
parents:
108
diff
changeset
|
409 for key in sorted(file_keywords.keys()): |
|
294
2eb443e77cff
Refactor: put the real keyword printing into a separate function.
Franz Glasner <hg@dom66.de>
parents:
293
diff
changeset
|
410 if rest: |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
411 ui.write(b".. |VCS%s| replace:: %s\n" % (key, file_keywords[key])) |
|
109
be4811239acf
kwprint: print example file-dependent keywords also.
Franz Glasner <hg@dom66.de>
parents:
108
diff
changeset
|
412 else: |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
413 ui.write(b"$%s: %s $\n" % (key, file_keywords[key])) |
|
291
31d5d77c297d
Begin real keyword expansion for subrepos
Franz Glasner <hg@dom66.de>
parents:
290
diff
changeset
|
414 |
|
31d5d77c297d
Begin real keyword expansion for subrepos
Franz Glasner <hg@dom66.de>
parents:
290
diff
changeset
|
415 |
|
294
2eb443e77cff
Refactor: put the real keyword printing into a separate function.
Franz Glasner <hg@dom66.de>
parents:
293
diff
changeset
|
416 def _kwprint_subrepos(ctx, ui, rest, no_file, path_filter, user_filter): |
|
293
75070825d111
- make_node_keywords() and make_keyword_filter() do not need a "repo" argument.
Franz Glasner <hg@dom66.de>
parents:
292
diff
changeset
|
417 """For all subrepos in `ctx` do keyword expansion resursively""" |
|
291
31d5d77c297d
Begin real keyword expansion for subrepos
Franz Glasner <hg@dom66.de>
parents:
290
diff
changeset
|
418 for subpath in sorted(ctx.substate): |
|
295
eeb8c52d8802
The "hg kwprint" command now is fully aware of subrepos if used with the "-S" flag
Franz Glasner <hg@dom66.de>
parents:
294
diff
changeset
|
419 substate = ctx.substate[subpath] |
|
eeb8c52d8802
The "hg kwprint" command now is fully aware of subrepos if used with the "-S" flag
Franz Glasner <hg@dom66.de>
parents:
294
diff
changeset
|
420 # skip on non-Mercurial subrepos |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
421 if substate[2] != b"hg": |
|
295
eeb8c52d8802
The "hg kwprint" command now is fully aware of subrepos if used with the "-S" flag
Franz Glasner <hg@dom66.de>
parents:
294
diff
changeset
|
422 continue |
|
291
31d5d77c297d
Begin real keyword expansion for subrepos
Franz Glasner <hg@dom66.de>
parents:
290
diff
changeset
|
423 subrep = ctx.workingsub(subpath) |
|
31d5d77c297d
Begin real keyword expansion for subrepos
Franz Glasner <hg@dom66.de>
parents:
290
diff
changeset
|
424 subctx = subrep._getctx() |
|
293
75070825d111
- make_node_keywords() and make_keyword_filter() do not need a "repo" argument.
Franz Glasner <hg@dom66.de>
parents:
292
diff
changeset
|
425 assert subctx.repo() == subrep._repo |
|
295
eeb8c52d8802
The "hg kwprint" command now is fully aware of subrepos if used with the "-S" flag
Franz Glasner <hg@dom66.de>
parents:
294
diff
changeset
|
426 keywords = make_node_keywords(ui, subctx, |
|
eeb8c52d8802
The "hg kwprint" command now is fully aware of subrepos if used with the "-S" flag
Franz Glasner <hg@dom66.de>
parents:
294
diff
changeset
|
427 hgpath=None, |
|
eeb8c52d8802
The "hg kwprint" command now is fully aware of subrepos if used with the "-S" flag
Franz Glasner <hg@dom66.de>
parents:
294
diff
changeset
|
428 path_filter=path_filter, |
|
eeb8c52d8802
The "hg kwprint" command now is fully aware of subrepos if used with the "-S" flag
Franz Glasner <hg@dom66.de>
parents:
294
diff
changeset
|
429 user_filter=user_filter, |
|
eeb8c52d8802
The "hg kwprint" command now is fully aware of subrepos if used with the "-S" flag
Franz Glasner <hg@dom66.de>
parents:
294
diff
changeset
|
430 hglocation=substate[0]) |
|
eeb8c52d8802
The "hg kwprint" command now is fully aware of subrepos if used with the "-S" flag
Franz Glasner <hg@dom66.de>
parents:
294
diff
changeset
|
431 if not no_file: |
|
330
793161e48af2
FIX: Remove duplicate assignment to file_keywords
Franz Glasner <fzglas.hg@dom66.de>
parents:
328
diff
changeset
|
432 file_keywords = make_file_keywords( |
|
295
eeb8c52d8802
The "hg kwprint" command now is fully aware of subrepos if used with the "-S" flag
Franz Glasner <hg@dom66.de>
parents:
294
diff
changeset
|
433 keywords, |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
434 b"dir3/dir4/test-s.file", |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
435 b"ffffffff22e11fec41158eec187630c24a43120a") |
|
295
eeb8c52d8802
The "hg kwprint" command now is fully aware of subrepos if used with the "-S" flag
Franz Glasner <hg@dom66.de>
parents:
294
diff
changeset
|
436 else: |
|
eeb8c52d8802
The "hg kwprint" command now is fully aware of subrepos if used with the "-S" flag
Franz Glasner <hg@dom66.de>
parents:
294
diff
changeset
|
437 file_keywords = None |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
438 ui.write(b"\n\n") |
|
295
eeb8c52d8802
The "hg kwprint" command now is fully aware of subrepos if used with the "-S" flag
Franz Glasner <hg@dom66.de>
parents:
294
diff
changeset
|
439 _kwprint_keywords(ui, keywords, file_keywords, rest, no_file) |
|
291
31d5d77c297d
Begin real keyword expansion for subrepos
Franz Glasner <hg@dom66.de>
parents:
290
diff
changeset
|
440 # Recursively check for other subrepos |
|
294
2eb443e77cff
Refactor: put the real keyword printing into a separate function.
Franz Glasner <hg@dom66.de>
parents:
293
diff
changeset
|
441 _kwprint_subrepos(subctx, ui, rest, no_file, path_filter, user_filter) |
|
291
31d5d77c297d
Begin real keyword expansion for subrepos
Franz Glasner <hg@dom66.de>
parents:
290
diff
changeset
|
442 |
|
31d5d77c297d
Begin real keyword expansion for subrepos
Franz Glasner <hg@dom66.de>
parents:
290
diff
changeset
|
443 |
|
31d5d77c297d
Begin real keyword expansion for subrepos
Franz Glasner <hg@dom66.de>
parents:
290
diff
changeset
|
444 def _test_subrepos(ctx, ui): |
|
293
75070825d111
- make_node_keywords() and make_keyword_filter() do not need a "repo" argument.
Franz Glasner <hg@dom66.de>
parents:
292
diff
changeset
|
445 ui.write("STATE: " + repr(subrepo.state(ctx, ui)) + "\n") |
|
291
31d5d77c297d
Begin real keyword expansion for subrepos
Franz Glasner <hg@dom66.de>
parents:
290
diff
changeset
|
446 for subpath in sorted(ctx.substate): |
|
31d5d77c297d
Begin real keyword expansion for subrepos
Franz Glasner <hg@dom66.de>
parents:
290
diff
changeset
|
447 ui.write("SUBPATH: " + subpath + "\n"); |
|
31d5d77c297d
Begin real keyword expansion for subrepos
Franz Glasner <hg@dom66.de>
parents:
290
diff
changeset
|
448 subrep = ctx.workingsub(subpath) |
|
31d5d77c297d
Begin real keyword expansion for subrepos
Franz Glasner <hg@dom66.de>
parents:
290
diff
changeset
|
449 ui.write(repr(subrep) + ": subrelpath=" + subrepo.subrelpath(subrep) |
|
31d5d77c297d
Begin real keyword expansion for subrepos
Franz Glasner <hg@dom66.de>
parents:
290
diff
changeset
|
450 + " reporelpath=" + subrepo.reporelpath(subrep._repo) |
|
31d5d77c297d
Begin real keyword expansion for subrepos
Franz Glasner <hg@dom66.de>
parents:
290
diff
changeset
|
451 + '\n') |
|
31d5d77c297d
Begin real keyword expansion for subrepos
Franz Glasner <hg@dom66.de>
parents:
290
diff
changeset
|
452 # Yes(!) |
|
31d5d77c297d
Begin real keyword expansion for subrepos
Franz Glasner <hg@dom66.de>
parents:
290
diff
changeset
|
453 assert subrepo.subrelpath(subrep) == subrepo.reporelpath(subrep._repo) |
|
31d5d77c297d
Begin real keyword expansion for subrepos
Franz Glasner <hg@dom66.de>
parents:
290
diff
changeset
|
454 assert subrepo.subrelpath(subrep).endswith(subpath) |
|
31d5d77c297d
Begin real keyword expansion for subrepos
Franz Glasner <hg@dom66.de>
parents:
290
diff
changeset
|
455 ui.write(" " + repr(subrep._getctx()) + '\n') |
|
31d5d77c297d
Begin real keyword expansion for subrepos
Franz Glasner <hg@dom66.de>
parents:
290
diff
changeset
|
456 _test_subrepos(subrep._getctx(), ui) |
|
45
c077d30da0ee
Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents:
44
diff
changeset
|
457 |
|
c077d30da0ee
Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents:
44
diff
changeset
|
458 |
|
33
dc8db9693262
kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents:
32
diff
changeset
|
459 def patch_archiver_class(archivername, filter): |
|
32
cfa53f8a6607
Refactor the class' monkey-patching
Franz Glasner <hg@dom66.de>
parents:
31
diff
changeset
|
460 """Patch an archiver class and return the original unbound method""" |
|
cfa53f8a6607
Refactor the class' monkey-patching
Franz Glasner <hg@dom66.de>
parents:
31
diff
changeset
|
461 |
|
cfa53f8a6607
Refactor the class' monkey-patching
Franz Glasner <hg@dom66.de>
parents:
31
diff
changeset
|
462 archiver_class = getattr(archival, archivername) |
|
cfa53f8a6607
Refactor the class' monkey-patching
Franz Glasner <hg@dom66.de>
parents:
31
diff
changeset
|
463 orig_addfile = getattr(archiver_class, "addfile") |
|
cfa53f8a6607
Refactor the class' monkey-patching
Franz Glasner <hg@dom66.de>
parents:
31
diff
changeset
|
464 |
|
287
95c207d21bbf
FIX: Typo in argument: "isline" -> "islink"
Franz Glasner <hg@dom66.de>
parents:
255
diff
changeset
|
465 def new_addfile(self, name, mode, islink, data): |
|
95c207d21bbf
FIX: Typo in argument: "isline" -> "islink"
Franz Glasner <hg@dom66.de>
parents:
255
diff
changeset
|
466 return orig_addfile(self, name, mode, islink, filter(name, data)) |
|
32
cfa53f8a6607
Refactor the class' monkey-patching
Franz Glasner <hg@dom66.de>
parents:
31
diff
changeset
|
467 |
|
cfa53f8a6607
Refactor the class' monkey-patching
Franz Glasner <hg@dom66.de>
parents:
31
diff
changeset
|
468 setattr(archiver_class, "addfile", new_addfile) |
|
cfa53f8a6607
Refactor the class' monkey-patching
Franz Glasner <hg@dom66.de>
parents:
31
diff
changeset
|
469 return orig_addfile |
|
29
58f47399691c
New successful PoC: monkey-patch all relevant archiver's "addfile()" method
Franz Glasner <hg@dom66.de>
parents:
28
diff
changeset
|
470 |
|
28
c8b7d0635656
PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
471 |
|
293
75070825d111
- make_node_keywords() and make_keyword_filter() do not need a "repo" argument.
Franz Glasner <hg@dom66.de>
parents:
292
diff
changeset
|
472 def make_keyword_filter(ui, ctx, archive_class, prefix, |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
473 hgpath=b"default", |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
474 path_filter=b"short", |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
475 user_filter=b"user", |
|
296
15d23729d176
Generate the real filter configuration data in an independent function.
Franz Glasner <hg@dom66.de>
parents:
295
diff
changeset
|
476 subrepos=False, |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
477 kwconfig=b""): |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
478 assert isinstance(archive_class, str), "must be a native string" |
|
296
15d23729d176
Generate the real filter configuration data in an independent function.
Franz Glasner <hg@dom66.de>
parents:
295
diff
changeset
|
479 filterdata_by_subrepos = { |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
480 b'': _make_repo_filterdata(ui, ctx, hgpath, None, kwconfig, |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
481 path_filter, user_filter), |
|
296
15d23729d176
Generate the real filter configuration data in an independent function.
Franz Glasner <hg@dom66.de>
parents:
295
diff
changeset
|
482 } |
|
298
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
483 if subrepos: |
|
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
484 _amend_filterdata_by_subrepos(filterdata_by_subrepos, |
|
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
485 ui, ctx, |
|
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
486 kwconfig, |
|
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
487 path_filter, |
|
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
488 user_filter) |
|
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
489 subrepo_paths = list(filterdata_by_subrepos.keys()) |
|
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
490 subrepo_paths.sort(key=len, reverse=True) |
|
296
15d23729d176
Generate the real filter configuration data in an independent function.
Franz Glasner <hg@dom66.de>
parents:
295
diff
changeset
|
491 |
|
15d23729d176
Generate the real filter configuration data in an independent function.
Franz Glasner <hg@dom66.de>
parents:
295
diff
changeset
|
492 def _filter(name, data): |
|
298
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
493 real_name = rel_name_in_subrepo = name |
|
296
15d23729d176
Generate the real filter configuration data in an independent function.
Franz Glasner <hg@dom66.de>
parents:
295
diff
changeset
|
494 if archive_class != "fileit": |
|
15d23729d176
Generate the real filter configuration data in an independent function.
Franz Glasner <hg@dom66.de>
parents:
295
diff
changeset
|
495 if prefix: |
|
15d23729d176
Generate the real filter configuration data in an independent function.
Franz Glasner <hg@dom66.de>
parents:
295
diff
changeset
|
496 assert name.startswith(prefix) |
|
298
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
497 real_name = rel_name_in_subrepo = name[len(prefix):] |
|
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
498 # find the filterdata configuration corresponding to current subrepo |
|
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
499 for s in subrepo_paths: |
|
296
15d23729d176
Generate the real filter configuration data in an independent function.
Franz Glasner <hg@dom66.de>
parents:
295
diff
changeset
|
500 if real_name.startswith(s): |
|
298
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
501 filterdata = filterdata_by_subrepos[s] |
|
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
502 rel_name_in_subrepo = real_name[len(s):] |
|
296
15d23729d176
Generate the real filter configuration data in an independent function.
Franz Glasner <hg@dom66.de>
parents:
295
diff
changeset
|
503 break |
|
298
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
504 else: |
|
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
505 raise ValueError("invalid subrepo filter data") |
|
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
506 if filterdata is None: |
|
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
507 return data |
|
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
508 matcher, matcher_rcs, matcher_rst, manifest, \ |
|
321
103df4b7a0c8
A new more flexible syntax for custom keyword expansion: with Python template format syntax now
Franz Glasner <fzglas.hg@dom66.de>
parents:
315
diff
changeset
|
509 keyword_substitutions, keywords = filterdata |
|
298
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
510 |
|
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
511 if not matcher(rel_name_in_subrepo): |
|
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
512 #ui.write("NOT MATCHER for " + real_name + " (name: " + name + ") \n") |
|
296
15d23729d176
Generate the real filter configuration data in an independent function.
Franz Glasner <hg@dom66.de>
parents:
295
diff
changeset
|
513 return data |
|
15d23729d176
Generate the real filter configuration data in an independent function.
Franz Glasner <hg@dom66.de>
parents:
295
diff
changeset
|
514 try: |
|
298
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
515 nodeid = node.hex(manifest[rel_name_in_subrepo]) |
|
296
15d23729d176
Generate the real filter configuration data in an independent function.
Franz Glasner <hg@dom66.de>
parents:
295
diff
changeset
|
516 except LookupError: |
|
15d23729d176
Generate the real filter configuration data in an independent function.
Franz Glasner <hg@dom66.de>
parents:
295
diff
changeset
|
517 nodeid = None |
|
15d23729d176
Generate the real filter configuration data in an independent function.
Franz Glasner <hg@dom66.de>
parents:
295
diff
changeset
|
518 # file specific keywords |
|
298
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
519 file_keywords = make_file_keywords( |
|
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
520 keywords, rel_name_in_subrepo, nodeid) |
|
321
103df4b7a0c8
A new more flexible syntax for custom keyword expansion: with Python template format syntax now
Franz Glasner <fzglas.hg@dom66.de>
parents:
315
diff
changeset
|
521 _predef_keywords = keywords.copy() |
|
103df4b7a0c8
A new more flexible syntax for custom keyword expansion: with Python template format syntax now
Franz Glasner <fzglas.hg@dom66.de>
parents:
315
diff
changeset
|
522 _predef_keywords.update(file_keywords) |
|
296
15d23729d176
Generate the real filter configuration data in an independent function.
Franz Glasner <hg@dom66.de>
parents:
295
diff
changeset
|
523 # This prevents unwanted keyword expansion here |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
524 _MARKER_RCS = b'$' |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
525 _MARKER_RST = b'|' |
|
296
15d23729d176
Generate the real filter configuration data in an independent function.
Franz Glasner <hg@dom66.de>
parents:
295
diff
changeset
|
526 for kw, value in itertools.chain(keyword_substitutions.items(), keywords.items(), file_keywords.items()): |
|
15d23729d176
Generate the real filter configuration data in an independent function.
Franz Glasner <hg@dom66.de>
parents:
295
diff
changeset
|
527 # |
|
321
103df4b7a0c8
A new more flexible syntax for custom keyword expansion: with Python template format syntax now
Franz Glasner <fzglas.hg@dom66.de>
parents:
315
diff
changeset
|
528 # Non-empty keyword_substitutions are an implicit whitelist and |
|
103df4b7a0c8
A new more flexible syntax for custom keyword expansion: with Python template format syntax now
Franz Glasner <fzglas.hg@dom66.de>
parents:
315
diff
changeset
|
529 # the value are Python format templates when expanding. |
|
296
15d23729d176
Generate the real filter configuration data in an independent function.
Franz Glasner <hg@dom66.de>
parents:
295
diff
changeset
|
530 # |
|
321
103df4b7a0c8
A new more flexible syntax for custom keyword expansion: with Python template format syntax now
Franz Glasner <fzglas.hg@dom66.de>
parents:
315
diff
changeset
|
531 if keyword_substitutions: |
|
103df4b7a0c8
A new more flexible syntax for custom keyword expansion: with Python template format syntax now
Franz Glasner <fzglas.hg@dom66.de>
parents:
315
diff
changeset
|
532 if kw in keyword_substitutions: |
|
103df4b7a0c8
A new more flexible syntax for custom keyword expansion: with Python template format syntax now
Franz Glasner <fzglas.hg@dom66.de>
parents:
315
diff
changeset
|
533 kwds = [kw] |
|
103df4b7a0c8
A new more flexible syntax for custom keyword expansion: with Python template format syntax now
Franz Glasner <fzglas.hg@dom66.de>
parents:
315
diff
changeset
|
534 if value: |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
535 if not pycompat.ispy3: |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
536 value = value.format(**_predef_keywords) |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
537 else: |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
538 # Assume UTF-8 strings in config files |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
539 _predef_keywords_u = dict((k.decode("utf-8"), v.decode("utf-8")) for k, v in _predef_keywords.items()) |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
540 value = value.decode("utf-8").format(**_predef_keywords_u).encode("utf-8") |
|
321
103df4b7a0c8
A new more flexible syntax for custom keyword expansion: with Python template format syntax now
Franz Glasner <fzglas.hg@dom66.de>
parents:
315
diff
changeset
|
541 else: |
|
103df4b7a0c8
A new more flexible syntax for custom keyword expansion: with Python template format syntax now
Franz Glasner <fzglas.hg@dom66.de>
parents:
315
diff
changeset
|
542 value = _predef_keywords[kw] |
|
103df4b7a0c8
A new more flexible syntax for custom keyword expansion: with Python template format syntax now
Franz Glasner <fzglas.hg@dom66.de>
parents:
315
diff
changeset
|
543 else: |
|
103df4b7a0c8
A new more flexible syntax for custom keyword expansion: with Python template format syntax now
Franz Glasner <fzglas.hg@dom66.de>
parents:
315
diff
changeset
|
544 # not whitelisted -> ignore |
|
103df4b7a0c8
A new more flexible syntax for custom keyword expansion: with Python template format syntax now
Franz Glasner <fzglas.hg@dom66.de>
parents:
315
diff
changeset
|
545 kwds = [] |
|
296
15d23729d176
Generate the real filter configuration data in an independent function.
Franz Glasner <hg@dom66.de>
parents:
295
diff
changeset
|
546 else: |
|
322
950a9bd55d7e
Expand "HGrepoid" as Mercurial's repository id (id of the first commit)
Franz Glasner <fzglas.hg@dom66.de>
parents:
321
diff
changeset
|
547 # Empty keyword_substitutions mean: expand built-in keywords |
|
296
15d23729d176
Generate the real filter configuration data in an independent function.
Franz Glasner <hg@dom66.de>
parents:
295
diff
changeset
|
548 kwds = [kw] |
|
15d23729d176
Generate the real filter configuration data in an independent function.
Franz Glasner <hg@dom66.de>
parents:
295
diff
changeset
|
549 for kw in kwds: |
|
298
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
550 if matcher_rcs(rel_name_in_subrepo): |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
551 filekw = b"%s%s%s" % (_MARKER_RCS, kw, _MARKER_RCS) |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
552 filevalue = b"%s%s: %s %s" \ |
|
296
15d23729d176
Generate the real filter configuration data in an independent function.
Franz Glasner <hg@dom66.de>
parents:
295
diff
changeset
|
553 % (_MARKER_RCS, kw, value, _MARKER_RCS) |
|
15d23729d176
Generate the real filter configuration data in an independent function.
Franz Glasner <hg@dom66.de>
parents:
295
diff
changeset
|
554 data = data.replace(filekw, filevalue) |
|
298
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
555 if matcher_rst(rel_name_in_subrepo): |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
556 filekw = b"%sVCS%s%s" % (_MARKER_RST, kw, _MARKER_RST) |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
557 filevalue = b"%s" % value # always convert to a string |
|
296
15d23729d176
Generate the real filter configuration data in an independent function.
Franz Glasner <hg@dom66.de>
parents:
295
diff
changeset
|
558 data = data.replace(filekw, filevalue) |
|
15d23729d176
Generate the real filter configuration data in an independent function.
Franz Glasner <hg@dom66.de>
parents:
295
diff
changeset
|
559 return data |
|
15d23729d176
Generate the real filter configuration data in an independent function.
Franz Glasner <hg@dom66.de>
parents:
295
diff
changeset
|
560 |
|
15d23729d176
Generate the real filter configuration data in an independent function.
Franz Glasner <hg@dom66.de>
parents:
295
diff
changeset
|
561 return _filter |
|
15d23729d176
Generate the real filter configuration data in an independent function.
Franz Glasner <hg@dom66.de>
parents:
295
diff
changeset
|
562 |
|
15d23729d176
Generate the real filter configuration data in an independent function.
Franz Glasner <hg@dom66.de>
parents:
295
diff
changeset
|
563 |
|
15d23729d176
Generate the real filter configuration data in an independent function.
Franz Glasner <hg@dom66.de>
parents:
295
diff
changeset
|
564 def _make_repo_filterdata(ui, ctx, hgpath, hglocation, kwconfig, |
|
15d23729d176
Generate the real filter configuration data in an independent function.
Franz Glasner <hg@dom66.de>
parents:
295
diff
changeset
|
565 path_filter, user_filter): |
|
293
75070825d111
- make_node_keywords() and make_keyword_filter() do not need a "repo" argument.
Franz Glasner <hg@dom66.de>
parents:
292
diff
changeset
|
566 keywords = make_node_keywords(ui, ctx, |
|
51
3807a60ee0dd
Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents:
47
diff
changeset
|
567 hgpath=hgpath, |
|
93
fa84debfb50e
Replace "no-shorten-url" by "path-filter"
Franz Glasner <hg@dom66.de>
parents:
92
diff
changeset
|
568 path_filter=path_filter, |
|
298
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
569 user_filter=user_filter, |
|
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
570 hglocation=hglocation) |
|
47
94ae433383a2
Allow an alternate patterns file (instead of .hgkwarchive) with the --kwconfig option.
Franz Glasner <hg@dom66.de>
parents:
46
diff
changeset
|
571 kwconfigdata = kwconfigname = None |
|
94ae433383a2
Allow an alternate patterns file (instead of .hgkwarchive) with the --kwconfig option.
Franz Glasner <hg@dom66.de>
parents:
46
diff
changeset
|
572 if kwconfig: |
|
157
e12025e46375
Use util.posixfile when reading a custom given .hgkwarchive file for Mercurial portability reasons
Franz Glasner <hg@dom66.de>
parents:
156
diff
changeset
|
573 kwconfigdata = util.posixfile(kwconfig, "rb").read() |
|
47
94ae433383a2
Allow an alternate patterns file (instead of .hgkwarchive) with the --kwconfig option.
Franz Glasner <hg@dom66.de>
parents:
46
diff
changeset
|
574 kwconfigname = kwconfig |
|
33
dc8db9693262
kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents:
32
diff
changeset
|
575 try: |
|
47
94ae433383a2
Allow an alternate patterns file (instead of .hgkwarchive) with the --kwconfig option.
Franz Glasner <hg@dom66.de>
parents:
46
diff
changeset
|
576 if kwconfigdata is None: |
|
156
d92850f876a4
Use a constant to define the ".hgkwarchive" name
Franz Glasner <hg@dom66.de>
parents:
155
diff
changeset
|
577 # use versioned .hgkwarchive |
|
d92850f876a4
Use a constant to define the ".hgkwarchive" name
Franz Glasner <hg@dom66.de>
parents:
155
diff
changeset
|
578 kwconfigdata = ctx[KWARCHIVE_CONFIG].data() |
|
d92850f876a4
Use a constant to define the ".hgkwarchive" name
Franz Glasner <hg@dom66.de>
parents:
155
diff
changeset
|
579 kwconfigname = KWARCHIVE_CONFIG |
|
33
dc8db9693262
kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents:
32
diff
changeset
|
580 except (IOError, LookupError): |
|
296
15d23729d176
Generate the real filter configuration data in an independent function.
Franz Glasner <hg@dom66.de>
parents:
295
diff
changeset
|
581 # sigil for no keyword expansion configured -> filter is pass-through |
|
15d23729d176
Generate the real filter configuration data in an independent function.
Franz Glasner <hg@dom66.de>
parents:
295
diff
changeset
|
582 return None |
|
33
dc8db9693262
kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents:
32
diff
changeset
|
583 else: |
|
44
71b321436cc1
Refactor: generate all node-specific keywords (file-path independent) in a dedicated function
Franz Glasner <hg@dom66.de>
parents:
42
diff
changeset
|
584 # |
|
71b321436cc1
Refactor: generate all node-specific keywords (file-path independent) in a dedicated function
Franz Glasner <hg@dom66.de>
parents:
42
diff
changeset
|
585 # Parse the data in ".hgkwarchive" and generate a |
|
71b321436cc1
Refactor: generate all node-specific keywords (file-path independent) in a dedicated function
Franz Glasner <hg@dom66.de>
parents:
42
diff
changeset
|
586 # Mercurial matcher |
|
71b321436cc1
Refactor: generate all node-specific keywords (file-path independent) in a dedicated function
Franz Glasner <hg@dom66.de>
parents:
42
diff
changeset
|
587 # |
|
33
dc8db9693262
kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents:
32
diff
changeset
|
588 cfg = config.config() |
|
47
94ae433383a2
Allow an alternate patterns file (instead of .hgkwarchive) with the --kwconfig option.
Franz Glasner <hg@dom66.de>
parents:
46
diff
changeset
|
589 cfg.parse(kwconfigname, kwconfigdata) |
|
33
dc8db9693262
kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents:
32
diff
changeset
|
590 include = [] |
|
dc8db9693262
kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents:
32
diff
changeset
|
591 exclude = [] |
|
dc8db9693262
kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents:
32
diff
changeset
|
592 patterns = [] |
|
118
e9c78a0bfe6a
Allow multiple style keyword expansion in one file.
Franz Glasner <hg@dom66.de>
parents:
116
diff
changeset
|
593 patterns_rcs = [] |
|
79
53c9f2f6a13e
Work in reST style keywords in kwarchive
Franz Glasner <hg@dom66.de>
parents:
78
diff
changeset
|
594 patterns_rst = [] |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
595 if cfg.items(b"patterns"): |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
596 for pattern, styles in cfg.items(b"patterns"): |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
597 styles = [s.strip() for s in styles.upper().split(b',')] |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
598 if b"YES" in styles or b"INCLUDE" in styles: |
|
33
dc8db9693262
kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents:
32
diff
changeset
|
599 include.append(pattern) |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
600 elif b"NO" in styles or b"EXCLUDE" in styles: |
|
33
dc8db9693262
kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents:
32
diff
changeset
|
601 exclude.append(pattern) |
|
dc8db9693262
kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents:
32
diff
changeset
|
602 else: |
|
dc8db9693262
kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents:
32
diff
changeset
|
603 patterns.append(pattern) |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
604 if b"REST" in styles or b"RST" in styles \ |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
605 or b"RCS" in styles: |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
606 if b"RCS" in styles: |
|
118
e9c78a0bfe6a
Allow multiple style keyword expansion in one file.
Franz Glasner <hg@dom66.de>
parents:
116
diff
changeset
|
607 patterns_rcs.append(pattern) |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
608 if b"REST" in styles or b"RST" in styles: |
|
118
e9c78a0bfe6a
Allow multiple style keyword expansion in one file.
Franz Glasner <hg@dom66.de>
parents:
116
diff
changeset
|
609 patterns_rst.append(pattern) |
|
e9c78a0bfe6a
Allow multiple style keyword expansion in one file.
Franz Glasner <hg@dom66.de>
parents:
116
diff
changeset
|
610 else: |
|
e9c78a0bfe6a
Allow multiple style keyword expansion in one file.
Franz Glasner <hg@dom66.de>
parents:
116
diff
changeset
|
611 # default to RCS if no keyword style is given |
|
e9c78a0bfe6a
Allow multiple style keyword expansion in one file.
Franz Glasner <hg@dom66.de>
parents:
116
diff
changeset
|
612 patterns_rcs.append(pattern) |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
613 matcher = match.match(ctx.repo().root, b'', patterns=patterns, |
|
33
dc8db9693262
kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents:
32
diff
changeset
|
614 include=include, exclude=exclude) |
|
91
36369940d31b
FIX: An empty pattern list for RST style keywords does **not** mean that matching it is always true
Franz Glasner <hg@dom66.de>
parents:
88
diff
changeset
|
615 else: |
|
349
0d889720613d
FIX: Mercurial 5 does not accept "root" and "cwd" for match.exact and friends: make a compatibility shim
Franz Glasner <fzglas.hg@dom66.de>
parents:
348
diff
changeset
|
616 matcher = _matchmod_never(ctx.repo().root, b'') |
|
118
e9c78a0bfe6a
Allow multiple style keyword expansion in one file.
Franz Glasner <hg@dom66.de>
parents:
116
diff
changeset
|
617 |
|
e9c78a0bfe6a
Allow multiple style keyword expansion in one file.
Franz Glasner <hg@dom66.de>
parents:
116
diff
changeset
|
618 # |
|
e9c78a0bfe6a
Allow multiple style keyword expansion in one file.
Franz Glasner <hg@dom66.de>
parents:
116
diff
changeset
|
619 # An empty patterns_rcs does not mean that match_rcs is always |
|
e9c78a0bfe6a
Allow multiple style keyword expansion in one file.
Franz Glasner <hg@dom66.de>
parents:
116
diff
changeset
|
620 # true. |
|
e9c78a0bfe6a
Allow multiple style keyword expansion in one file.
Franz Glasner <hg@dom66.de>
parents:
116
diff
changeset
|
621 # |
|
e9c78a0bfe6a
Allow multiple style keyword expansion in one file.
Franz Glasner <hg@dom66.de>
parents:
116
diff
changeset
|
622 if not patterns_rcs: |
|
349
0d889720613d
FIX: Mercurial 5 does not accept "root" and "cwd" for match.exact and friends: make a compatibility shim
Franz Glasner <fzglas.hg@dom66.de>
parents:
348
diff
changeset
|
623 matcher_rcs = _matchmod_never(ctx.repo().root, b'') |
|
118
e9c78a0bfe6a
Allow multiple style keyword expansion in one file.
Franz Glasner <hg@dom66.de>
parents:
116
diff
changeset
|
624 else: |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
625 matcher_rcs = match.match(ctx.repo().root, b'', |
|
293
75070825d111
- make_node_keywords() and make_keyword_filter() do not need a "repo" argument.
Franz Glasner <hg@dom66.de>
parents:
292
diff
changeset
|
626 patterns=patterns_rcs, |
|
118
e9c78a0bfe6a
Allow multiple style keyword expansion in one file.
Franz Glasner <hg@dom66.de>
parents:
116
diff
changeset
|
627 include=[], exclude=[]) |
|
91
36369940d31b
FIX: An empty pattern list for RST style keywords does **not** mean that matching it is always true
Franz Glasner <hg@dom66.de>
parents:
88
diff
changeset
|
628 # |
|
36369940d31b
FIX: An empty pattern list for RST style keywords does **not** mean that matching it is always true
Franz Glasner <hg@dom66.de>
parents:
88
diff
changeset
|
629 # An empty patterns_rst does not mean that match_rst is always |
|
36369940d31b
FIX: An empty pattern list for RST style keywords does **not** mean that matching it is always true
Franz Glasner <hg@dom66.de>
parents:
88
diff
changeset
|
630 # true. |
|
36369940d31b
FIX: An empty pattern list for RST style keywords does **not** mean that matching it is always true
Franz Glasner <hg@dom66.de>
parents:
88
diff
changeset
|
631 # |
|
36369940d31b
FIX: An empty pattern list for RST style keywords does **not** mean that matching it is always true
Franz Glasner <hg@dom66.de>
parents:
88
diff
changeset
|
632 if not patterns_rst: |
|
349
0d889720613d
FIX: Mercurial 5 does not accept "root" and "cwd" for match.exact and friends: make a compatibility shim
Franz Glasner <fzglas.hg@dom66.de>
parents:
348
diff
changeset
|
633 matcher_rst = _matchmod_never(ctx.repo().root, b'') |
|
91
36369940d31b
FIX: An empty pattern list for RST style keywords does **not** mean that matching it is always true
Franz Glasner <hg@dom66.de>
parents:
88
diff
changeset
|
634 else: |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
635 matcher_rst = match.match(ctx.repo().root, b'', |
|
293
75070825d111
- make_node_keywords() and make_keyword_filter() do not need a "repo" argument.
Franz Glasner <hg@dom66.de>
parents:
292
diff
changeset
|
636 patterns=patterns_rst, |
|
79
53c9f2f6a13e
Work in reST style keywords in kwarchive
Franz Glasner <hg@dom66.de>
parents:
78
diff
changeset
|
637 include=[], exclude=[]) |
|
33
dc8db9693262
kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents:
32
diff
changeset
|
638 |
|
104
65789e3e8e3d
Provide a "HGnodeid" per file keyword that expands to the NodeID of the artifact.
Franz Glasner <hg@dom66.de>
parents:
103
diff
changeset
|
639 # |
|
321
103df4b7a0c8
A new more flexible syntax for custom keyword expansion: with Python template format syntax now
Franz Glasner <fzglas.hg@dom66.de>
parents:
315
diff
changeset
|
640 # This are the settings of the [keywords] section in .hgkwarchive. |
|
103df4b7a0c8
A new more flexible syntax for custom keyword expansion: with Python template format syntax now
Franz Glasner <fzglas.hg@dom66.de>
parents:
315
diff
changeset
|
641 # An empty section means: all default keywords are enabled. |
|
103df4b7a0c8
A new more flexible syntax for custom keyword expansion: with Python template format syntax now
Franz Glasner <fzglas.hg@dom66.de>
parents:
315
diff
changeset
|
642 # Otherwise only the given keywords are enabled with their expanded |
|
103df4b7a0c8
A new more flexible syntax for custom keyword expansion: with Python template format syntax now
Franz Glasner <fzglas.hg@dom66.de>
parents:
315
diff
changeset
|
643 # values on the right side. An empty right side means: use the default |
|
103df4b7a0c8
A new more flexible syntax for custom keyword expansion: with Python template format syntax now
Franz Glasner <fzglas.hg@dom66.de>
parents:
315
diff
changeset
|
644 # expansion. |
|
133
8d16138e00af
Implemented substitution type keyword expansion
Franz Glasner <hg@dom66.de>
parents:
131
diff
changeset
|
645 # |
|
8d16138e00af
Implemented substitution type keyword expansion
Franz Glasner <hg@dom66.de>
parents:
131
diff
changeset
|
646 keyword_substitutions = {} |
|
8d16138e00af
Implemented substitution type keyword expansion
Franz Glasner <hg@dom66.de>
parents:
131
diff
changeset
|
647 |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
648 for alias, value in cfg.items(b"keywords"): |
|
321
103df4b7a0c8
A new more flexible syntax for custom keyword expansion: with Python template format syntax now
Franz Glasner <fzglas.hg@dom66.de>
parents:
315
diff
changeset
|
649 keyword_substitutions[alias] = value |
|
122
e6037655967b
Implemented a keyword white-list including aliases.
Franz Glasner <hg@dom66.de>
parents:
120
diff
changeset
|
650 |
|
e6037655967b
Implemented a keyword white-list including aliases.
Franz Glasner <hg@dom66.de>
parents:
120
diff
changeset
|
651 # |
|
104
65789e3e8e3d
Provide a "HGnodeid" per file keyword that expands to the NodeID of the artifact.
Franz Glasner <hg@dom66.de>
parents:
103
diff
changeset
|
652 # Get the manifest to be able to determine a file's NodeId |
|
65789e3e8e3d
Provide a "HGnodeid" per file keyword that expands to the NodeID of the artifact.
Franz Glasner <hg@dom66.de>
parents:
103
diff
changeset
|
653 # |
|
65789e3e8e3d
Provide a "HGnodeid" per file keyword that expands to the NodeID of the artifact.
Franz Glasner <hg@dom66.de>
parents:
103
diff
changeset
|
654 manifest = ctx.manifest() |
|
65789e3e8e3d
Provide a "HGnodeid" per file keyword that expands to the NodeID of the artifact.
Franz Glasner <hg@dom66.de>
parents:
103
diff
changeset
|
655 |
|
296
15d23729d176
Generate the real filter configuration data in an independent function.
Franz Glasner <hg@dom66.de>
parents:
295
diff
changeset
|
656 return (matcher, matcher_rcs, matcher_rst, |
|
15d23729d176
Generate the real filter configuration data in an independent function.
Franz Glasner <hg@dom66.de>
parents:
295
diff
changeset
|
657 manifest, |
|
321
103df4b7a0c8
A new more flexible syntax for custom keyword expansion: with Python template format syntax now
Franz Glasner <fzglas.hg@dom66.de>
parents:
315
diff
changeset
|
658 keyword_substitutions, keywords,) |
|
44
71b321436cc1
Refactor: generate all node-specific keywords (file-path independent) in a dedicated function
Franz Glasner <hg@dom66.de>
parents:
42
diff
changeset
|
659 |
|
71b321436cc1
Refactor: generate all node-specific keywords (file-path independent) in a dedicated function
Franz Glasner <hg@dom66.de>
parents:
42
diff
changeset
|
660 |
|
298
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
661 def _amend_filterdata_by_subrepos(filterdata_by_subrepos, |
|
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
662 ui, |
|
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
663 ctx, |
|
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
664 kwconfig, |
|
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
665 path_filter, user_filter): |
|
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
666 |
|
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
667 for subpath in sorted(ctx.substate): |
|
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
668 substate = ctx.substate[subpath] |
|
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
669 # skip on non-Mercurial subrepos |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
670 if substate[2] != b"hg": |
|
298
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
671 continue |
|
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
672 subrep = ctx.workingsub(subpath) |
|
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
673 subctx = subrep._getctx() |
|
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
674 |
|
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
675 # Really amend |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
676 filterdata_by_subrepos[subrepo.subrelpath(subrep) + b'/'] = \ |
|
298
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
677 _make_repo_filterdata(ui, subctx, None, substate[0], kwconfig, |
|
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
678 path_filter, user_filter) |
|
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
679 |
|
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
680 # Recursively check for other subrepos |
|
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
681 _amend_filterdata_by_subrepos(filterdata_by_subrepos, |
|
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
682 ui, subctx, |
|
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
683 kwconfig, |
|
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
684 path_filter, user_filter) |
|
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
685 |
|
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
686 |
|
293
75070825d111
- make_node_keywords() and make_keyword_filter() do not need a "repo" argument.
Franz Glasner <hg@dom66.de>
parents:
292
diff
changeset
|
687 def make_node_keywords(ui, ctx, |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
688 hgpath=b"default", |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
689 path_filter=b"short", |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
690 user_filter=b"user", |
|
295
eeb8c52d8802
The "hg kwprint" command now is fully aware of subrepos if used with the "-S" flag
Franz Glasner <hg@dom66.de>
parents:
294
diff
changeset
|
691 hglocation=None): |
|
44
71b321436cc1
Refactor: generate all node-specific keywords (file-path independent) in a dedicated function
Franz Glasner <hg@dom66.de>
parents:
42
diff
changeset
|
692 """Make all the node-specific (i.e. file-path independent) keywords |
|
71b321436cc1
Refactor: generate all node-specific keywords (file-path independent) in a dedicated function
Franz Glasner <hg@dom66.de>
parents:
42
diff
changeset
|
693 |
|
71b321436cc1
Refactor: generate all node-specific keywords (file-path independent) in a dedicated function
Franz Glasner <hg@dom66.de>
parents:
42
diff
changeset
|
694 """ |
|
342
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
695 if path_filter == b"repo": |
|
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
696 path_uri = b"repo:" + ctx.repo()[ctx.repo().lookup(b'0')].hex() |
|
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
697 elif path_filter == b"reposhort": |
|
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
698 path_uri = b"repo:" + templatefilters.short( |
|
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
699 ctx.repo()[ctx.repo().lookup(b'0')].hex()) |
|
44
71b321436cc1
Refactor: generate all node-specific keywords (file-path independent) in a dedicated function
Franz Glasner <hg@dom66.de>
parents:
42
diff
changeset
|
700 else: |
|
342
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
701 if (hglocation is not None) and hgpath: |
|
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
702 raise ValueError("either `hgpath' or `hglocation` can be set") |
|
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
703 if (hglocation is not None) or (hgpath and hgpath != b"."): |
|
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
704 if hglocation is None: |
|
420
43fd36a465cc
Make revinfo and kwarchive compatible to Mercurial 5.8: ui.paths yields now a list of location objects
Franz Glasner <fzglas.hg@dom66.de>
parents:
357
diff
changeset
|
705 # |
|
43fd36a465cc
Make revinfo and kwarchive compatible to Mercurial 5.8: ui.paths yields now a list of location objects
Franz Glasner <fzglas.hg@dom66.de>
parents:
357
diff
changeset
|
706 # Since Mercurial 5.8 ui.paths[n] yields a list of |
|
43fd36a465cc
Make revinfo and kwarchive compatible to Mercurial 5.8: ui.paths yields now a list of location objects
Franz Glasner <fzglas.hg@dom66.de>
parents:
357
diff
changeset
|
707 # locations |
|
43fd36a465cc
Make revinfo and kwarchive compatible to Mercurial 5.8: ui.paths yields now a list of location objects
Franz Glasner <fzglas.hg@dom66.de>
parents:
357
diff
changeset
|
708 # |
|
43fd36a465cc
Make revinfo and kwarchive compatible to Mercurial 5.8: ui.paths yields now a list of location objects
Franz Glasner <fzglas.hg@dom66.de>
parents:
357
diff
changeset
|
709 locations = ui.paths[hgpath] |
|
43fd36a465cc
Make revinfo and kwarchive compatible to Mercurial 5.8: ui.paths yields now a list of location objects
Franz Glasner <fzglas.hg@dom66.de>
parents:
357
diff
changeset
|
710 if isinstance(locations, list): |
|
43fd36a465cc
Make revinfo and kwarchive compatible to Mercurial 5.8: ui.paths yields now a list of location objects
Franz Glasner <fzglas.hg@dom66.de>
parents:
357
diff
changeset
|
711 # for now a quick check of assumptions |
|
43fd36a465cc
Make revinfo and kwarchive compatible to Mercurial 5.8: ui.paths yields now a list of location objects
Franz Glasner <fzglas.hg@dom66.de>
parents:
357
diff
changeset
|
712 assert len(locations) == 1 |
|
43fd36a465cc
Make revinfo and kwarchive compatible to Mercurial 5.8: ui.paths yields now a list of location objects
Franz Glasner <fzglas.hg@dom66.de>
parents:
357
diff
changeset
|
713 hglocation = locations[0].loc |
|
43fd36a465cc
Make revinfo and kwarchive compatible to Mercurial 5.8: ui.paths yields now a list of location objects
Franz Glasner <fzglas.hg@dom66.de>
parents:
357
diff
changeset
|
714 else: |
|
43fd36a465cc
Make revinfo and kwarchive compatible to Mercurial 5.8: ui.paths yields now a list of location objects
Franz Glasner <fzglas.hg@dom66.de>
parents:
357
diff
changeset
|
715 hglocation = locations.loc |
|
342
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
716 try: |
|
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
717 if path_filter == b"full": |
|
425
2a062f87f75d
Make "revinfo" and "kwarchive" work on Mercurial 6.
Franz Glasner <fzglas.hg@dom66.de>
parents:
424
diff
changeset
|
718 path_uri = bytes(_urlutil.url(hglocation)) |
|
342
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
719 elif path_filter == b"nopwd": |
|
425
2a062f87f75d
Make "revinfo" and "kwarchive" work on Mercurial 6.
Franz Glasner <fzglas.hg@dom66.de>
parents:
424
diff
changeset
|
720 path_uri = _urlutil.hidepassword(hglocation) |
|
342
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
721 elif path_filter == b"nouser": |
|
425
2a062f87f75d
Make "revinfo" and "kwarchive" work on Mercurial 6.
Franz Glasner <fzglas.hg@dom66.de>
parents:
424
diff
changeset
|
722 path_url = _urlutil.url(hglocation) |
|
342
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
723 path_url.user = None |
|
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
724 path_url.passwd = None |
|
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
725 path_uri = bytes(path_url) |
|
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
726 elif path_filter == b"short": |
|
425
2a062f87f75d
Make "revinfo" and "kwarchive" work on Mercurial 6.
Franz Glasner <fzglas.hg@dom66.de>
parents:
424
diff
changeset
|
727 path_url = _urlutil.url(hglocation) |
|
342
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
728 path_url.scheme = SHORTENED_HG_SCHEMES.get(path_url.scheme, |
|
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
729 b"hg") |
|
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
730 path_url.user = None |
|
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
731 path_url.passwd = None |
|
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
732 path_url.host = stripped_hostname(path_url.host) |
|
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
733 path_url.port = None |
|
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
734 path_uri = bytes(path_url) |
|
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
735 elif path_filter == b"last": |
|
425
2a062f87f75d
Make "revinfo" and "kwarchive" work on Mercurial 6.
Franz Glasner <fzglas.hg@dom66.de>
parents:
424
diff
changeset
|
736 path_url = str(_urlutil.url(hglocation)).split('/') |
|
342
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
737 path_uri = pycompat.sysbytes(".../"+path_url[-1]) |
|
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
738 else: |
|
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
739 raise error.Abort(b"path-filter `%s' not implemented" |
|
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
740 % path_filter) |
|
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
741 except LookupError: |
|
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
742 raise error.Abort( |
|
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
743 _(b"remote repository named `%s' not found") % hgpath) |
|
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
744 else: |
|
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
745 path_uri = ctx.repo().root |
|
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
746 if path_filter == b"last": |
|
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
747 m = max(path_uri.rfind(b"/"), path_uri.rfind(b"\\")) |
|
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
748 if m >= 0: |
|
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
749 path_uri = b".../" + path_uri[m+1:] |
|
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
750 if path_uri.startswith(b"\\\\"): |
|
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
751 # Make an URL from a Windows UNC path |
|
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
752 path_uri = b"file:///" + path_uri.replace(b'\\', b'/') |
|
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
753 elif len(path_uri) >= 2 \ |
|
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
754 and ((pycompat.ispy3 and ((b'A' <= pycompat.bytechr(path_uri[0]) <= b'Z') or (b'a' <= pycompat.bytechr(path_uri[0]) <= b'z'))) or ((not pycompat.ispy3 and (b'A' <= path_uri[0].upper() <= b'Z')))) \ |
|
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
755 and path_uri[1] == b':': |
|
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
756 # make an URL from a Windows path with drive letter |
|
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
757 path_uri = b"file:///" + path_uri.replace(b'\\', b'/') |
|
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
758 elif path_uri.startswith(b'/'): |
|
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
759 # an absolute POSIX path |
|
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
760 path_uri = b"file://" + path_uri |
|
304
71288cb43ba9
kwarchive: Make it work with Mercurial 4.6+ (really tested on 4.8.1).
Franz Glasner <hg@dom66.de>
parents:
300
diff
changeset
|
761 if context_mapping_api: |
|
71288cb43ba9
kwarchive: Make it work with Mercurial 4.6+ (really tested on 4.8.1).
Franz Glasner <hg@dom66.de>
parents:
300
diff
changeset
|
762 mapping = { |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
763 b'repo': ctx.repo(), |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
764 b'ctx': ctx, |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
765 b'cache': {} |
|
304
71288cb43ba9
kwarchive: Make it work with Mercurial 4.6+ (really tested on 4.8.1).
Franz Glasner <hg@dom66.de>
parents:
300
diff
changeset
|
766 } |
|
71288cb43ba9
kwarchive: Make it work with Mercurial 4.6+ (really tested on 4.8.1).
Franz Glasner <hg@dom66.de>
parents:
300
diff
changeset
|
767 latesttags = templatekw.getlatesttags(_FakeRenderContext(), mapping) |
|
71288cb43ba9
kwarchive: Make it work with Mercurial 4.6+ (really tested on 4.8.1).
Franz Glasner <hg@dom66.de>
parents:
300
diff
changeset
|
768 else: |
|
71288cb43ba9
kwarchive: Make it work with Mercurial 4.6+ (really tested on 4.8.1).
Franz Glasner <hg@dom66.de>
parents:
300
diff
changeset
|
769 latesttags = templatekw.getlatesttags(ctx.repo(), ctx, {}) |
|
44
71b321436cc1
Refactor: generate all node-specific keywords (file-path independent) in a dedicated function
Franz Glasner <hg@dom66.de>
parents:
42
diff
changeset
|
770 keywords = { |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
771 b"HGrepoid": ctx.repo()[ctx.repo().lookup(b'0')].hex(), # repo id |
|
338
038cca685729
Add a short representation of the repo id with name "HGshortrepoid"
Franz Glasner <hg@dom66.de>
parents:
337
diff
changeset
|
772 b"HGshortrepoid": templatefilters.short(ctx.repo()[ctx.repo().lookup(b'0')].hex()), # short form of the repo id |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
773 b"HGpath": path_uri, # XXX FIXME: Should Archive an alias of this |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
774 b"HGbranch": ctx.branch(), |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
775 b"HGtags": b' '.join([tag for tag in ctx.tags() if tag != b"tip"]), |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
776 b"HGlatesttags": b" ".join(latesttags[2]), |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
777 b"HGlatesttagdistance": pycompat.sysbytes(str(latesttags[1])), |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
778 b"HGlatesttagdate": templatefilters.isodatesec(_dateutil.makedate(latesttags[0])), |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
779 b"HGlatesttagjustdate": templatefilters.shortdate(_dateutil.makedate(latesttags[0])), |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
780 b"HGbookmarks": b' '.join([bm if not bm.startswith(b'*') else bm[1:] |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
781 for bm in ctx.bookmarks() if bm != b"@"]), |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
782 b"State": ctx.phasestr(), |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
783 b"HGrevision": ctx.hex(), |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
784 b"Revision": templatefilters.short(ctx.hex()), |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
785 b"Date": templatefilters.isodatesec(ctx.date()), |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
786 b"JustDate": templatefilters.shortdate(ctx.date()), |
|
115
06a60e2a9887
Added "JustDate" (from Visual Source Safe and Surround SCM) as date only keyword
Franz Glasner <hg@dom66.de>
parents:
114
diff
changeset
|
787 # compatibility alias for `JustDate' |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
788 b"HGshortdate": templatefilters.shortdate(ctx.date()), |
|
44
71b321436cc1
Refactor: generate all node-specific keywords (file-path independent) in a dedicated function
Franz Glasner <hg@dom66.de>
parents:
42
diff
changeset
|
789 } |
|
435
7fd26761565b
Provide keywords with some alternate date format: Y/m/d instead of Y-m-d.
Franz Glasner <fzglas.hg@dom66.de>
parents:
432
diff
changeset
|
790 keywords[b"Date2"] = keywords[b"Date"].replace(b"-", b"/", 2) |
|
7fd26761565b
Provide keywords with some alternate date format: Y/m/d instead of Y-m-d.
Franz Glasner <fzglas.hg@dom66.de>
parents:
432
diff
changeset
|
791 keywords[b"JustDate2"] = keywords[b"JustDate"].replace(b"-", b"/", 2) |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
792 if user_filter == b"user": |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
793 keywords[b"Author"] = templatefilters.emailuser(ctx.user()) |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
794 elif user_filter == b"person": |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
795 keywords[b"Author"] = templatefilters.utf8( |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
796 templatefilters.person(ctx.user()).replace(b' ', b'+')) |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
797 elif user_filter == b"email": |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
798 keywords[b"Author"] = templatefilters.email(ctx.user()) |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
799 elif user_filter in (b"full", b"none",): |
|
81
e02aceb91a9b
Make "full" a user filter and "none" an alias to "full"
Franz Glasner <hg@dom66.de>
parents:
80
diff
changeset
|
800 # |
|
e02aceb91a9b
Make "full" a user filter and "none" an alias to "full"
Franz Glasner <hg@dom66.de>
parents:
80
diff
changeset
|
801 # "none" is retained for compatibility reasons and now an |
|
e02aceb91a9b
Make "full" a user filter and "none" an alias to "full"
Franz Glasner <hg@dom66.de>
parents:
80
diff
changeset
|
802 # alias for "full". |
|
e02aceb91a9b
Make "full" a user filter and "none" an alias to "full"
Franz Glasner <hg@dom66.de>
parents:
80
diff
changeset
|
803 # But make it **one** word because that is meant in the RCS spec. |
|
e02aceb91a9b
Make "full" a user filter and "none" an alias to "full"
Franz Glasner <hg@dom66.de>
parents:
80
diff
changeset
|
804 # |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
805 keywords[b"Author"] = templatefilters.utf8(ctx.user().replace(b' ', b'+')) |
|
81
e02aceb91a9b
Make "full" a user filter and "none" an alias to "full"
Franz Glasner <hg@dom66.de>
parents:
80
diff
changeset
|
806 else: |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
807 raise error.Abort(_(b"unknown user filter")) |
|
65
bdb549d71148
Allow customization of the $Author$ output when expanding keywords.
Franz Glasner <hg@dom66.de>
parents:
64
diff
changeset
|
808 |
|
44
71b321436cc1
Refactor: generate all node-specific keywords (file-path independent) in a dedicated function
Franz Glasner <hg@dom66.de>
parents:
42
diff
changeset
|
809 return keywords |
|
51
3807a60ee0dd
Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents:
47
diff
changeset
|
810 |
|
3807a60ee0dd
Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents:
47
diff
changeset
|
811 |
|
298
aa945541d2ca
kwarchive: fully implements recursing into Mercurial subrepos and do keyword expansion there also
Franz Glasner <hg@dom66.de>
parents:
296
diff
changeset
|
812 def make_file_keywords(keywords, rel_name, nodeid): |
|
109
be4811239acf
kwprint: print example file-dependent keywords also.
Franz Glasner <hg@dom66.de>
parents:
108
diff
changeset
|
813 return { |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
814 b"HGsource": keywords[b"HGpath"] + b'/' + rel_name, |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
815 b"Source": rel_name, |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
816 b"File": templatefilters.basename(rel_name), |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
817 b"Header": b"%s %s %s %s %s" % (rel_name, keywords[b"Revision"], keywords[b"Date"], keywords[b"Author"], keywords[b"State"]), |
|
435
7fd26761565b
Provide keywords with some alternate date format: Y/m/d instead of Y-m-d.
Franz Glasner <fzglas.hg@dom66.de>
parents:
432
diff
changeset
|
818 b"Header2": b"%s %s %s %s %s" % (rel_name, keywords[b"Revision"], keywords[b"Date2"], keywords[b"Author"], keywords[b"State"]), |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
819 b"HGid": b"%s %s %s %s %s" % (keywords[b"HGpath"] + b'/' + rel_name, keywords[b"Revision"], keywords[b"Date"], keywords[b"Author"], keywords[b"State"]), |
|
435
7fd26761565b
Provide keywords with some alternate date format: Y/m/d instead of Y-m-d.
Franz Glasner <fzglas.hg@dom66.de>
parents:
432
diff
changeset
|
820 b"HGid2": b"%s %s %s %s %s" % (keywords[b"HGpath"] + b'/' + rel_name, keywords[b"Revision"], keywords[b"Date2"], keywords[b"Author"], keywords[b"State"]), |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
821 b"HGheader": b"%s %s %s %s %s" % (keywords[b"HGpath"] + b'/' + rel_name, keywords[b"HGrevision"], keywords[b"Date"], keywords[b"Author"], keywords[b"State"]), |
|
435
7fd26761565b
Provide keywords with some alternate date format: Y/m/d instead of Y-m-d.
Franz Glasner <fzglas.hg@dom66.de>
parents:
432
diff
changeset
|
822 b"HGheader2": b"%s %s %s %s %s" % (keywords[b"HGpath"] + b'/' + rel_name, keywords[b"HGrevision"], keywords[b"Date2"], keywords[b"Author"], keywords[b"State"]), |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
823 b"Id": b"%s %s %s %s %s" % (templatefilters.basename(rel_name), keywords[b"Revision"], keywords[b"Date"], keywords[b"Author"], keywords[b"State"]), |
|
435
7fd26761565b
Provide keywords with some alternate date format: Y/m/d instead of Y-m-d.
Franz Glasner <fzglas.hg@dom66.de>
parents:
432
diff
changeset
|
824 b"Id2": b"%s %s %s %s %s" % (templatefilters.basename(rel_name), keywords[b"Revision"], keywords[b"Date2"], keywords[b"Author"], keywords[b"State"]), |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
825 b"HGnodeid": nodeid or b'', |
|
109
be4811239acf
kwprint: print example file-dependent keywords also.
Franz Glasner <hg@dom66.de>
parents:
108
diff
changeset
|
826 } |
|
be4811239acf
kwprint: print example file-dependent keywords also.
Franz Glasner <hg@dom66.de>
parents:
108
diff
changeset
|
827 |
|
be4811239acf
kwprint: print example file-dependent keywords also.
Franz Glasner <hg@dom66.de>
parents:
108
diff
changeset
|
828 |
|
51
3807a60ee0dd
Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents:
47
diff
changeset
|
829 def stripped_hostname(hostname): |
|
56
333f98d045ab
FIX: Remove the port information from a cleaned path url also
Franz Glasner <hg@dom66.de>
parents:
52
diff
changeset
|
830 """Return `hostname` without any domain port information""" |
|
51
3807a60ee0dd
Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents:
47
diff
changeset
|
831 if not hostname: |
|
3807a60ee0dd
Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents:
47
diff
changeset
|
832 return hostname |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
833 idx = hostname.find(b'.') |
|
51
3807a60ee0dd
Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents:
47
diff
changeset
|
834 if idx < 0: |
|
3807a60ee0dd
Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents:
47
diff
changeset
|
835 return hostname |
|
3807a60ee0dd
Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents:
47
diff
changeset
|
836 return hostname[:idx] |
|
65
bdb549d71148
Allow customization of the $Author$ output when expanding keywords.
Franz Glasner <hg@dom66.de>
parents:
64
diff
changeset
|
837 |
|
bdb549d71148
Allow customization of the $Author$ output when expanding keywords.
Franz Glasner <hg@dom66.de>
parents:
64
diff
changeset
|
838 |
|
136
f470702886b4
Renamed some internal functions to provide a more descriptive name
Franz Glasner <hg@dom66.de>
parents:
134
diff
changeset
|
839 def get_checked_user_filter_option(opts): |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
840 uf = opts.get(b"user_filter") |
|
81
e02aceb91a9b
Make "full" a user filter and "none" an alias to "full"
Franz Glasner <hg@dom66.de>
parents:
80
diff
changeset
|
841 # "none" is retained for compatibility reasons and now an alias for "full" |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
842 if uf not in (b"person", b"user", b"email", b"full", b"none"): |
|
114
a51822141ccf
Style: handled some more flake8 warnings: consistent command declaration list formatting
Franz Glasner <hg@dom66.de>
parents:
112
diff
changeset
|
843 raise error.Abort( |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
844 _(b"user filter must be any of `user', `person', `email' or `none'")) |
|
65
bdb549d71148
Allow customization of the $Author$ output when expanding keywords.
Franz Glasner <hg@dom66.de>
parents:
64
diff
changeset
|
845 return uf |
|
93
fa84debfb50e
Replace "no-shorten-url" by "path-filter"
Franz Glasner <hg@dom66.de>
parents:
92
diff
changeset
|
846 |
|
fa84debfb50e
Replace "no-shorten-url" by "path-filter"
Franz Glasner <hg@dom66.de>
parents:
92
diff
changeset
|
847 |
|
136
f470702886b4
Renamed some internal functions to provide a more descriptive name
Franz Glasner <hg@dom66.de>
parents:
134
diff
changeset
|
848 def get_checked_path_filter_option(opts): |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
849 pf = opts.get(b"path_filter") |
|
342
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
850 if pf not in (b"full", b"nopwd", b"nouser", b"short", b"last", |
|
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
851 b"repo", b"reposhort"): |
|
114
a51822141ccf
Style: handled some more flake8 warnings: consistent command declaration list formatting
Franz Glasner <hg@dom66.de>
parents:
112
diff
changeset
|
852 raise error.Abort( |
|
342
a69c89c18546
Implemented the "repo" and "reposhort" path filter variants to print the (shortened) repository id instead of the repository path
Franz Glasner <fzglas.hg@dom66.de>
parents:
338
diff
changeset
|
853 _(b"path filter must be any of `full', `nopwd', `nouser`, `short', `last', `repo' or `reposhort'")) |
|
93
fa84debfb50e
Replace "no-shorten-url" by "path-filter"
Franz Glasner <hg@dom66.de>
parents:
92
diff
changeset
|
854 return pf |
|
103
d6e594644778
Make kwarchive work on Mercurial 4.6+ also: the signature of cmdutil.makefileXXX() have changed
Franz Glasner <hg@dom66.de>
parents:
101
diff
changeset
|
855 |
|
d6e594644778
Make kwarchive work on Mercurial 4.6+ also: the signature of cmdutil.makefileXXX() have changed
Franz Glasner <hg@dom66.de>
parents:
101
diff
changeset
|
856 |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
857 if hasattr(inspect, "getfullargspec"): |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
858 # PY3 |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
859 _has_makefilename_ctx = "ctx" in inspect.getfullargspec(cmdutil.makefilename).args |
|
349
0d889720613d
FIX: Mercurial 5 does not accept "root" and "cwd" for match.exact and friends: make a compatibility shim
Franz Glasner <fzglas.hg@dom66.de>
parents:
348
diff
changeset
|
860 _has_matchmod_with_root = "root" in inspect.getfullargspec(match.exact).args |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
861 else: |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
862 _has_makefilename_ctx = "ctx" in inspect.getargspec(cmdutil.makefilename).args |
|
349
0d889720613d
FIX: Mercurial 5 does not accept "root" and "cwd" for match.exact and friends: make a compatibility shim
Franz Glasner <fzglas.hg@dom66.de>
parents:
348
diff
changeset
|
863 _has_matchmod_with_root = "root" in inspect.getargspec(match.exact).args |
|
331
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
864 |
|
99b44c866f4f
Ported the kwarchive extension to Python3 and tested with Mercurial 5.0.1
Franz Glasner <fzglas.hg@dom66.de>
parents:
330
diff
changeset
|
865 if _has_makefilename_ctx: |
|
103
d6e594644778
Make kwarchive work on Mercurial 4.6+ also: the signature of cmdutil.makefileXXX() have changed
Franz Glasner <hg@dom66.de>
parents:
101
diff
changeset
|
866 |
|
d6e594644778
Make kwarchive work on Mercurial 4.6+ also: the signature of cmdutil.makefileXXX() have changed
Franz Glasner <hg@dom66.de>
parents:
101
diff
changeset
|
867 # Mercurial >= 4.6 |
|
d6e594644778
Make kwarchive work on Mercurial 4.6+ also: the signature of cmdutil.makefileXXX() have changed
Franz Glasner <hg@dom66.de>
parents:
101
diff
changeset
|
868 |
|
d6e594644778
Make kwarchive work on Mercurial 4.6+ also: the signature of cmdutil.makefileXXX() have changed
Franz Glasner <hg@dom66.de>
parents:
101
diff
changeset
|
869 makefilename_compat = cmdutil.makefilename |
|
d6e594644778
Make kwarchive work on Mercurial 4.6+ also: the signature of cmdutil.makefileXXX() have changed
Franz Glasner <hg@dom66.de>
parents:
101
diff
changeset
|
870 makefileobj_compat = cmdutil.makefileobj |
|
d6e594644778
Make kwarchive work on Mercurial 4.6+ also: the signature of cmdutil.makefileXXX() have changed
Franz Glasner <hg@dom66.de>
parents:
101
diff
changeset
|
871 |
|
d6e594644778
Make kwarchive work on Mercurial 4.6+ also: the signature of cmdutil.makefileXXX() have changed
Franz Glasner <hg@dom66.de>
parents:
101
diff
changeset
|
872 else: |
|
d6e594644778
Make kwarchive work on Mercurial 4.6+ also: the signature of cmdutil.makefileXXX() have changed
Franz Glasner <hg@dom66.de>
parents:
101
diff
changeset
|
873 |
|
d6e594644778
Make kwarchive work on Mercurial 4.6+ also: the signature of cmdutil.makefileXXX() have changed
Franz Glasner <hg@dom66.de>
parents:
101
diff
changeset
|
874 # Mercurial < 4.6 |
|
d6e594644778
Make kwarchive work on Mercurial 4.6+ also: the signature of cmdutil.makefileXXX() have changed
Franz Glasner <hg@dom66.de>
parents:
101
diff
changeset
|
875 |
|
d6e594644778
Make kwarchive work on Mercurial 4.6+ also: the signature of cmdutil.makefileXXX() have changed
Franz Glasner <hg@dom66.de>
parents:
101
diff
changeset
|
876 def makefilename_compat(ctx, pat, **props): |
|
d6e594644778
Make kwarchive work on Mercurial 4.6+ also: the signature of cmdutil.makefileXXX() have changed
Franz Glasner <hg@dom66.de>
parents:
101
diff
changeset
|
877 return cmdutil.makefilename(ctx.repo(), pat, ctx.node(), **props) |
|
d6e594644778
Make kwarchive work on Mercurial 4.6+ also: the signature of cmdutil.makefileXXX() have changed
Franz Glasner <hg@dom66.de>
parents:
101
diff
changeset
|
878 |
|
d6e594644778
Make kwarchive work on Mercurial 4.6+ also: the signature of cmdutil.makefileXXX() have changed
Franz Glasner <hg@dom66.de>
parents:
101
diff
changeset
|
879 def makefileobj_compat(ctx, pat, **props): |
|
d6e594644778
Make kwarchive work on Mercurial 4.6+ also: the signature of cmdutil.makefileXXX() have changed
Franz Glasner <hg@dom66.de>
parents:
101
diff
changeset
|
880 return cmdutil.makefileobj(ctx.repo(), pat, ctx.node(), **props) |
|
304
71288cb43ba9
kwarchive: Make it work with Mercurial 4.6+ (really tested on 4.8.1).
Franz Glasner <hg@dom66.de>
parents:
300
diff
changeset
|
881 |
|
349
0d889720613d
FIX: Mercurial 5 does not accept "root" and "cwd" for match.exact and friends: make a compatibility shim
Franz Glasner <fzglas.hg@dom66.de>
parents:
348
diff
changeset
|
882 if _has_matchmod_with_root: |
|
0d889720613d
FIX: Mercurial 5 does not accept "root" and "cwd" for match.exact and friends: make a compatibility shim
Franz Glasner <fzglas.hg@dom66.de>
parents:
348
diff
changeset
|
883 |
|
0d889720613d
FIX: Mercurial 5 does not accept "root" and "cwd" for match.exact and friends: make a compatibility shim
Franz Glasner <fzglas.hg@dom66.de>
parents:
348
diff
changeset
|
884 # Mercurial < 5 |
|
0d889720613d
FIX: Mercurial 5 does not accept "root" and "cwd" for match.exact and friends: make a compatibility shim
Franz Glasner <fzglas.hg@dom66.de>
parents:
348
diff
changeset
|
885 |
|
0d889720613d
FIX: Mercurial 5 does not accept "root" and "cwd" for match.exact and friends: make a compatibility shim
Franz Glasner <fzglas.hg@dom66.de>
parents:
348
diff
changeset
|
886 _matchmod_never = match.never |
|
0d889720613d
FIX: Mercurial 5 does not accept "root" and "cwd" for match.exact and friends: make a compatibility shim
Franz Glasner <fzglas.hg@dom66.de>
parents:
348
diff
changeset
|
887 |
|
0d889720613d
FIX: Mercurial 5 does not accept "root" and "cwd" for match.exact and friends: make a compatibility shim
Franz Glasner <fzglas.hg@dom66.de>
parents:
348
diff
changeset
|
888 else: |
|
0d889720613d
FIX: Mercurial 5 does not accept "root" and "cwd" for match.exact and friends: make a compatibility shim
Franz Glasner <fzglas.hg@dom66.de>
parents:
348
diff
changeset
|
889 |
|
0d889720613d
FIX: Mercurial 5 does not accept "root" and "cwd" for match.exact and friends: make a compatibility shim
Franz Glasner <fzglas.hg@dom66.de>
parents:
348
diff
changeset
|
890 def _matchmod_never(root, cwd, badfn=None): |
|
0d889720613d
FIX: Mercurial 5 does not accept "root" and "cwd" for match.exact and friends: make a compatibility shim
Franz Glasner <fzglas.hg@dom66.de>
parents:
348
diff
changeset
|
891 return match.never(badfn=badfn) |
|
0d889720613d
FIX: Mercurial 5 does not accept "root" and "cwd" for match.exact and friends: make a compatibility shim
Franz Glasner <fzglas.hg@dom66.de>
parents:
348
diff
changeset
|
892 |
|
304
71288cb43ba9
kwarchive: Make it work with Mercurial 4.6+ (really tested on 4.8.1).
Franz Glasner <hg@dom66.de>
parents:
300
diff
changeset
|
893 |
|
71288cb43ba9
kwarchive: Make it work with Mercurial 4.6+ (really tested on 4.8.1).
Franz Glasner <hg@dom66.de>
parents:
300
diff
changeset
|
894 if context_mapping_api: |
|
71288cb43ba9
kwarchive: Make it work with Mercurial 4.6+ (really tested on 4.8.1).
Franz Glasner <hg@dom66.de>
parents:
300
diff
changeset
|
895 |
|
71288cb43ba9
kwarchive: Make it work with Mercurial 4.6+ (really tested on 4.8.1).
Franz Glasner <hg@dom66.de>
parents:
300
diff
changeset
|
896 class _FakeRenderContext(object): |
|
71288cb43ba9
kwarchive: Make it work with Mercurial 4.6+ (really tested on 4.8.1).
Franz Glasner <hg@dom66.de>
parents:
300
diff
changeset
|
897 |
|
71288cb43ba9
kwarchive: Make it work with Mercurial 4.6+ (really tested on 4.8.1).
Franz Glasner <hg@dom66.de>
parents:
300
diff
changeset
|
898 @staticmethod |
|
71288cb43ba9
kwarchive: Make it work with Mercurial 4.6+ (really tested on 4.8.1).
Franz Glasner <hg@dom66.de>
parents:
300
diff
changeset
|
899 def resource(mapping, name): |
|
71288cb43ba9
kwarchive: Make it work with Mercurial 4.6+ (really tested on 4.8.1).
Franz Glasner <hg@dom66.de>
parents:
300
diff
changeset
|
900 return mapping[name] |
