Show More
@@ -86,17 +86,15 import re, shutil, sys, tempfile, time | |||||
86 |
|
86 | |||
87 | commands.optionalrepo += ' kwdemo' |
|
87 | commands.optionalrepo += ' kwdemo' | |
88 |
|
88 | |||
|
89 | # hg commands that trigger expansion only when writing to working dir, | |||
|
90 | # not when reading filelog, and unexpand when reading from working dir | |||
|
91 | restricted = ('diff1', 'record', | |||
|
92 | 'qfold', 'qimport', 'qnew', 'qpush', 'qrefresh', 'qrecord') | |||
|
93 | ||||
89 | def utcdate(date): |
|
94 | def utcdate(date): | |
90 | '''Returns hgdate in cvs-like UTC format.''' |
|
95 | '''Returns hgdate in cvs-like UTC format.''' | |
91 | return time.strftime('%Y/%m/%d %H:%M:%S', time.gmtime(date[0])) |
|
96 | return time.strftime('%Y/%m/%d %H:%M:%S', time.gmtime(date[0])) | |
92 |
|
97 | |||
93 | def _kwrestrict(cmd): |
|
|||
94 | '''Returns True if cmd should trigger restricted expansion. |
|
|||
95 | Keywords will only expanded when writing to working dir. |
|
|||
96 | Crucial for mq as expanded keywords should not make it into patches.''' |
|
|||
97 | return cmd in ('diff1', 'record', |
|
|||
98 | 'qfold', 'qimport', 'qnew', 'qpush', 'qrefresh', 'qrecord') |
|
|||
99 |
|
||||
100 |
|
98 | |||
101 | _kwtemplater = None |
|
99 | _kwtemplater = None | |
102 |
|
100 | |||
@@ -157,7 +155,7 class kwtemplater(object): | |||||
157 |
|
155 | |||
158 | def expand(self, node, data): |
|
156 | def expand(self, node, data): | |
159 | '''Returns data with keywords expanded.''' |
|
157 | '''Returns data with keywords expanded.''' | |
160 |
if util.binary(data) or |
|
158 | if util.binary(data) or self.hgcmd in restricted: | |
161 | return data |
|
159 | return data | |
162 | return self.substitute(node, data, self.re_kw.sub) |
|
160 | return self.substitute(node, data, self.re_kw.sub) | |
163 |
|
161 | |||
@@ -451,7 +449,7 def reposetup(ui, repo): | |||||
451 |
|
449 | |||
452 | def wread(self, filename): |
|
450 | def wread(self, filename): | |
453 | data = super(kwrepo, self).wread(filename) |
|
451 | data = super(kwrepo, self).wread(filename) | |
454 |
if |
|
452 | if hgcmd in restricted and _kwtemplater.matcher(filename): | |
455 | return _kwtemplater.shrink(data) |
|
453 | return _kwtemplater.shrink(data) | |
456 | return data |
|
454 | return data | |
457 |
|
455 |
General Comments 0
You need to be logged in to leave comments.
Login now