8 |
8 |
9 There are many good reasons why this is not needed in a distributed |
9 There are many good reasons why this is not needed in a distributed |
10 SCM, still it may be useful in very small projects based on single |
10 SCM, still it may be useful in very small projects based on single |
11 files (like LaTeX packages), that are mostly addressed to an audience |
11 files (like LaTeX packages), that are mostly addressed to an audience |
12 not running a version control system. |
12 not running a version control system. |
|
13 |
|
14 For in-depth discussion refer to |
|
15 <http://www.selenic.com/mercurial/wiki/index.cgi/KeywordPlan>. |
13 |
16 |
14 You can either use the default cvs-like keywords or provide your |
17 You can either use the default cvs-like keywords or provide your |
15 own in hgrc. |
18 own in hgrc. |
16 |
19 |
17 Default $keywords$ and their $keyword: substition $ are: |
20 Default $keywords$ and their $keyword: substition $ are: |
32 |
35 |
33 # filename patterns for expansion are configured in this section |
36 # filename patterns for expansion are configured in this section |
34 [keyword] |
37 [keyword] |
35 **.py = expand |
38 **.py = expand |
36 ... |
39 ... |
37 # in case you prefer you own keyword maps over the cvs-like defaults: |
40 # in case you prefer your own keyword maps over the cvs-like defaults: |
38 [keywordmaps] |
41 [keywordmaps] |
39 hgdate = {date|rfc822date} |
42 HGdate = {date|rfc822date} |
40 lastlog = {desc} |
43 lastlog = {desc|firstline} |
41 checked in by = {author} |
44 checked in by = {author} |
42 ... |
45 ... |
43 ''' |
46 ''' |
44 |
47 |
45 from mercurial import cmdutil, templater, util |
48 from mercurial import cmdutil, templater, util |
95 '|'.join(re.escape(k) for k in self.templates.keys())) |
98 '|'.join(re.escape(k) for k in self.templates.keys())) |
96 self.t = cmdutil.changeset_templater(self.ui, self.repo, |
99 self.t = cmdutil.changeset_templater(self.ui, self.repo, |
97 False, '', False) |
100 False, '', False) |
98 |
101 |
99 def expand(self, mobj, path, node): |
102 def expand(self, mobj, path, node): |
|
103 '''Expands keyword with corresponding template.''' |
100 kw = mobj.group(1) |
104 kw = mobj.group(1) |
101 template = templater.parsestring(self.templates[kw], quoted=False) |
105 template = templater.parsestring(self.templates[kw], quoted=False) |
102 self.t.use_template(template) |
106 self.t.use_template(template) |
103 self.ui.pushbuffer() |
107 self.ui.pushbuffer() |
104 self.t.show(changenode=node, root=self.repo.root, file=path) |
108 self.t.show(changenode=node, root=self.repo.root, file=path) |
146 def add(self, text, meta, tr, link, p1=None, p2=None): |
150 def add(self, text, meta, tr, link, p1=None, p2=None): |
147 '''Removes keyword substitutions when adding to filelog.''' |
151 '''Removes keyword substitutions when adding to filelog.''' |
148 if self.iskwcandidate(text): |
152 if self.iskwcandidate(text): |
149 text = self.kwt.re_kw.sub(r'$\1$', text) |
153 text = self.kwt.re_kw.sub(r'$\1$', text) |
150 return super(kwfilelog, self).add(text, |
154 return super(kwfilelog, self).add(text, |
151 meta, tr, link, p1=p1, p2=p2) |
155 meta, tr, link, p1=p1, p2=p2) |
152 |
156 |
153 def cmp(self, node, text): |
157 def cmp(self, node, text): |
154 '''Removes keyword substitutions for comparison.''' |
158 '''Removes keyword substitutions for comparison.''' |
155 if self.iskwcandidate(text): |
159 if self.iskwcandidate(text): |
156 text = self.kwt.re_kw.sub(r'$\1$', text) |
160 text = self.kwt.re_kw.sub(r'$\1$', text) |