# HG changeset patch # User Jun Wu # Date 1462824660 -3600 # Node ID 7e98352a37db9c185bebc28f9ae150e2e8c4ca9a # Parent 025e849d22f0a52844a9631981b817c0af07a278 maps: add the "batchset" method to RevMap This is a part of the bigger plan to get rid of reading or writing rev_map directly without going through the RevMap class. The "batchset" method is like "__setitem__" but set items in batches. It will be used in rebuildmeta. diff --git a/hgsubversion/maps.py b/hgsubversion/maps.py --- a/hgsubversion/maps.py +++ b/hgsubversion/maps.py @@ -360,6 +360,19 @@ class RevMap(dict): dict.clear(self) self._hashes = None + def batchset(self, items): + '''Set items in batches + + items is an array of (rev num, branch, binary hash) + + For performance reason, meta.lastpulled and meta.firstpulled + are not updated. + ''' + f = open(self.meta.revmap_file, 'a') + f.write(''.join('%s %s %s\n' % (revnum, hex(binhash), br or '') + for revnum, br, binhash in items)) + f.close() + @classmethod def readmapfile(cls, path, missingok=True): try: