From 8551771d2b3ce508a6d901f7cde6818d4e20e361 Mon Sep 17 00:00:00 2001 From: Rocco Rutte Date: Mon, 22 Oct 2007 09:50:52 +0200 Subject: [PATCH] hg2git.py: Allow consumers to modify keys of dicts returned by load_cache() By default, the key is not changed. This will allow us for fixing up the off-by-one issue with marks restored using load_cache(). Signed-off-by: Rocco Rutte --- hg2git.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hg2git.py b/hg2git.py index c58b4e7..3015e0b 100755 --- a/hg2git.py +++ b/hg2git.py @@ -57,7 +57,10 @@ def get_changeset(ui,repo,revision,authors={}): branch=get_branch(extra.get('branch','master')) return (node,manifest,fixup_user(user,authors),(time,tz),files,desc,branch,extra) -def load_cache(filename): +def mangle_key(key): + return key + +def load_cache(filename,get_key=mangle_key): cache={} if not os.path.exists(filename): return cache @@ -70,7 +73,7 @@ def load_cache(filename): sys.stderr.write('Invalid file format in [%s], line %d\n' % (filename,l)) continue # put key:value in cache, key without ^: - cache[fields[0][1:]]=fields[1].split('\n')[0] + cache[get_key(fields[0][1:])]=fields[1].split('\n')[0] f.close() return cache -- 2.11.4.GIT