@matheusbsbs / matheus-bagliano / commits / 7c0d741a3e
Fork 0

hg-to-git speedup through selectable repack intervals

Signed-off-by: Lars Hjemli <hjemli@gmail.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Michael Gebetsroither committed Oct 6, 2007 at 23:16 UTC 7c0d741a3e8db662419cc841e3068b2a8880a109
1 file changed +11 -3
contrib/hg-to-git/hg-to-git.py
+11 -3
@@ -29,6 +29,8 @@ hgvers = {}
29 hgchildren = {}
30 # Current branch for each hg revision
31 hgbranch = {}
32 +# Number of new changesets converted from hg
33 +hgnewcsets = 0
34
35 #------------------------------------------------------------------------------
36
@@ -40,6 +42,8 @@ def usage():
42 options:
43 -s, --gitstate=FILE: name of the state to be saved/read
44 for incrementals
45 + -n, --nrepack=INT: number of changesets that will trigger
46 + a repack (default=0, -1 to deactivate)
47
48 required:
49 hgprj: name of the HG project to import (directory)
@@ -68,14 +72,16 @@ def getgitenv(user, date):
72 #------------------------------------------------------------------------------
73
74 state = ''
75 +opt_nrepack = 0
76
77 try:
73 - opts, args = getopt.getopt(sys.argv[1:], 's:t:', ['gitstate=', 'tempdir='])
78 + opts, args = getopt.getopt(sys.argv[1:], 's:t:n:', ['gitstate=', 'tempdir=', 'nrepack='])
79 for o, a in opts:
80 if o in ('-s', '--gitstate'):
81 state = a
82 state = os.path.abspath(state)
78 -
83 + if o in ('-n', '--nrepack'):
84 + opt_nrepack = int(a)
85 if len(args) != 1:
86 raise('params')
87 except:
@@ -138,6 +144,7 @@ for cset in range(int(tip) + 1):
144 # incremental, already seen
145 if hgvers.has_key(str(cset)):
146 continue
147 + hgnewcsets += 1
148
149 # get info
150 prnts = os.popen('hg log -r %d | grep ^parent: | cut -f 2 -d :' % cset).readlines()
@@ -222,7 +229,8 @@ for cset in range(int(tip) + 1):
229 print 'record', cset, '->', vvv
230 hgvers[str(cset)] = vvv
231
225 -os.system('git-repack -a -d')
232 +if hgnewcsets >= opt_nrepack and opt_nrepack != -1:
233 + os.system('git-repack -a -d')
234
235 # write the state for incrementals
236 if state: