summaryrefslogtreecommitdiff
path: root/hg2git.py
diff options
context:
space:
mode:
authorRocco Rutte <pdmef@gmx.net>2007-03-08 11:21:21 +0000
committerRocco Rutte <pdmef@gmx.net>2007-03-08 11:21:21 +0000
commit85f0d9c88103d6ffa27549dd46e3341438e6257a (patch)
treed267f9a5aed99e17bf423bc4c090c205cb59c6c0 /hg2git.py
parent61bb1cb70794df21b626159ff164839d7915907e (diff)
downloadhg-fast-export-85f0d9c88103d6ffa27549dd46e3341438e6257a.tar.gz
hg2git.py: Refactor main code into hg2git() function
Now this can even be used as a module from other python scripts by simply calling the hg2git() function. Except some config values nobody really ever wants to change, it's even save to run several hg2git() functions in parallel as no global vars or the like are used by intention (but it makes the code uglier). Signed-off-by: Rocco Rutte <pdmef@gmx.net>
Diffstat (limited to 'hg2git.py')
-rw-r--r--hg2git.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/hg2git.py b/hg2git.py
index ee95dfb..1683cb5 100644
--- a/hg2git.py
+++ b/hg2git.py
@@ -238,9 +238,7 @@ def verify_heads(ui,repo,cache):
'\n%s (repo) != %s (cache)\n' % (b,sha1,c))
return True
-if __name__=='__main__':
- if len(sys.argv)!=6: sys.exit(usage(1))
- repourl,m,marksfile,headsfile,tipfile=sys.argv[1:]
+def hg2git(repourl,m,marksfile,headsfile,tipfile):
_max=int(m)
marks_cache=load_cache(marksfile)
@@ -250,7 +248,7 @@ if __name__=='__main__':
ui,repo=setup_repo(repourl)
if not verify_heads(ui,repo,heads_cache):
- sys.exit(1)
+ return 1
tip=repo.changelog.count()
@@ -271,3 +269,10 @@ if __name__=='__main__':
state_cache['tip']=max
state_cache['repo']=repourl
save_cache(tipfile,state_cache)
+
+ return 0
+
+if __name__=='__main__':
+ if len(sys.argv)!=6: sys.exit(usage(1))
+ repourl,m,marksfile,headsfile,tipfile=sys.argv[1:]
+ sys.exit(hg2git(repourl,m,marksfile,headsfile,tipfile))