# HG changeset patch # User Jun Wu # Date 1466011526 -3600 # Node ID 7bb2c6ca4d2497f6107cfc553a193cbb99fe37b5 # Parent b98ff95b5861aa8ec63fead28fd9ff4074db5ae7 maps: implement migration from SqliteRevMap to RevMap It'd be good to let user migrate up and down freely. diff --git a/hgsubversion/maps.py b/hgsubversion/maps.py --- a/hgsubversion/maps.py +++ b/hgsubversion/maps.py @@ -420,6 +420,13 @@ class RevMap(dict): raise return iter([]) ver = int(f.readline()) + if ver == SqliteRevMap.VERSION: + revmap = SqliteRevMap(self._filepath, self._lastpulled_file) + tmppath = '%s.tmp' % self._filepath + revmap.exportrevmapv1(tmppath) + os.rename(tmppath, self._filepath) + hgutil.unlinkpath(revmap._dbpath) + return self._readmapfile() if ver != self.VERSION: raise hgutil.Abort('revmap too new -- please upgrade') return f @@ -732,6 +739,14 @@ class SqliteRevMap(collections.MutableMa data[revnum, branch or None] = bin(ha) self._insert([(r, b, h) for (r, b), h in data.iteritems()]) + @util.gcdisable + def exportrevmapv1(self, path): + with open(path, 'w') as f: + f.write('%s\n' % RevMap.VERSION) + for row in self._query('SELECT rev, branch, hash FROM revmap'): + rev, br, ha = row + f.write('%s %s %s\n' % (rev, hex(ha), br)) + class FileMap(object):