annotate hgext/interhg.py @ 13411:d4de90a612f7

commit: abort if a subrepo is modified and ui.commitsubrepos=no The default behaviour is to commit subrepositories with uncommitted changes. In my experience this is usually undesirable: - Changes to dependencies are often debugging leftovers - Real changes should generally be applied on the source project directly, tested then committed. This is not always possible, subversion subrepos may include only a small part of the source project, without the tests. Setting ui.commitsubrepos=no will now abort commits containing such modified subrepositories like: $ hg --config ui.commitsubrepos=no ci -m msg abort: uncommitted changes in subrepo sub I ruled out the hook solution because it does not easily take --include/exclude options in account. Also, my main concern is whether this flag could cause problems with extensions. If there are legitimate reasons for callers to override this behaviour (I could not find any), they might either override at ui level, or we could add an argument to localrepo.commit() later. v2: - Renamed ui.commitsubs to ui.commitsubrepos - Mention the configuration entry in hg help subrepos
author Patrick Mezard <pmezard@gmail.com>
date Tue, 15 Feb 2011 22:25:48 +0100
parents 21a50fe47a92
children 38caf405d010
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4817
0ac6b537893f interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff changeset
1 # interhg.py - interhg
0ac6b537893f interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff changeset
2 #
0ac6b537893f interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff changeset
3 # Copyright 2007 OHASHI Hideya <ohachige@gmail.com>
0ac6b537893f interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff changeset
4 #
5288
18091102a633 interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents: 4817
diff changeset
5 # Contributor(s):
18091102a633 interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents: 4817
diff changeset
6 # Edward Lee <edward.lee@engineering.uiuc.edu>
18091102a633 interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents: 4817
diff changeset
7 #
8225
46293a0c7e9f updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents: 7216
diff changeset
8 # This software may be used and distributed according to the terms of the
10263
25e572394f5c Update license to GPLv2+
Matt Mackall <mpm@selenic.com>
parents: 9263
diff changeset
9 # GNU General Public License version 2 or any later version.
8824
67ee7587abea interhg: upgrade comments to online help and improve them
Cédric Duval <cedricduval@free.fr>
parents: 8225
diff changeset
10
67ee7587abea interhg: upgrade comments to online help and improve them
Cédric Duval <cedricduval@free.fr>
parents: 8225
diff changeset
11 '''expand expressions into changelog and summaries
67ee7587abea interhg: upgrade comments to online help and improve them
Cédric Duval <cedricduval@free.fr>
parents: 8225
diff changeset
12
9263
2dd1ed9e44db interhg: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents: 9211
diff changeset
13 This extension allows the use of a special syntax in summaries, which
2dd1ed9e44db interhg: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents: 9211
diff changeset
14 will be automatically expanded into links or any other arbitrary
2dd1ed9e44db interhg: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents: 9211
diff changeset
15 expression, much like InterWiki does.
8824
67ee7587abea interhg: upgrade comments to online help and improve them
Cédric Duval <cedricduval@free.fr>
parents: 8225
diff changeset
16
9263
2dd1ed9e44db interhg: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents: 9211
diff changeset
17 A few example patterns (link to bug tracking, etc.) that may be used
2dd1ed9e44db interhg: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents: 9211
diff changeset
18 in your hgrc::
8824
67ee7587abea interhg: upgrade comments to online help and improve them
Cédric Duval <cedricduval@free.fr>
parents: 8225
diff changeset
19
67ee7587abea interhg: upgrade comments to online help and improve them
Cédric Duval <cedricduval@free.fr>
parents: 8225
diff changeset
20 [interhg]
8910
0c610f77ae1a interhg: escape backslashes in docstring
Martin Geisler <mg@lazybytes.net>
parents: 8909
diff changeset
21 issues = s!issue(\\d+)!<a href="http://bts/issue\\1">issue\\1</a>!
0c610f77ae1a interhg: escape backslashes in docstring
Martin Geisler <mg@lazybytes.net>
parents: 8909
diff changeset
22 bugzilla = s!((?:bug|b=|(?=#?\\d{4,}))(?:\\s*#?)(\\d+))!<a..=\\2">\\1</a>!i
0c610f77ae1a interhg: escape backslashes in docstring
Martin Geisler <mg@lazybytes.net>
parents: 8909
diff changeset
23 boldify = s!(^|\\s)#(\\d+)\\b! <b>#\\2</b>!
8824
67ee7587abea interhg: upgrade comments to online help and improve them
Cédric Duval <cedricduval@free.fr>
parents: 8225
diff changeset
24 '''
4817
0ac6b537893f interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff changeset
25
0ac6b537893f interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff changeset
26 import re
0ac6b537893f interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff changeset
27 from mercurial.hgweb import hgweb_mod
7216
292fb2ad2846 extensions: use new wrapper functions
Matt Mackall <mpm@selenic.com>
parents: 6962
diff changeset
28 from mercurial import templatefilters, extensions
6962
2af657eafeba i18n: mark strings for translation in interhg extension
Martin Geisler <mg@daimi.au.dk>
parents: 5976
diff changeset
29 from mercurial.i18n import _
4817
0ac6b537893f interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff changeset
30
0ac6b537893f interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff changeset
31 interhg_table = []
0ac6b537893f interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff changeset
32
12766
21a50fe47a92 interhg: use uisetup() instead of module-load side effects
Augie Fackler <durin42@gmail.com>
parents: 10472
diff changeset
33 def uisetup(ui):
21a50fe47a92 interhg: use uisetup() instead of module-load side effects
Augie Fackler <durin42@gmail.com>
parents: 10472
diff changeset
34 orig_escape = templatefilters.filters["escape"]
4817
0ac6b537893f interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff changeset
35
12766
21a50fe47a92 interhg: use uisetup() instead of module-load side effects
Augie Fackler <durin42@gmail.com>
parents: 10472
diff changeset
36 def interhg_escape(x):
21a50fe47a92 interhg: use uisetup() instead of module-load side effects
Augie Fackler <durin42@gmail.com>
parents: 10472
diff changeset
37 escstr = orig_escape(x)
21a50fe47a92 interhg: use uisetup() instead of module-load side effects
Augie Fackler <durin42@gmail.com>
parents: 10472
diff changeset
38 for regexp, format in interhg_table:
21a50fe47a92 interhg: use uisetup() instead of module-load side effects
Augie Fackler <durin42@gmail.com>
parents: 10472
diff changeset
39 escstr = regexp.sub(format, escstr)
21a50fe47a92 interhg: use uisetup() instead of module-load side effects
Augie Fackler <durin42@gmail.com>
parents: 10472
diff changeset
40 return escstr
21a50fe47a92 interhg: use uisetup() instead of module-load side effects
Augie Fackler <durin42@gmail.com>
parents: 10472
diff changeset
41
21a50fe47a92 interhg: use uisetup() instead of module-load side effects
Augie Fackler <durin42@gmail.com>
parents: 10472
diff changeset
42 templatefilters.filters["escape"] = interhg_escape
4817
0ac6b537893f interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff changeset
43
10472
9126d13bad7a interhg: fixes regression introduced by 38170eeed18c
Wagner Bruna <wbruna@yahoo.com>
parents: 10263
diff changeset
44 def interhg_refresh(orig, self, *args, **kwargs):
4817
0ac6b537893f interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff changeset
45 interhg_table[:] = []
5288
18091102a633 interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents: 4817
diff changeset
46 for key, pattern in self.repo.ui.configitems('interhg'):
18091102a633 interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents: 4817
diff changeset
47 # grab the delimiter from the character after the "s"
18091102a633 interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents: 4817
diff changeset
48 unesc = pattern[1]
18091102a633 interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents: 4817
diff changeset
49 delim = re.escape(unesc)
18091102a633 interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents: 4817
diff changeset
50
18091102a633 interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents: 4817
diff changeset
51 # identify portions of the pattern, taking care to avoid escaped
18091102a633 interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents: 4817
diff changeset
52 # delimiters. the replace format and flags are optional, but delimiters
18091102a633 interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents: 4817
diff changeset
53 # are required.
18091102a633 interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents: 4817
diff changeset
54 match = re.match(r'^s%s(.+)(?:(?<=\\\\)|(?<!\\))%s(.*)%s([ilmsux])*$'
18091102a633 interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents: 4817
diff changeset
55 % (delim, delim, delim), pattern)
18091102a633 interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents: 4817
diff changeset
56 if not match:
6962
2af657eafeba i18n: mark strings for translation in interhg extension
Martin Geisler <mg@daimi.au.dk>
parents: 5976
diff changeset
57 self.repo.ui.warn(_("interhg: invalid pattern for %s: %s\n")
5288
18091102a633 interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents: 4817
diff changeset
58 % (key, pattern))
18091102a633 interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents: 4817
diff changeset
59 continue
18091102a633 interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents: 4817
diff changeset
60
18091102a633 interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents: 4817
diff changeset
61 # we need to unescape the delimiter for regexp and format
18091102a633 interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents: 4817
diff changeset
62 delim_re = re.compile(r'(?<!\\)\\%s' % delim)
18091102a633 interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents: 4817
diff changeset
63 regexp = delim_re.sub(unesc, match.group(1))
18091102a633 interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents: 4817
diff changeset
64 format = delim_re.sub(unesc, match.group(2))
18091102a633 interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents: 4817
diff changeset
65
18091102a633 interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents: 4817
diff changeset
66 # the pattern allows for 6 regexp flags, so set them if necessary
18091102a633 interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents: 4817
diff changeset
67 flagin = match.group(3)
18091102a633 interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents: 4817
diff changeset
68 flags = 0
18091102a633 interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents: 4817
diff changeset
69 if flagin:
18091102a633 interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents: 4817
diff changeset
70 for flag in flagin.upper():
18091102a633 interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents: 4817
diff changeset
71 flags |= re.__dict__[flag]
18091102a633 interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents: 4817
diff changeset
72
18091102a633 interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents: 4817
diff changeset
73 try:
18091102a633 interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents: 4817
diff changeset
74 regexp = re.compile(regexp, flags)
18091102a633 interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents: 4817
diff changeset
75 interhg_table.append((regexp, format))
18091102a633 interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents: 4817
diff changeset
76 except re.error:
6962
2af657eafeba i18n: mark strings for translation in interhg extension
Martin Geisler <mg@daimi.au.dk>
parents: 5976
diff changeset
77 self.repo.ui.warn(_("interhg: invalid regexp for %s: %s\n")
5288
18091102a633 interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents: 4817
diff changeset
78 % (key, regexp))
10472
9126d13bad7a interhg: fixes regression introduced by 38170eeed18c
Wagner Bruna <wbruna@yahoo.com>
parents: 10263
diff changeset
79 return orig(self, *args, **kwargs)
4817
0ac6b537893f interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff changeset
80
7216
292fb2ad2846 extensions: use new wrapper functions
Matt Mackall <mpm@selenic.com>
parents: 6962
diff changeset
81 extensions.wrapfunction(hgweb_mod.hgweb, 'refresh', interhg_refresh)