annotate extensions/kwarchive.py @ 80:f772a6cc2f67

Make a plain Windows UNC path into a file: URL for HGpath and friends. Within Mercurial they are normalized to plain Windows UNC paths.
author Franz Glasner <hg@dom66.de>
date Fri, 23 Feb 2018 12:48:25 +0100
parents 53c9f2f6a13e
children e02aceb91a9b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 -*-
34
7c4addd60935 Put keyword into the extensions itself
Franz Glasner <hg@dom66.de>
parents: 33
diff changeset
2 # $HGheader$
7c4addd60935 Put keyword into the extensions itself
Franz Glasner <hg@dom66.de>
parents: 33
diff changeset
3 #
60
eebebd7acc69 Wording of docu
Franz Glasner <hg@dom66.de>
parents: 57
diff changeset
4 """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
5
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
6 The patterns of files to to expanded are configured in an versioned
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
7 ``.hgkwarchive`` configuration file found in the root of the working
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
8 directory.
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
9
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
10 The ``.hgkwarchive`` file uses the same syntax as all other Mercurial
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
11 configuration files.
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
12
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
13 The ``[patterns]`` section specifies which files should have the keywords
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
14 expanded.
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
15
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
16
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
17 Example::
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
18
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
19 [patterns]
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
20 # expand keywords in every python file except those matching "x*"
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
21 **.py =
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
22 x* = NO
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
23
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
24 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
25 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
26
28
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
27 """
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
28
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
29 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
30
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
31
42
b46ab29aefd8 Remove the "__version__" variable: use "__revision__" only instead
Franz Glasner <hg@dom66.de>
parents: 41
diff changeset
32 __revision__ = "$Revision$"
28
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
33
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
34 __author__ = "Franz Glasner"
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
35
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
36
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
37 import os
33
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
38 import itertools
28
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
39
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
40 from mercurial.i18n import _
33
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
41 from mercurial import (archival, commands, config, cmdutil, error, match,
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
42 pycompat, scmutil, templatefilters, util)
28
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
43
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
44
75
8e77ed36c333 All extensions work with Mercurial 4.4.2 also
Franz Glasner <hg@dom66.de>
parents: 72
diff changeset
45 testedwith = "4.3.1 4.3.2 4.4.2"
28
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
46
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
47
51
3807a60ee0dd Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 47
diff changeset
48 SHORTENED_HG_SCHEMES = {
3807a60ee0dd Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 47
diff changeset
49 "ssh": "hg+ssh",
3807a60ee0dd Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 47
diff changeset
50 "http": "hg+http",
3807a60ee0dd Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 47
diff changeset
51 "https": "hg+https",
3807a60ee0dd Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 47
diff changeset
52 "file": "file",
3807a60ee0dd Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 47
diff changeset
53 }
3807a60ee0dd Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 47
diff changeset
54
3807a60ee0dd Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 47
diff changeset
55
28
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
56 cmdtable = {}
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
57
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
58 command = cmdutil.command(cmdtable)
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
59
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
60
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
61 @command('kwarchive',
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
62 [('', 'no-decode', None, _('do not pass files through decoders')),
76
b72672ca2de9 FIX: Indentation
Franz Glasner <hg@dom66.de>
parents: 75
diff changeset
63 ('p', 'prefix', '', _('directory prefix for files in archive'), _('PREFIX')),
b72672ca2de9 FIX: Indentation
Franz Glasner <hg@dom66.de>
parents: 75
diff changeset
64 ('r', 'rev', '', _('revision to distribute'), _('REV')),
b72672ca2de9 FIX: Indentation
Franz Glasner <hg@dom66.de>
parents: 75
diff changeset
65 ('t', 'type', '', _('type of distribution to create'), _('TYPE')),
b72672ca2de9 FIX: Indentation
Franz Glasner <hg@dom66.de>
parents: 75
diff changeset
66 ('', 'path', 'default', _('the canonical repository to use'), _('PATH')),
b72672ca2de9 FIX: Indentation
Franz Glasner <hg@dom66.de>
parents: 75
diff changeset
67 ('', "kwconfig", '', _('an alternate pattern configuration configuration file'), _('PATTERNCONFIG')),
b72672ca2de9 FIX: Indentation
Franz Glasner <hg@dom66.de>
parents: 75
diff changeset
68 ('', "no-shorten-path", None, _("don't shorten the path urls")),
b72672ca2de9 FIX: Indentation
Franz Glasner <hg@dom66.de>
parents: 75
diff changeset
69 ('', "user-filter", "user", _("the part of the user to be printed"), _("USERFILTER")),
28
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
70 ] + cmdutil.subrepoopts + cmdutil.walkopts,
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
71 _('[OPTION]... DEST'))
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
72 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
73 '''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
74
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
75 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
76 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
77
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
78 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
79 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
80
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
81 .. container:: verbose
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 Examples:
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 - 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
86
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
87 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
88
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
89 - 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
90
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
91 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
92
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
93 Valid types are:
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 :``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
96 :``tar``: tar archive, uncompressed
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
97 :``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
98 :``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
99 :``uzip``: zip archive, uncompressed
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
100 :``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
101
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
102 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
103 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
104
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
105 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
106 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
107 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
108 removed.
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
109
41
c05d8dcb4bb0 Doku: Enhance
Franz Glasner <hg@dom66.de>
parents: 36
diff changeset
110 Use --path to specify named path information from :hg:`paths` as
c05d8dcb4bb0 Doku: Enhance
Franz Glasner <hg@dom66.de>
parents: 36
diff changeset
111 the canonical repository location. Use ``.`` for the current
c05d8dcb4bb0 Doku: Enhance
Franz Glasner <hg@dom66.de>
parents: 36
diff changeset
112 repository root root. If no path is given then ``default`` is
c05d8dcb4bb0 Doku: Enhance
Franz Glasner <hg@dom66.de>
parents: 36
diff changeset
113 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
114
51
3807a60ee0dd Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 47
diff changeset
115 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
116 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
117
65
bdb549d71148 Allow customization of the $Author$ output when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 64
diff changeset
118 Allowed --user-filter values are:
bdb549d71148 Allow customization of the $Author$ output when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 64
diff changeset
119
bdb549d71148 Allow customization of the $Author$ output when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 64
diff changeset
120 :``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
121 :``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
122 :``email``: the email address
72
7484b3254940 Added a new "filter" for $Author$: filter nothing and print the complete Mercurial user information as one word
Franz Glasner <hg@dom66.de>
parents: 69
diff changeset
123 :``none``: the complete user information w/o filtering
65
bdb549d71148 Allow customization of the $Author$ output when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 64
diff changeset
124
28
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
125 Returns 0 on success.
41
c05d8dcb4bb0 Doku: Enhance
Franz Glasner <hg@dom66.de>
parents: 36
diff changeset
126
28
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
127 '''
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
128
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
129 opts = pycompat.byteskwargs(opts)
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
130 ctx = scmutil.revsingle(repo, opts.get('rev'))
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
131 if not ctx:
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
132 raise error.Abort(_('no working directory: please specify a revision'))
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
133 node = ctx.node()
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
134 dest = cmdutil.makefilename(repo, dest, node)
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
135 if os.path.realpath(dest) == repo.root:
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
136 raise error.Abort(_('repository root cannot be destination'))
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
137
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
138 kind = opts.get('type') or archival.guesskind(dest) or 'files'
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
139 prefix = opts.get('prefix')
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
140
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
141 if dest == '-':
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
142 if kind == 'files':
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
143 raise error.Abort(_('cannot archive plain files to stdout'))
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
144 dest = cmdutil.makefileobj(repo, dest)
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
145 if not prefix:
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
146 prefix = os.path.basename(repo.root) + '-%h'
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
147
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
148 prefix = cmdutil.makefilename(repo, prefix, node)
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
149 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
150
58f47399691c New successful PoC: monkey-patch all relevant archiver's "addfile()" method
Franz Glasner <hg@dom66.de>
parents: 28
diff changeset
151 #
31
0597395e2d18 Comment: better explanation of what is monkey-patched
Franz Glasner <hg@dom66.de>
parents: 30
diff changeset
152 # 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
153 # expands keywords
58f47399691c New successful PoC: monkey-patch all relevant archiver's "addfile()" method
Franz Glasner <hg@dom66.de>
parents: 28
diff changeset
154 #
32
cfa53f8a6607 Refactor the class' monkey-patching
Franz Glasner <hg@dom66.de>
parents: 31
diff changeset
155 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
156 patch_archiver_class(
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
157 ac,
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
158 make_keyword_filter(
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
159 ui,
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
160 repo,
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
161 ctx,
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
162 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
163 archival.tidyprefix(dest, kind, prefix),
47
94ae433383a2 Allow an alternate patterns file (instead of .hgkwarchive) with the --kwconfig option.
Franz Glasner <hg@dom66.de>
parents: 46
diff changeset
164 hgpath=opts.get("path"),
51
3807a60ee0dd Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 47
diff changeset
165 shorten_path_url=not opts.get("no_shorten_path"),
65
bdb549d71148 Allow customization of the $Author$ output when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 64
diff changeset
166 user_filter=get_checked_user_filter(opts),
47
94ae433383a2 Allow an alternate patterns file (instead of .hgkwarchive) with the --kwconfig option.
Franz Glasner <hg@dom66.de>
parents: 46
diff changeset
167 kwconfig=opts.get("kwconfig")))
30
1670760f695f Monkey-patch all current archivers in mercurial.archival: fileit, tarit and ziptit
Franz Glasner <hg@dom66.de>
parents: 29
diff changeset
168
28
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
169 archival.archive(repo, dest, node, kind, not opts.get('no_decode'),
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
170 matchfn, prefix, subrepos=opts.get('subrepos'))
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
171
32
cfa53f8a6607 Refactor the class' monkey-patching
Franz Glasner <hg@dom66.de>
parents: 31
diff changeset
172 # XXX FIXME: Should the original methods be restored here?
cfa53f8a6607 Refactor the class' monkey-patching
Franz Glasner <hg@dom66.de>
parents: 31
diff changeset
173
46
4a0c26dfef3c Comment about automatically amending .hg_archival.txt with "path" items.
Franz Glasner <hg@dom66.de>
parents: 45
diff changeset
174 # 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
175 # 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
176 # 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
177 # 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
178
32
cfa53f8a6607 Refactor the class' monkey-patching
Franz Glasner <hg@dom66.de>
parents: 31
diff changeset
179
45
c077d30da0ee Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents: 44
diff changeset
180 @command('kwprint',
c077d30da0ee Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents: 44
diff changeset
181 [('r', 'rev', '', _('revision to distribute'), _('REV')),
c077d30da0ee Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents: 44
diff changeset
182 ('', 'path', 'default', _('the canonical repository to use'), _('PATH')),
51
3807a60ee0dd Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 47
diff changeset
183 ('', "no-shorten-path", None, _("don't shorten the path urls")),
76
b72672ca2de9 FIX: Indentation
Franz Glasner <hg@dom66.de>
parents: 75
diff changeset
184 ('', "user-filter", "user", _("the part of the user to be printed"), _("USERFILTER")),
78
743dd4a77b4a Implemented a "--reST" option for printing reST substitution definitions from keywords
Franz Glasner <hg@dom66.de>
parents: 76
diff changeset
185 ('', "reST", None, _("output in reST substitution definition syntax")),
45
c077d30da0ee Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents: 44
diff changeset
186 ] + cmdutil.subrepoopts + cmdutil.walkopts,
c077d30da0ee Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents: 44
diff changeset
187 _('[OPTION]...'))
c077d30da0ee Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents: 44
diff changeset
188 def kwprint(ui, repo, **opts):
c077d30da0ee Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents: 44
diff changeset
189 '''print the file-independent keywords
c077d30da0ee Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents: 44
diff changeset
190
c077d30da0ee Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents: 44
diff changeset
191 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
192 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
193
c077d30da0ee Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents: 44
diff changeset
194 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
195 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
196 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
197 assumed.
c077d30da0ee Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents: 44
diff changeset
198
51
3807a60ee0dd Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 47
diff changeset
199 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
200 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
201
65
bdb549d71148 Allow customization of the $Author$ output when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 64
diff changeset
202 Allowed --user-filter values are:
bdb549d71148 Allow customization of the $Author$ output when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 64
diff changeset
203
bdb549d71148 Allow customization of the $Author$ output when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 64
diff changeset
204 :``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
205 :``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
206 :``email``: the email address
72
7484b3254940 Added a new "filter" for $Author$: filter nothing and print the complete Mercurial user information as one word
Franz Glasner <hg@dom66.de>
parents: 69
diff changeset
207 :``none``: the complete user information w/o filtering
65
bdb549d71148 Allow customization of the $Author$ output when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 64
diff changeset
208
78
743dd4a77b4a Implemented a "--reST" option for printing reST substitution definitions from keywords
Franz Glasner <hg@dom66.de>
parents: 76
diff changeset
209 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
210 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
211 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
212
45
c077d30da0ee Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents: 44
diff changeset
213 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
214
c077d30da0ee Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents: 44
diff changeset
215 '''
c077d30da0ee Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents: 44
diff changeset
216
c077d30da0ee Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents: 44
diff changeset
217 opts = pycompat.byteskwargs(opts)
c077d30da0ee Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents: 44
diff changeset
218 ctx = scmutil.revsingle(repo, opts.get('rev'))
c077d30da0ee Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents: 44
diff changeset
219 if not ctx:
c077d30da0ee Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents: 44
diff changeset
220 raise error.Abort(_('no working directory: please specify a revision'))
c077d30da0ee Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents: 44
diff changeset
221 node = ctx.node()
c077d30da0ee Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents: 44
diff changeset
222
c077d30da0ee Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents: 44
diff changeset
223 prefix = cmdutil.makefilename(repo, "", node)
c077d30da0ee Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents: 44
diff changeset
224
c077d30da0ee Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents: 44
diff changeset
225 keywords = make_node_keywords(
51
3807a60ee0dd Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 47
diff changeset
226 ui, repo, ctx, prefix,
3807a60ee0dd Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 47
diff changeset
227 hgpath=opts.get("path"),
65
bdb549d71148 Allow customization of the $Author$ output when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 64
diff changeset
228 shorten_path_url=not opts.get("no_shorten_path"),
bdb549d71148 Allow customization of the $Author$ output when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 64
diff changeset
229 user_filter=get_checked_user_filter(opts))
45
c077d30da0ee Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents: 44
diff changeset
230 for key in sorted(keywords.keys()):
78
743dd4a77b4a Implemented a "--reST" option for printing reST substitution definitions from keywords
Franz Glasner <hg@dom66.de>
parents: 76
diff changeset
231 if opts.get("reST"):
743dd4a77b4a Implemented a "--reST" option for printing reST substitution definitions from keywords
Franz Glasner <hg@dom66.de>
parents: 76
diff changeset
232 ui.write(".. |VCS%s| replace:: %s\n" % (key, keywords[key]))
743dd4a77b4a Implemented a "--reST" option for printing reST substitution definitions from keywords
Franz Glasner <hg@dom66.de>
parents: 76
diff changeset
233 else:
743dd4a77b4a Implemented a "--reST" option for printing reST substitution definitions from keywords
Franz Glasner <hg@dom66.de>
parents: 76
diff changeset
234 ui.write("$%s: %s $\n" % (key, keywords[key]))
45
c077d30da0ee Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents: 44
diff changeset
235
c077d30da0ee Implemented a "kwprint" command to print just some file-independent keywords
Franz Glasner <hg@dom66.de>
parents: 44
diff changeset
236
33
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
237 def patch_archiver_class(archivername, filter):
32
cfa53f8a6607 Refactor the class' monkey-patching
Franz Glasner <hg@dom66.de>
parents: 31
diff changeset
238 """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
239
cfa53f8a6607 Refactor the class' monkey-patching
Franz Glasner <hg@dom66.de>
parents: 31
diff changeset
240 archiver_class = getattr(archival, archivername)
cfa53f8a6607 Refactor the class' monkey-patching
Franz Glasner <hg@dom66.de>
parents: 31
diff changeset
241 orig_addfile = getattr(archiver_class, "addfile")
cfa53f8a6607 Refactor the class' monkey-patching
Franz Glasner <hg@dom66.de>
parents: 31
diff changeset
242
cfa53f8a6607 Refactor the class' monkey-patching
Franz Glasner <hg@dom66.de>
parents: 31
diff changeset
243 def new_addfile(self, name, mode, isline, data):
33
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
244 return orig_addfile(self, name, mode, isline, filter(name, data))
32
cfa53f8a6607 Refactor the class' monkey-patching
Franz Glasner <hg@dom66.de>
parents: 31
diff changeset
245
cfa53f8a6607 Refactor the class' monkey-patching
Franz Glasner <hg@dom66.de>
parents: 31
diff changeset
246 setattr(archiver_class, "addfile", new_addfile)
cfa53f8a6607 Refactor the class' monkey-patching
Franz Glasner <hg@dom66.de>
parents: 31
diff changeset
247 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
248
28
c8b7d0635656 PoC for archive with keyword expansion: works w/o touching subrepos
Franz Glasner <hg@dom66.de>
parents:
diff changeset
249
33
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
250 def make_keyword_filter(ui, repo, ctx, archive_class, prefix,
47
94ae433383a2 Allow an alternate patterns file (instead of .hgkwarchive) with the --kwconfig option.
Franz Glasner <hg@dom66.de>
parents: 46
diff changeset
251 hgpath="default",
51
3807a60ee0dd Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 47
diff changeset
252 shorten_path_url=True,
66
fe4feca5b136 The default user-filter of $Author$ is "user" now.
Franz Glasner <hg@dom66.de>
parents: 65
diff changeset
253 user_filter="user",
47
94ae433383a2 Allow an alternate patterns file (instead of .hgkwarchive) with the --kwconfig option.
Franz Glasner <hg@dom66.de>
parents: 46
diff changeset
254 kwconfig=""):
51
3807a60ee0dd Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 47
diff changeset
255 keywords = make_node_keywords(ui, repo, ctx, prefix,
3807a60ee0dd Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 47
diff changeset
256 hgpath=hgpath,
65
bdb549d71148 Allow customization of the $Author$ output when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 64
diff changeset
257 shorten_path_url=shorten_path_url,
bdb549d71148 Allow customization of the $Author$ output when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 64
diff changeset
258 user_filter=user_filter)
47
94ae433383a2 Allow an alternate patterns file (instead of .hgkwarchive) with the --kwconfig option.
Franz Glasner <hg@dom66.de>
parents: 46
diff changeset
259 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
260 if kwconfig:
94ae433383a2 Allow an alternate patterns file (instead of .hgkwarchive) with the --kwconfig option.
Franz Glasner <hg@dom66.de>
parents: 46
diff changeset
261 kwconfigdata = open(kwconfig, "rb").read()
94ae433383a2 Allow an alternate patterns file (instead of .hgkwarchive) with the --kwconfig option.
Franz Glasner <hg@dom66.de>
parents: 46
diff changeset
262 kwconfigname = kwconfig
33
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
263 try:
47
94ae433383a2 Allow an alternate patterns file (instead of .hgkwarchive) with the --kwconfig option.
Franz Glasner <hg@dom66.de>
parents: 46
diff changeset
264 if kwconfigdata is None:
94ae433383a2 Allow an alternate patterns file (instead of .hgkwarchive) with the --kwconfig option.
Franz Glasner <hg@dom66.de>
parents: 46
diff changeset
265 # .hgkwarchive
94ae433383a2 Allow an alternate patterns file (instead of .hgkwarchive) with the --kwconfig option.
Franz Glasner <hg@dom66.de>
parents: 46
diff changeset
266 kwconfigdata = ctx[".hgkwarchive"].data()
94ae433383a2 Allow an alternate patterns file (instead of .hgkwarchive) with the --kwconfig option.
Franz Glasner <hg@dom66.de>
parents: 46
diff changeset
267 kwconfigname = ".kwarchive"
33
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
268 except (IOError, LookupError):
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
269 def _filter(name, data):
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
270 return data
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
271 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
272 #
71b321436cc1 Refactor: generate all node-specific keywords (file-path independent) in a dedicated function
Franz Glasner <hg@dom66.de>
parents: 42
diff changeset
273 # 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
274 # 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
275 #
33
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
276 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
277 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
278 include = []
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
279 exclude = []
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
280 patterns = []
79
53c9f2f6a13e Work in reST style keywords in kwarchive
Franz Glasner <hg@dom66.de>
parents: 78
diff changeset
281 patterns_rst = []
33
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
282 if cfg.items("patterns"):
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
283 for pattern, style in cfg.items("patterns"):
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
284 style = style.upper()
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
285 if style in ("YES", "INCLUDE",):
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
286 include.append(pattern)
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
287 if style in ("NO", "EXCLUDE",):
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
288 exclude.append(pattern)
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
289 else:
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
290 patterns.append(pattern)
79
53c9f2f6a13e Work in reST style keywords in kwarchive
Franz Glasner <hg@dom66.de>
parents: 78
diff changeset
291 if style in ("REST", "RST",):
53c9f2f6a13e Work in reST style keywords in kwarchive
Franz Glasner <hg@dom66.de>
parents: 78
diff changeset
292 patterns_rst.append(pattern)
33
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
293 matcher = match.match(repo.root, '', patterns=patterns,
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
294 include=include, exclude=exclude)
79
53c9f2f6a13e Work in reST style keywords in kwarchive
Franz Glasner <hg@dom66.de>
parents: 78
diff changeset
295 matcher_rst = match.match(repo.root, '', patterns=patterns_rst,
53c9f2f6a13e Work in reST style keywords in kwarchive
Franz Glasner <hg@dom66.de>
parents: 78
diff changeset
296 include=[], exclude=[])
33
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
297 else:
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
298 matcher = match.never(repo.root, '')
79
53c9f2f6a13e Work in reST style keywords in kwarchive
Franz Glasner <hg@dom66.de>
parents: 78
diff changeset
299 matcher_rst = match.never(repo.root, '')
33
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
300
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
301 def _filter(name, data):
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
302 real_name = name
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
303 if archive_class != "fileit":
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
304 if prefix:
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
305 assert name.startswith(prefix)
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
306 real_name = name[len(prefix):]
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
307 if not matcher(real_name):
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
308 return data
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
309 # file specific keywords
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
310 file_keywords = {
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
311 "HGsource": keywords["HGpath"] + '/' + real_name,
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
312 "Source": real_name,
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
313 "File": templatefilters.basename(real_name),
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
314 "Header": "%s %s %s %s" % (real_name, keywords["Revision"], keywords["Date"], keywords["Author"]),
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
315 "HGid": "%s %s %s %s" % (keywords["HGpath"] + '/' + real_name, keywords["Revision"], keywords["Date"], keywords["Author"]),
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
316 "HGheader": "%s %s %s %s" % (keywords["HGpath"] + '/' + real_name, keywords["HGrevision"], keywords["Date"], keywords["Author"]),
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
317 "Id": "%s %s %s %s" % (templatefilters.basename(real_name), keywords["Revision"], keywords["Date"], keywords["Author"]),
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
318 }
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
319 # This prevents unwanted keyword expansion here
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
320 _MARKER = '$'
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
321 for kw, value in itertools.chain(keywords.items(), file_keywords.items()):
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
322 filekw = _MARKER + kw + _MARKER
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
323 filevalue = "%s%s: %s %s" % (_MARKER, kw, value, _MARKER)
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
324 data = data.replace(filekw, filevalue)
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
325 return data
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
326
dc8db9693262 kwarchive expands keyword on given files (.hgkwarchive with generic Mercurial patterns)
Franz Glasner <hg@dom66.de>
parents: 32
diff changeset
327 return _filter
44
71b321436cc1 Refactor: generate all node-specific keywords (file-path independent) in a dedicated function
Franz Glasner <hg@dom66.de>
parents: 42
diff changeset
328
71b321436cc1 Refactor: generate all node-specific keywords (file-path independent) in a dedicated function
Franz Glasner <hg@dom66.de>
parents: 42
diff changeset
329
51
3807a60ee0dd Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 47
diff changeset
330 def make_node_keywords(ui, repo, ctx, prefix,
3807a60ee0dd Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 47
diff changeset
331 hgpath="default",
65
bdb549d71148 Allow customization of the $Author$ output when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 64
diff changeset
332 shorten_path_url=True,
66
fe4feca5b136 The default user-filter of $Author$ is "user" now.
Franz Glasner <hg@dom66.de>
parents: 65
diff changeset
333 user_filter="user"):
44
71b321436cc1 Refactor: generate all node-specific keywords (file-path independent) in a dedicated function
Franz Glasner <hg@dom66.de>
parents: 42
diff changeset
334 """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
335
71b321436cc1 Refactor: generate all node-specific keywords (file-path independent) in a dedicated function
Franz Glasner <hg@dom66.de>
parents: 42
diff changeset
336 """
71b321436cc1 Refactor: generate all node-specific keywords (file-path independent) in a dedicated function
Franz Glasner <hg@dom66.de>
parents: 42
diff changeset
337 if hgpath:
71b321436cc1 Refactor: generate all node-specific keywords (file-path independent) in a dedicated function
Franz Glasner <hg@dom66.de>
parents: 42
diff changeset
338 if hgpath == '.':
51
3807a60ee0dd Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 47
diff changeset
339 path_uri = repo.root
44
71b321436cc1 Refactor: generate all node-specific keywords (file-path independent) in a dedicated function
Franz Glasner <hg@dom66.de>
parents: 42
diff changeset
340 else:
71b321436cc1 Refactor: generate all node-specific keywords (file-path independent) in a dedicated function
Franz Glasner <hg@dom66.de>
parents: 42
diff changeset
341 try:
51
3807a60ee0dd Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 47
diff changeset
342 if shorten_path_url:
3807a60ee0dd Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 47
diff changeset
343 path_url = util.url(ui.paths[hgpath].loc)
3807a60ee0dd Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 47
diff changeset
344 path_url.scheme = SHORTENED_HG_SCHEMES.get(path_url.scheme, "hg")
3807a60ee0dd Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 47
diff changeset
345 path_url.user = None
3807a60ee0dd Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 47
diff changeset
346 path_url.passwd = None
3807a60ee0dd Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 47
diff changeset
347 path_url.host = stripped_hostname(path_url.host)
56
333f98d045ab FIX: Remove the port information from a cleaned path url also
Franz Glasner <hg@dom66.de>
parents: 52
diff changeset
348 path_url.port = None
51
3807a60ee0dd Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 47
diff changeset
349 path_uri = bytes(path_url)
3807a60ee0dd Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 47
diff changeset
350 else:
3807a60ee0dd Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 47
diff changeset
351 path_uri = util.hidepassword(ui.paths[hgpath].loc)
44
71b321436cc1 Refactor: generate all node-specific keywords (file-path independent) in a dedicated function
Franz Glasner <hg@dom66.de>
parents: 42
diff changeset
352 except LookupError:
71b321436cc1 Refactor: generate all node-specific keywords (file-path independent) in a dedicated function
Franz Glasner <hg@dom66.de>
parents: 42
diff changeset
353 raise error.Abort(_('repository %s not found') % hgpath)
71b321436cc1 Refactor: generate all node-specific keywords (file-path independent) in a dedicated function
Franz Glasner <hg@dom66.de>
parents: 42
diff changeset
354 else:
51
3807a60ee0dd Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 47
diff changeset
355 path_uri = repo.root
80
f772a6cc2f67 Make a plain Windows UNC path into a file: URL for HGpath and friends.
Franz Glasner <hg@dom66.de>
parents: 79
diff changeset
356 # Make an URL from a Windows UNC path
f772a6cc2f67 Make a plain Windows UNC path into a file: URL for HGpath and friends.
Franz Glasner <hg@dom66.de>
parents: 79
diff changeset
357 if path_uri.startswith(b"\\\\"):
f772a6cc2f67 Make a plain Windows UNC path into a file: URL for HGpath and friends.
Franz Glasner <hg@dom66.de>
parents: 79
diff changeset
358 path_uri = b"file:///" + path_uri.replace(b'\\', b'/')
44
71b321436cc1 Refactor: generate all node-specific keywords (file-path independent) in a dedicated function
Franz Glasner <hg@dom66.de>
parents: 42
diff changeset
359 keywords = {
51
3807a60ee0dd Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 47
diff changeset
360 "HGpath": path_uri,
44
71b321436cc1 Refactor: generate all node-specific keywords (file-path independent) in a dedicated function
Franz Glasner <hg@dom66.de>
parents: 42
diff changeset
361 "HGrevision": ctx.hex(),
71b321436cc1 Refactor: generate all node-specific keywords (file-path independent) in a dedicated function
Franz Glasner <hg@dom66.de>
parents: 42
diff changeset
362 "Revision": templatefilters.short(ctx.hex()),
71b321436cc1 Refactor: generate all node-specific keywords (file-path independent) in a dedicated function
Franz Glasner <hg@dom66.de>
parents: 42
diff changeset
363 "Date": templatefilters.isodatesec(ctx.date()),
71b321436cc1 Refactor: generate all node-specific keywords (file-path independent) in a dedicated function
Franz Glasner <hg@dom66.de>
parents: 42
diff changeset
364 }
66
fe4feca5b136 The default user-filter of $Author$ is "user" now.
Franz Glasner <hg@dom66.de>
parents: 65
diff changeset
365 if user_filter == "user":
69
d0a1521cb164 The "user" filter splits at a "." character - the "emailuser" filter does not: this is what we want as "user" filter
Franz Glasner <hg@dom66.de>
parents: 66
diff changeset
366 keywords["Author"] = templatefilters.emailuser(ctx.user())
66
fe4feca5b136 The default user-filter of $Author$ is "user" now.
Franz Glasner <hg@dom66.de>
parents: 65
diff changeset
367 elif user_filter == "person":
65
bdb549d71148 Allow customization of the $Author$ output when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 64
diff changeset
368 keywords["Author"] = templatefilters.utf8(templatefilters.person(ctx.user()).replace(' ', '+'))
bdb549d71148 Allow customization of the $Author$ output when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 64
diff changeset
369 elif user_filter == "email":
bdb549d71148 Allow customization of the $Author$ output when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 64
diff changeset
370 keywords["Author"] = templatefilters.email(ctx.user())
72
7484b3254940 Added a new "filter" for $Author$: filter nothing and print the complete Mercurial user information as one word
Franz Glasner <hg@dom66.de>
parents: 69
diff changeset
371 elif user_filter == "none":
7484b3254940 Added a new "filter" for $Author$: filter nothing and print the complete Mercurial user information as one word
Franz Glasner <hg@dom66.de>
parents: 69
diff changeset
372 keywords["Author"] = templatefilters.utf8(ctx.user().replace(' ', '+'))
65
bdb549d71148 Allow customization of the $Author$ output when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 64
diff changeset
373
44
71b321436cc1 Refactor: generate all node-specific keywords (file-path independent) in a dedicated function
Franz Glasner <hg@dom66.de>
parents: 42
diff changeset
374 return keywords
51
3807a60ee0dd Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 47
diff changeset
375
3807a60ee0dd Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 47
diff changeset
376
3807a60ee0dd Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 47
diff changeset
377 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
378 """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
379 if not hostname:
3807a60ee0dd Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 47
diff changeset
380 return hostname
3807a60ee0dd Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 47
diff changeset
381 idx = hostname.find('.')
3807a60ee0dd Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 47
diff changeset
382 if idx < 0:
3807a60ee0dd Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 47
diff changeset
383 return hostname
3807a60ee0dd Shorten path urls by default when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 47
diff changeset
384 return hostname[:idx]
65
bdb549d71148 Allow customization of the $Author$ output when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 64
diff changeset
385
bdb549d71148 Allow customization of the $Author$ output when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 64
diff changeset
386
bdb549d71148 Allow customization of the $Author$ output when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 64
diff changeset
387 def get_checked_user_filter(opts):
bdb549d71148 Allow customization of the $Author$ output when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 64
diff changeset
388 uf = opts.get("user_filter")
72
7484b3254940 Added a new "filter" for $Author$: filter nothing and print the complete Mercurial user information as one word
Franz Glasner <hg@dom66.de>
parents: 69
diff changeset
389 if not uf in ("person", "user", "email", "none"):
66
fe4feca5b136 The default user-filter of $Author$ is "user" now.
Franz Glasner <hg@dom66.de>
parents: 65
diff changeset
390 raise error.Abort(_("user filter must be any of `user', `person' or `email'"))
65
bdb549d71148 Allow customization of the $Author$ output when expanding keywords.
Franz Glasner <hg@dom66.de>
parents: 64
diff changeset
391 return uf