From f741bf39f2a875bcc6051296a0ff643bcaa76e4d Mon Sep 17 00:00:00 2001 From: Frej Drejhammar Date: Fri, 19 Feb 2021 16:46:37 +0100 Subject: [PATCH] bugfix: Avoid starting incremental conversions from scratch Keys and values in the state cache are byte strings, therefore a lookup of 'tip' will always fail. The failure makes the conversion start over from the beginning, but as fast-export is deterministic the results are the same, just very inefficient. The bug has existed since the port to Python 3. This patch switches the 'tip' lookup to use a byte string which should make incremental conversions restart at the last converted commit. As 'x' == b'x' in Python 2, this should be a backwards compatible change. Bug reported and fix suggested by Tomas Kolda. Fixes #258. --- hg-fast-export.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hg-fast-export.py b/hg-fast-export.py index 7c22d81..299d851 100755 --- a/hg-fast-export.py +++ b/hg-fast-export.py @@ -547,7 +547,7 @@ def hg2git(repourl,m,marksfile,mappingfile,headsfile,tipfile, except AttributeError: tip=len(repo) - min=int(state_cache.get('tip',0)) + min=int(state_cache.get(b'tip',0)) max=_max if _max<0 or max>tip: max=tip @@ -580,8 +580,8 @@ def hg2git(repourl,m,marksfile,mappingfile,headsfile,tipfile, for rev in range(min,max): c=export_note(ui,repo,rev,c,authors, encoding, rev == min and min != 0) - state_cache['tip']=max - state_cache['repo']=repourl + state_cache[b'tip']=max + state_cache[b'repo']=repourl save_cache(tipfile,state_cache) save_cache(mappingfile,mapping_cache)