Mercurial > hg
comparison mercurial/changelog.py @ 42407:602469a91550
context: get filesadded() and filesremoved() from changeset if configured
This adds the read side for getting the sets of added and removed
files from the changeset extras. I timed this command on the hg repo:
hg log -T '{rev}\n {files}\n %:{file_mods}\n +{file_adds}\n -{file_dels}\n'
It took 1m21s before and 6.4s after. I also used that command to check
that the result didn't change compared to calculating the values from
the manifests on the fly (it didn't change).
In the mozilla-unified repo, the same command run on
FIREFOX_BETA_58_END::FIREFOX_BETA_59_END went from 29s to 0.67s.
Differential Revision: https://phab.mercurial-scm.org/D6417
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Tue, 14 May 2019 22:20:10 -0700 |
parents | f385ba70e4af |
children | a1f87294471f |
comparison
equal
deleted
inserted
replaced
42406:f385ba70e4af | 42407:602469a91550 |
---|---|
105 for i, f in enumerate(files): | 105 for i, f in enumerate(files): |
106 if f in subset: | 106 if f in subset: |
107 indices.append('%d' % i) | 107 indices.append('%d' % i) |
108 return '\0'.join(indices) | 108 return '\0'.join(indices) |
109 | 109 |
110 def decodefileindices(files, data): | |
111 try: | |
112 subset = [] | |
113 for strindex in data.split('\0'): | |
114 i = int(strindex) | |
115 if i < 0 or i >= len(files): | |
116 return None | |
117 subset.append(files[i]) | |
118 return subset | |
119 except (ValueError, IndexError): | |
120 # Perhaps someone had chosen the same key name (e.g. "added") and | |
121 # used different syntax for the value. | |
122 return None | |
123 | |
110 def stripdesc(desc): | 124 def stripdesc(desc): |
111 """strip trailing whitespace and leading and trailing empty lines""" | 125 """strip trailing whitespace and leading and trailing empty lines""" |
112 return '\n'.join([l.rstrip() for l in desc.splitlines()]).strip('\n') | 126 return '\n'.join([l.rstrip() for l in desc.splitlines()]).strip('\n') |
113 | 127 |
114 class appender(object): | 128 class appender(object): |
200 extra = attr.ib() | 214 extra = attr.ib() |
201 manifest = attr.ib(default=nullid) | 215 manifest = attr.ib(default=nullid) |
202 user = attr.ib(default='') | 216 user = attr.ib(default='') |
203 date = attr.ib(default=(0, 0)) | 217 date = attr.ib(default=(0, 0)) |
204 files = attr.ib(default=attr.Factory(list)) | 218 files = attr.ib(default=attr.Factory(list)) |
219 filesadded = attr.ib(default=None) | |
220 filesremoved = attr.ib(default=None) | |
205 p1copies = attr.ib(default=None) | 221 p1copies = attr.ib(default=None) |
206 p2copies = attr.ib(default=None) | 222 p2copies = attr.ib(default=None) |
207 description = attr.ib(default='') | 223 description = attr.ib(default='') |
208 | 224 |
209 class changelogrevision(object): | 225 class changelogrevision(object): |
304 off = self._offsets | 320 off = self._offsets |
305 if off[2] == off[3]: | 321 if off[2] == off[3]: |
306 return [] | 322 return [] |
307 | 323 |
308 return self._text[off[2] + 1:off[3]].split('\n') | 324 return self._text[off[2] + 1:off[3]].split('\n') |
325 | |
326 @property | |
327 def filesadded(self): | |
328 rawindices = self.extra.get('filesadded') | |
329 return rawindices and decodefileindices(self.files, rawindices) | |
330 | |
331 @property | |
332 def filesremoved(self): | |
333 rawindices = self.extra.get('filesremoved') | |
334 return rawindices and decodefileindices(self.files, rawindices) | |
309 | 335 |
310 @property | 336 @property |
311 def p1copies(self): | 337 def p1copies(self): |
312 rawcopies = self.extra.get('p1copies') | 338 rawcopies = self.extra.get('p1copies') |
313 return rawcopies and decodecopies(rawcopies) | 339 return rawcopies and decodecopies(rawcopies) |