Mercurial > hgrepos > DevTools > mercurial-extensions
annotate extensions/revinfo.py @ 328:80fa55e2fb16
FIX: Remove unneeded code when temporarily disabling Mercurial's demandimport
The context manager demandimport.activated() does all things already.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 08 Jul 2019 18:11:51 +0200 |
| parents | 56f2020b8b9e |
| children | 39674f294709 |
| rev | line source |
|---|---|
|
1
a80645763196
revinfo: a module to write .hg_archival.txt like repository metadata
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:
114
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$ |
|
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
|
4 # |
|
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
|
5 # :Copyright: (C) 2015-2019 Franz Glasner <fzglas.hg@dom66.de> |
|
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. |
|
34
7c4addd60935
Put keyword into the extensions itself
Franz Glasner <hg@dom66.de>
parents:
27
diff
changeset
|
10 # |
|
1
a80645763196
revinfo: a module to write .hg_archival.txt like repository metadata
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
11 """write a revision summary similar to .hg_archival.txt |
|
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:
125
diff
changeset
|
12 |
|
5e502e9dd5e5
As an example: put the |VCSRevision| into the extensions also and print it with the help output
Franz Glasner <hg@dom66.de>
parents:
125
diff
changeset
|
13 (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:
125
diff
changeset
|
14 |
|
1
a80645763196
revinfo: a module to write .hg_archival.txt like repository metadata
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
15 """ |
|
a80645763196
revinfo: a module to write .hg_archival.txt like repository metadata
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
16 |
|
42
b46ab29aefd8
Remove the "__version__" variable: use "__revision__" only instead
Franz Glasner <hg@dom66.de>
parents:
40
diff
changeset
|
17 __revision__ = "$Revision$" |
|
1
a80645763196
revinfo: a module to write .hg_archival.txt like repository metadata
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
18 |
|
a80645763196
revinfo: a module to write .hg_archival.txt like repository metadata
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
19 __author__ = "Franz Glasner" |
|
a80645763196
revinfo: a module to write .hg_archival.txt like repository metadata
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
20 |
|
a80645763196
revinfo: a module to write .hg_archival.txt like repository metadata
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
21 |
|
a80645763196
revinfo: a module to write .hg_archival.txt like repository metadata
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
22 from mercurial.i18n import _ |
|
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:
315
diff
changeset
|
23 from mercurial import (cmdutil, scmutil, util, error, archival, pycompat, |
|
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:
315
diff
changeset
|
24 demandimport) |
|
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:
315
diff
changeset
|
25 with demandimport.deactivated(): |
|
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:
315
diff
changeset
|
26 try: |
|
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:
315
diff
changeset
|
27 from mercurial import registrar |
|
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:
315
diff
changeset
|
28 except ImportError: |
|
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:
315
diff
changeset
|
29 registrar = None |
|
1
a80645763196
revinfo: a module to write .hg_archival.txt like repository metadata
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
30 |
|
a80645763196
revinfo: a module to write .hg_archival.txt like repository metadata
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
31 |
|
a80645763196
revinfo: a module to write .hg_archival.txt like repository metadata
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
32 cmdtable = {} |
|
a80645763196
revinfo: a module to write .hg_archival.txt like repository metadata
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
33 |
|
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:
315
diff
changeset
|
34 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:
151
diff
changeset
|
35 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:
151
diff
changeset
|
36 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:
151
diff
changeset
|
37 command = cmdutil.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:
151
diff
changeset
|
38 |
|
1
a80645763196
revinfo: a module to write .hg_archival.txt like repository metadata
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
39 |
|
327
56f2020b8b9e
Run unit-tests with Mercurial 5.0.1: ok without changes
Franz Glasner <fzglas.hg@dom66.de>
parents:
326
diff
changeset
|
40 testedwith = "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" |
|
3
133dab95fb84
Added the recommended "testedwith" module attribute
Franz Glasner <hg@dom66.de>
parents:
1
diff
changeset
|
41 |
|
1
a80645763196
revinfo: a module to write .hg_archival.txt like repository metadata
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
42 |
|
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:
137
diff
changeset
|
43 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:
137
diff
changeset
|
44 """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:
137
diff
changeset
|
45 |
|
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:
137
diff
changeset
|
46 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:
137
diff
changeset
|
47 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:
137
diff
changeset
|
48 |
|
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:
137
diff
changeset
|
49 """ |
|
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:
137
diff
changeset
|
50 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:
137
diff
changeset
|
51 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:
137
diff
changeset
|
52 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:
137
diff
changeset
|
53 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:
137
diff
changeset
|
54 except NameError: |
|
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:
137
diff
changeset
|
55 return "<unknown>" |
|
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:
137
diff
changeset
|
56 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:
137
diff
changeset
|
57 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:
137
diff
changeset
|
58 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:
137
diff
changeset
|
59 "../VERSION"), |
|
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:
137
diff
changeset
|
60 "r").read() |
|
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:
137
diff
changeset
|
61 return re.search("^(.*)", verdata,).group(1) |
|
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:
137
diff
changeset
|
62 except OSError: |
|
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:
137
diff
changeset
|
63 return "<not found>" |
|
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:
137
diff
changeset
|
64 |
|
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:
137
diff
changeset
|
65 |
|
114
a51822141ccf
Style: handled some more flake8 warnings: consistent command declaration list formatting
Franz Glasner <hg@dom66.de>
parents:
113
diff
changeset
|
66 @command( |
|
a51822141ccf
Style: handled some more flake8 warnings: consistent command declaration list formatting
Franz Glasner <hg@dom66.de>
parents:
113
diff
changeset
|
67 "revinfo", |
|
a51822141ccf
Style: handled some more flake8 warnings: consistent command declaration list formatting
Franz Glasner <hg@dom66.de>
parents:
113
diff
changeset
|
68 [ |
|
a51822141ccf
Style: handled some more flake8 warnings: consistent command declaration list formatting
Franz Glasner <hg@dom66.de>
parents:
113
diff
changeset
|
69 ("r", "rev", "", _('revision to handle'), _('REV')), |
|
a51822141ccf
Style: handled some more flake8 warnings: consistent command declaration list formatting
Franz Glasner <hg@dom66.de>
parents:
113
diff
changeset
|
70 ("", "amend", None, _('amend a given file with path information')), |
|
a51822141ccf
Style: handled some more flake8 warnings: consistent command declaration list formatting
Franz Glasner <hg@dom66.de>
parents:
113
diff
changeset
|
71 ("p", "path", [], _('the configured default path'), _('SOURCE')), |
|
a51822141ccf
Style: handled some more flake8 warnings: consistent command declaration list formatting
Franz Glasner <hg@dom66.de>
parents:
113
diff
changeset
|
72 ("d", "data", [], _("add an extra `KEY: VALUE' pair into the file"), _('KEY=VALUE')), |
|
a51822141ccf
Style: handled some more flake8 warnings: consistent command declaration list formatting
Franz Glasner <hg@dom66.de>
parents:
113
diff
changeset
|
73 ], |
|
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:
151
diff
changeset
|
74 _("hg revinfo [OPTION]... [DEST]"), |
|
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:
151
diff
changeset
|
75 inferrepo=True) |
|
1
a80645763196
revinfo: a module to write .hg_archival.txt like repository metadata
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
76 def revinfo(ui, repo, dest=None, **opts): |
|
a80645763196
revinfo: a module to write .hg_archival.txt like repository metadata
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
77 """write a revision summary |
|
a80645763196
revinfo: a module to write .hg_archival.txt like repository metadata
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
78 |
|
a80645763196
revinfo: a module to write .hg_archival.txt like repository metadata
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
79 If DEST is given the info is written into the file DEST. Otherwise |
|
a80645763196
revinfo: a module to write .hg_archival.txt like repository metadata
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
80 it is written to stdout. |
|
a80645763196
revinfo: a module to write .hg_archival.txt like repository metadata
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
81 |
|
a80645763196
revinfo: a module to write .hg_archival.txt like repository metadata
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
82 By default, the revision used is the parent of the working |
|
a80645763196
revinfo: a module to write .hg_archival.txt like repository metadata
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
83 directory; use -r/--rev to specify a different revision. |
|
a80645763196
revinfo: a module to write .hg_archival.txt like repository metadata
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
84 |
|
40
fe48ca312f92
Use "." if the current repository root is to be assumed as path information
Franz Glasner <hg@dom66.de>
parents:
34
diff
changeset
|
85 Use -p/--path to specify named path information from :hg:`paths` |
|
fe48ca312f92
Use "." if the current repository root is to be assumed as path information
Franz Glasner <hg@dom66.de>
parents:
34
diff
changeset
|
86 as the canonical repository location. It will be printed as "path" |
|
fe48ca312f92
Use "." if the current repository root is to be assumed as path information
Franz Glasner <hg@dom66.de>
parents:
34
diff
changeset
|
87 item to the output. If no path is given then "default" is |
|
fe48ca312f92
Use "." if the current repository root is to be assumed as path information
Franz Glasner <hg@dom66.de>
parents:
34
diff
changeset
|
88 assumed. Use "." to use the current workspace root. |
|
fe48ca312f92
Use "." if the current repository root is to be assumed as path information
Franz Glasner <hg@dom66.de>
parents:
34
diff
changeset
|
89 Disable this by providing an empty SOURCE. |
|
9
33899e714b14
Added a new option "-n/--name" for revinfo to print the canonical repository path
Franz Glasner <hg@dom66.de>
parents:
4
diff
changeset
|
90 |
|
13
c78608f802d4
Implemented "--amend" for revinfo to put extra "path" items into existing files
Franz Glasner <hg@dom66.de>
parents:
12
diff
changeset
|
91 Use --amend to extend a given file with a "path" item. |
|
c78608f802d4
Implemented "--amend" for revinfo to put extra "path" items into existing files
Franz Glasner <hg@dom66.de>
parents:
12
diff
changeset
|
92 Can also be used to put more than one path item into the file. |
|
c78608f802d4
Implemented "--amend" for revinfo to put extra "path" items into existing files
Franz Glasner <hg@dom66.de>
parents:
12
diff
changeset
|
93 |
|
1
a80645763196
revinfo: a module to write .hg_archival.txt like repository metadata
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
94 The printed information is the same as the :hg:`archive` command |
|
13
c78608f802d4
Implemented "--amend" for revinfo to put extra "path" items into existing files
Franz Glasner <hg@dom66.de>
parents:
12
diff
changeset
|
95 writes into ".hg_archival.txt". The "path" info is an extra item. |
|
40
fe48ca312f92
Use "." if the current repository root is to be assumed as path information
Franz Glasner <hg@dom66.de>
parents:
34
diff
changeset
|
96 |
|
1
a80645763196
revinfo: a module to write .hg_archival.txt like repository metadata
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
97 """ |
|
151
11b39af77153
Process opts through pycompat.byteskwargs as all other current extensions do
Franz Glasner <hg@dom66.de>
parents:
150
diff
changeset
|
98 opts = pycompat.byteskwargs(opts) |
|
13
c78608f802d4
Implemented "--amend" for revinfo to put extra "path" items into existing files
Franz Glasner <hg@dom66.de>
parents:
12
diff
changeset
|
99 if opts.get("amend") and opts.get("rev"): |
|
102
702d473b6d85
FIX: The "mercurial.util.Abort" alias is gone: use the mercurial.error.Abort instead.
Franz Glasner <hg@dom66.de>
parents:
99
diff
changeset
|
100 raise error.Abort(_("cannot use -r/--rev together with --amend")) |
|
1
a80645763196
revinfo: a module to write .hg_archival.txt like repository metadata
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
101 |
|
13
c78608f802d4
Implemented "--amend" for revinfo to put extra "path" items into existing files
Franz Glasner <hg@dom66.de>
parents:
12
diff
changeset
|
102 if opts.get("amend"): |
|
c78608f802d4
Implemented "--amend" for revinfo to put extra "path" items into existing files
Franz Glasner <hg@dom66.de>
parents:
12
diff
changeset
|
103 if not dest: |
|
102
702d473b6d85
FIX: The "mercurial.util.Abort" alias is gone: use the mercurial.error.Abort instead.
Franz Glasner <hg@dom66.de>
parents:
99
diff
changeset
|
104 raise error.Abort(_('need a destination file with --amend')) |
|
13
c78608f802d4
Implemented "--amend" for revinfo to put extra "path" items into existing files
Franz Glasner <hg@dom66.de>
parents:
12
diff
changeset
|
105 with open(dest, "rb") as rfile: |
|
c78608f802d4
Implemented "--amend" for revinfo to put extra "path" items into existing files
Franz Glasner <hg@dom66.de>
parents:
12
diff
changeset
|
106 msg = rfile.read() |
|
c78608f802d4
Implemented "--amend" for revinfo to put extra "path" items into existing files
Franz Glasner <hg@dom66.de>
parents:
12
diff
changeset
|
107 else: |
|
c78608f802d4
Implemented "--amend" for revinfo to put extra "path" items into existing files
Franz Glasner <hg@dom66.de>
parents:
12
diff
changeset
|
108 ctx = scmutil.revsingle(repo, opts.get("rev")) |
|
c78608f802d4
Implemented "--amend" for revinfo to put extra "path" items into existing files
Franz Glasner <hg@dom66.de>
parents:
12
diff
changeset
|
109 if not ctx: |
|
114
a51822141ccf
Style: handled some more flake8 warnings: consistent command declaration list formatting
Franz Glasner <hg@dom66.de>
parents:
113
diff
changeset
|
110 raise error.Abort( |
|
a51822141ccf
Style: handled some more flake8 warnings: consistent command declaration list formatting
Franz Glasner <hg@dom66.de>
parents:
113
diff
changeset
|
111 _("no working directory: please specify a revision")) |
|
13
c78608f802d4
Implemented "--amend" for revinfo to put extra "path" items into existing files
Franz Glasner <hg@dom66.de>
parents:
12
diff
changeset
|
112 |
|
c78608f802d4
Implemented "--amend" for revinfo to put extra "path" items into existing files
Franz Glasner <hg@dom66.de>
parents:
12
diff
changeset
|
113 msg = archival.buildmetadata(ctx) |
|
24
c91a5c0f1be3
Add a "-d/--data" option that adds additional "KEY: VALUE" pairs into the revinfo.
Franz Glasner <hg@dom66.de>
parents:
22
diff
changeset
|
114 |
|
c91a5c0f1be3
Add a "-d/--data" option that adds additional "KEY: VALUE" pairs into the revinfo.
Franz Glasner <hg@dom66.de>
parents:
22
diff
changeset
|
115 for kv in opts.get("data"): |
| 113 | 116 kvparts = [i.strip() for i in kv.split("=", 1)] |
|
24
c91a5c0f1be3
Add a "-d/--data" option that adds additional "KEY: VALUE" pairs into the revinfo.
Franz Glasner <hg@dom66.de>
parents:
22
diff
changeset
|
117 if len(kvparts) == 2: |
|
c91a5c0f1be3
Add a "-d/--data" option that adds additional "KEY: VALUE" pairs into the revinfo.
Franz Glasner <hg@dom66.de>
parents:
22
diff
changeset
|
118 msg += "%s: %s\n" % tuple(kvparts) |
|
c91a5c0f1be3
Add a "-d/--data" option that adds additional "KEY: VALUE" pairs into the revinfo.
Franz Glasner <hg@dom66.de>
parents:
22
diff
changeset
|
119 else: |
|
114
a51822141ccf
Style: handled some more flake8 warnings: consistent command declaration list formatting
Franz Glasner <hg@dom66.de>
parents:
113
diff
changeset
|
120 raise error.Abort( |
|
a51822141ccf
Style: handled some more flake8 warnings: consistent command declaration list formatting
Franz Glasner <hg@dom66.de>
parents:
113
diff
changeset
|
121 _("given data `%s' is not a KEY=VALUE pair") % (kv, )) |
|
24
c91a5c0f1be3
Add a "-d/--data" option that adds additional "KEY: VALUE" pairs into the revinfo.
Franz Glasner <hg@dom66.de>
parents:
22
diff
changeset
|
122 |
|
20
8ca89d70b44c
Make the "-p/--path" option an option that can be repeated.
Franz Glasner <hg@dom66.de>
parents:
18
diff
changeset
|
123 paths = opts.get("path") |
|
24
c91a5c0f1be3
Add a "-d/--data" option that adds additional "KEY: VALUE" pairs into the revinfo.
Franz Glasner <hg@dom66.de>
parents:
22
diff
changeset
|
124 # |
|
c91a5c0f1be3
Add a "-d/--data" option that adds additional "KEY: VALUE" pairs into the revinfo.
Franz Glasner <hg@dom66.de>
parents:
22
diff
changeset
|
125 # When not amending and no path options is given print the |
|
c91a5c0f1be3
Add a "-d/--data" option that adds additional "KEY: VALUE" pairs into the revinfo.
Franz Glasner <hg@dom66.de>
parents:
22
diff
changeset
|
126 # "default" path |
|
c91a5c0f1be3
Add a "-d/--data" option that adds additional "KEY: VALUE" pairs into the revinfo.
Franz Glasner <hg@dom66.de>
parents:
22
diff
changeset
|
127 # |
|
c91a5c0f1be3
Add a "-d/--data" option that adds additional "KEY: VALUE" pairs into the revinfo.
Franz Glasner <hg@dom66.de>
parents:
22
diff
changeset
|
128 if not opts.get("amend"): |
|
c91a5c0f1be3
Add a "-d/--data" option that adds additional "KEY: VALUE" pairs into the revinfo.
Franz Glasner <hg@dom66.de>
parents:
22
diff
changeset
|
129 if not paths: |
|
c91a5c0f1be3
Add a "-d/--data" option that adds additional "KEY: VALUE" pairs into the revinfo.
Franz Glasner <hg@dom66.de>
parents:
22
diff
changeset
|
130 paths = ["default"] |
|
20
8ca89d70b44c
Make the "-p/--path" option an option that can be repeated.
Franz Glasner <hg@dom66.de>
parents:
18
diff
changeset
|
131 for canonicalpath in paths: |
|
8ca89d70b44c
Make the "-p/--path" option an option that can be repeated.
Franz Glasner <hg@dom66.de>
parents:
18
diff
changeset
|
132 if canonicalpath: |
|
40
fe48ca312f92
Use "." if the current repository root is to be assumed as path information
Franz Glasner <hg@dom66.de>
parents:
34
diff
changeset
|
133 if canonicalpath == ".": |
|
fe48ca312f92
Use "." if the current repository root is to be assumed as path information
Franz Glasner <hg@dom66.de>
parents:
34
diff
changeset
|
134 msg += "path: %s\n" % repo.root |
|
20
8ca89d70b44c
Make the "-p/--path" option an option that can be repeated.
Franz Glasner <hg@dom66.de>
parents:
18
diff
changeset
|
135 else: |
|
40
fe48ca312f92
Use "." if the current repository root is to be assumed as path information
Franz Glasner <hg@dom66.de>
parents:
34
diff
changeset
|
136 for name, path in sorted(ui.paths.iteritems()): |
|
fe48ca312f92
Use "." if the current repository root is to be assumed as path information
Franz Glasner <hg@dom66.de>
parents:
34
diff
changeset
|
137 if name == canonicalpath: |
|
fe48ca312f92
Use "." if the current repository root is to be assumed as path information
Franz Glasner <hg@dom66.de>
parents:
34
diff
changeset
|
138 msg += "path: %s\n" % util.hidepassword(path.loc) |
|
fe48ca312f92
Use "." if the current repository root is to be assumed as path information
Franz Glasner <hg@dom66.de>
parents:
34
diff
changeset
|
139 break |
|
fe48ca312f92
Use "." if the current repository root is to be assumed as path information
Franz Glasner <hg@dom66.de>
parents:
34
diff
changeset
|
140 else: |
|
fe48ca312f92
Use "." if the current repository root is to be assumed as path information
Franz Glasner <hg@dom66.de>
parents:
34
diff
changeset
|
141 msg += "path: %s\n" % canonicalpath |
|
1
a80645763196
revinfo: a module to write .hg_archival.txt like repository metadata
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
142 if dest: |
|
a80645763196
revinfo: a module to write .hg_archival.txt like repository metadata
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
143 with open(dest, "wb") as rfile: |
|
a80645763196
revinfo: a module to write .hg_archival.txt like repository metadata
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
144 rfile.write(msg) |
|
a80645763196
revinfo: a module to write .hg_archival.txt like repository metadata
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
145 else: |
|
a80645763196
revinfo: a module to write .hg_archival.txt like repository metadata
Franz Glasner <hg@dom66.de>
parents:
diff
changeset
|
146 ui.write(msg) |
