Mercurial > hg > mercurial-crew-with-dirclash
annotate hgext/interhg.py @ 5390:36c46e20976a
merge: provide *_ISLINK environment vars to merge helper
Sets HG_MY_ISLINK, HG_OTHER_ISLINK, HG_BASE_ISLINK in environment. Without these variables, it's impossible for the merge application to know whether the 'other' and 'base' files were symlinks in their original contexts. For the purposes of the merge they are always emitted as small text files.
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Wed, 03 Oct 2007 23:09:36 +0200 |
parents | 18091102a633 |
children |
rev | line source |
---|---|
4818
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:
4818
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:
4818
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:
4818
diff
changeset
|
7 # |
4818
0ac6b537893f
interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff
changeset
|
8 # This software may be used and distributed according to the terms |
0ac6b537893f
interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff
changeset
|
9 # of the GNU General Public License, incorporated herein by reference. |
0ac6b537893f
interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff
changeset
|
10 # |
0ac6b537893f
interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff
changeset
|
11 # The `interhg' Mercurial extension allows you to change changelog and |
0ac6b537893f
interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff
changeset
|
12 # summary text just like InterWiki way. |
0ac6b537893f
interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff
changeset
|
13 # |
0ac6b537893f
interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff
changeset
|
14 # To enable this extension: |
0ac6b537893f
interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff
changeset
|
15 # |
0ac6b537893f
interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff
changeset
|
16 # [extensions] |
0ac6b537893f
interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff
changeset
|
17 # interhg = |
0ac6b537893f
interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff
changeset
|
18 # |
5288
18091102a633
interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents:
4818
diff
changeset
|
19 # These are some example patterns (link to bug tracking, etc.) |
4818
0ac6b537893f
interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff
changeset
|
20 # |
0ac6b537893f
interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff
changeset
|
21 # [interhg] |
5288
18091102a633
interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents:
4818
diff
changeset
|
22 # issues = s!issue(\d+)!<a href="http://bts/issue\1">issue\1<\/a>! |
18091102a633
interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents:
4818
diff
changeset
|
23 # bugzilla = s!((?:bug|b=|(?=#?\d{4,}))(?:\s*#?)(\d+))!<a..=\2">\1</a>!i |
18091102a633
interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents:
4818
diff
changeset
|
24 # boldify = s/(^|\s)#(\d+)\b/ <b>#\2<\/b>/ |
4818
0ac6b537893f
interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff
changeset
|
25 # |
5288
18091102a633
interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents:
4818
diff
changeset
|
26 # Add any number of names and patterns to match |
4818
0ac6b537893f
interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff
changeset
|
27 |
0ac6b537893f
interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff
changeset
|
28 import re |
0ac6b537893f
interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff
changeset
|
29 from mercurial.hgweb import hgweb_mod |
0ac6b537893f
interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff
changeset
|
30 from mercurial import templater |
0ac6b537893f
interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff
changeset
|
31 |
0ac6b537893f
interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff
changeset
|
32 orig_escape = templater.common_filters["escape"] |
0ac6b537893f
interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff
changeset
|
33 |
0ac6b537893f
interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff
changeset
|
34 interhg_table = [] |
0ac6b537893f
interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff
changeset
|
35 |
0ac6b537893f
interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff
changeset
|
36 def interhg_escape(x): |
0ac6b537893f
interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff
changeset
|
37 escstr = orig_escape(x) |
5288
18091102a633
interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents:
4818
diff
changeset
|
38 for regexp, format in interhg_table: |
4818
0ac6b537893f
interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff
changeset
|
39 escstr = regexp.sub(format, escstr) |
0ac6b537893f
interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff
changeset
|
40 return escstr |
0ac6b537893f
interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff
changeset
|
41 |
0ac6b537893f
interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff
changeset
|
42 templater.common_filters["escape"] = interhg_escape |
0ac6b537893f
interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff
changeset
|
43 |
0ac6b537893f
interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff
changeset
|
44 orig_refresh = hgweb_mod.hgweb.refresh |
0ac6b537893f
interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff
changeset
|
45 |
0ac6b537893f
interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff
changeset
|
46 def interhg_refresh(self): |
0ac6b537893f
interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff
changeset
|
47 interhg_table[:] = [] |
5288
18091102a633
interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents:
4818
diff
changeset
|
48 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:
4818
diff
changeset
|
49 # 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:
4818
diff
changeset
|
50 unesc = pattern[1] |
18091102a633
interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents:
4818
diff
changeset
|
51 delim = re.escape(unesc) |
18091102a633
interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents:
4818
diff
changeset
|
52 |
18091102a633
interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents:
4818
diff
changeset
|
53 # 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:
4818
diff
changeset
|
54 # 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:
4818
diff
changeset
|
55 # are required. |
18091102a633
interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents:
4818
diff
changeset
|
56 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:
4818
diff
changeset
|
57 % (delim, delim, delim), pattern) |
18091102a633
interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents:
4818
diff
changeset
|
58 if not match: |
18091102a633
interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents:
4818
diff
changeset
|
59 self.repo.ui.warn("interhg: invalid pattern for %s: %s\n" |
18091102a633
interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents:
4818
diff
changeset
|
60 % (key, pattern)) |
18091102a633
interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents:
4818
diff
changeset
|
61 continue |
18091102a633
interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents:
4818
diff
changeset
|
62 |
18091102a633
interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents:
4818
diff
changeset
|
63 # 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:
4818
diff
changeset
|
64 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:
4818
diff
changeset
|
65 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:
4818
diff
changeset
|
66 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:
4818
diff
changeset
|
67 |
18091102a633
interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents:
4818
diff
changeset
|
68 # 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:
4818
diff
changeset
|
69 flagin = match.group(3) |
18091102a633
interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents:
4818
diff
changeset
|
70 flags = 0 |
18091102a633
interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents:
4818
diff
changeset
|
71 if flagin: |
18091102a633
interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents:
4818
diff
changeset
|
72 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:
4818
diff
changeset
|
73 flags |= re.__dict__[flag] |
18091102a633
interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents:
4818
diff
changeset
|
74 |
18091102a633
interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents:
4818
diff
changeset
|
75 try: |
18091102a633
interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents:
4818
diff
changeset
|
76 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:
4818
diff
changeset
|
77 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:
4818
diff
changeset
|
78 except re.error: |
18091102a633
interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents:
4818
diff
changeset
|
79 self.repo.ui.warn("interhg: invalid regexp for %s: %s\n" |
18091102a633
interhg: allow more flexible pattern specification (fixes 2/3 of issue699)
Edward Lee <edward.lee@engineering.uiuc.edu>
parents:
4818
diff
changeset
|
80 % (key, regexp)) |
4818
0ac6b537893f
interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff
changeset
|
81 return orig_refresh(self) |
0ac6b537893f
interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff
changeset
|
82 |
0ac6b537893f
interhg extension allows you to change changelog text like InterWiki.
OHASHI Hideya <ohachige@gmail.com>
parents:
diff
changeset
|
83 hgweb_mod.hgweb.refresh = interhg_refresh |