##// END OF EJS Templates
context: get filesadded() and filesremoved() from changeset if configured...
Martin von Zweigbergk -
r42599:602469a9 default
parent child Browse files
Show More
@@ -107,6 +107,20 b' def encodefileindices(files, 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')
@@ -202,6 +216,8 b' class _changelogrevision(object):'
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='')
@@ -308,6 +324,16 b' class changelogrevision(object):'
308 return self._text[off[2] + 1:off[3]].split('\n')
324 return self._text[off[2] + 1:off[3]].split('\n')
309
325
310 @property
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)
335
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)
@@ -469,12 +469,24 b' class changectx(basectx):'
469 modified.difference_update(self.filesremoved())
469 modified.difference_update(self.filesremoved())
470 return sorted(modified)
470 return sorted(modified)
471 def filesadded(self):
471 def filesadded(self):
472 source = self._repo.ui.config('experimental', 'copies.read-from')
473 if (source == 'changeset-only' or
474 (source == 'compatibility' and
475 self._changeset.filesadded is not None)):
476 return self._changeset.filesadded or []
477
472 added = []
478 added = []
473 for f in self.files():
479 for f in self.files():
474 if not any(f in p for p in self.parents()):
480 if not any(f in p for p in self.parents()):
475 added.append(f)
481 added.append(f)
476 return added
482 return added
477 def filesremoved(self):
483 def filesremoved(self):
484 source = self._repo.ui.config('experimental', 'copies.read-from')
485 if (source == 'changeset-only' or
486 (source == 'compatibility' and
487 self._changeset.filesremoved is not None)):
488 return self._changeset.filesremoved or []
489
478 removed = []
490 removed = []
479 for f in self.files():
491 for f in self.files():
480 if f not in self:
492 if f not in self:
General Comments 0
You need to be logged in to leave comments. Login now