hg-to-git: add --verbose option
This patch adds an option to make hg-to-git quiet by default. Note: it only suppresses those messages that would be printed when everything was up-to-date. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Acked-by: Stelian Pop <stelian@popies.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin committed
May 26, 2008 at 14:20 UTC
37a12dda24f7ab250869db7eb00157f78d40c724
1 file changed
+13
-5
contrib/hg-to-git/hg-to-git.py
+13
-5
@@ -46,6 +46,7 @@ options:
46
for incrementals
47
-n, --nrepack=INT: number of changesets that will trigger
48
a repack (default=0, -1 to deactivate)
49
+ -v, --verbose: be verbose
50
51
required:
52
hgprj: name of the HG project to import (directory)
@@ -75,15 +76,18 @@ def getgitenv(user, date):
76
77
state = ''
78
opt_nrepack = 0
79
+verbose = False
80
81
try:
80
- opts, args = getopt.getopt(sys.argv[1:], 's:t:n:', ['gitstate=', 'tempdir=', 'nrepack='])
82
+ opts, args = getopt.getopt(sys.argv[1:], 's:t:n:v', ['gitstate=', 'tempdir=', 'nrepack=', 'verbose'])
83
for o, a in opts:
84
if o in ('-s', '--gitstate'):
85
state = a
86
state = os.path.abspath(state)
87
if o in ('-n', '--nrepack'):
88
opt_nrepack = int(a)
89
+ if o in ('-v', '--verbose'):
90
+ verbose = True
91
if len(args) != 1:
92
raise('params')
93
except:
@@ -95,17 +99,20 @@ os.chdir(hgprj)
99
100
if state:
101
if os.path.exists(state):
98
- print 'State does exist, reading'
102
+ if verbose:
103
+ print 'State does exist, reading'
104
f = open(state, 'r')
105
hgvers = pickle.load(f)
106
else:
107
print 'State does not exist, first run'
108
109
tip = os.popen('hg tip --template "{rev}"').read()
105
-print 'tip is', tip
110
+if verbose:
111
+ print 'tip is', tip
112
113
# Calculate the branches
108
-print 'analysing the branches...'
114
+if verbose:
115
+ print 'analysing the branches...'
116
hgchildren["0"] = ()
117
hgparents["0"] = (None, None)
118
hgbranch["0"] = "master"
@@ -232,7 +239,8 @@ if hgnewcsets >= opt_nrepack and opt_nrepack != -1:
239
240
# write the state for incrementals
241
if state:
235
- print 'Writing state'
242
+ if verbose:
243
+ print 'Writing state'
244
f = open(state, 'w')
245
pickle.dump(hgvers, f)
246