diff options
author | Rocco Rutte <pdmef@gmx.net> | 2007-10-26 17:11:57 +0200 |
---|---|---|
committer | Rocco Rutte <pdmef@gmx.net> | 2007-10-26 17:11:57 +0200 |
commit | bc98d2c088b6e854eb59485d1109f85c1076a961 (patch) | |
tree | 9a706887dce54010b870f5262264cf509acd3bf8 | |
parent | b200f9f8b396348d7ad208f00d6cd73c1da79907 (diff) | |
download | hg-fast-export-bc98d2c088b6e854eb59485d1109f85c1076a961.tar.gz |
hg-fast-export.py: Cache possibly sanitized branch names
...instead of doing it for every single commit.
Signed-off-by: Rocco Rutte <pdmef@gmx.net>
-rwxr-xr-x | hg-fast-export.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/hg-fast-export.py b/hg-fast-export.py index 97dba5f..e3af8a6 100755 --- a/hg-fast-export.py +++ b/hg-fast-export.py @@ -152,11 +152,18 @@ def sanitize_name(name,what="branch"): sys.stderr.write('Warning: sanitized %s [%s] to [%s]\n' % (what,name,n)) return n -def export_commit(ui,repo,revision,marks,heads,last,max,count,authors,sob): +def export_commit(ui,repo,revision,marks,heads,last,max,count,authors,sob,brmap): + def get_branchname(name): + if brmap.has_key(name): + return brmap[name] + n=sanitize_name(name) + brmap[name]=n + return n + (revnode,_,user,(time,timezone),files,desc,branch,_)=get_changeset(ui,repo,revision,authors) parents=repo.changelog.parentrevs(revision) - branch=sanitize_name(branch) + branch=get_branchname(branch) wr('commit refs/heads/%s' % branch) wr('mark :%d' % (revision+1)) @@ -332,8 +339,9 @@ def hg2git(repourl,m,marksfile,headsfile,tipfile,authors={},sob=False,force=Fals c=0 last={} + brmap={} for rev in range(min,max): - c=export_commit(ui,repo,rev,marks_cache,heads_cache,last,max,c,authors,sob) + c=export_commit(ui,repo,rev,marks_cache,heads_cache,last,max,c,authors,sob,brmap) c=export_tags(ui,repo,marks_cache,min,max,c,authors) |