# [PATCH] hg-to-git: add --verbose option

9 messages from 2008-05-26 to 2008-05-26. Participants: Johannes Schindelin, Johan Herland, Sverre Rabbelier, Stelian Pop, Junio C Hamano, David Symonds.
Thread: https://gitlist.dev/t/13670

## Johannes Schindelin, 2008-05-26 12:46

Subject: [PATCH] hg-to-git: add --verbose option
Message-ID: <alpine.DEB.1.00.0805261344420.30431@racer>
URL: https://gitlist.dev/e/alpine.DEB.1.00.0805261344420.30431%40racer

```

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>
---

	Yeah, I know, a Python hater codes in Python.  Well, somebody told
	me I had to code in it until I do not hate it anymore.

 contrib/hg-to-git/hg-to-git.py |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/contrib/hg-to-git/hg-to-git.py b/contrib/hg-to-git/hg-to-git.py
index d72ffbb..daad399 100755
--- a/contrib/hg-to-git/hg-to-git.py
+++ b/contrib/hg-to-git/hg-to-git.py
@@ -46,6 +46,7 @@ options:
                          for incrementals
     -n, --nrepack=INT:   number of changesets that will trigger
                          a repack (default=0, -1 to deactivate)
+    -v, --verbose:       be verbose
 
 required:
     hgprj:  name of the HG project to import (directory)
@@ -75,15 +76,18 @@ def getgitenv(user, date):
 
 state = ''
 opt_nrepack = 0
+verbose = ''
 
 try:
-    opts, args = getopt.getopt(sys.argv[1:], 's:t:n:', ['gitstate=', 'tempdir=', 'nrepack='])
+    opts, args = getopt.getopt(sys.argv[1:], 's:t:n:v', ['gitstate=', 'tempdir=', 'nrepack=', 'verbose'])
     for o, a in opts:
         if o in ('-s', '--gitstate'):
             state = a
             state = os.path.abspath(state)
         if o in ('-n', '--nrepack'):
             opt_nrepack = int(a)
+        if o in ('-v', '--verbose'):
+            verbose = true
     if len(args) != 1:
         raise('params')
 except:
@@ -95,17 +99,20 @@ os.chdir(hgprj)
 
 if state:
     if os.path.exists(state):
-        print 'State does exist, reading'
+        if verbose:
+            print 'State does exist, reading'
         f = open(state, 'r')
         hgvers = pickle.load(f)
     else:
         print 'State does not exist, first run'
 
 tip = os.popen('hg tip --template "{rev}"').read()
-print 'tip is', tip
+if verbose:
+    print 'tip is', tip
 
 # Calculate the branches
-print 'analysing the branches...'
+if verbose:
+    print 'analysing the branches...'
 hgchildren["0"] = ()
 hgparents["0"] = (None, None)
 hgbranch["0"] = "master"
@@ -232,7 +239,8 @@ if hgnewcsets >= opt_nrepack and opt_nrepack != -1:
 
 # write the state for incrementals
 if state:
-    print 'Writing state'
+    if verbose:
+        print 'Writing state'
     f = open(state, 'w')
     pickle.dump(hgvers, f)
 
-- 
1.5.5.GIT

```

## Johan Herland, 2008-05-26 13:09

Subject: Re: [PATCH] hg-to-git: add --verbose option
Message-ID: <200805261509.49841.johan@herland.net>
URL: https://gitlist.dev/e/200805261509.49841.johan%40herland.net
In-Reply-To: <alpine.DEB.1.00.0805261344420.30431@racer>

```
On Monday 26 May 2008, Johannes Schindelin wrote:
> 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>
> ---
>
> 	Yeah, I know, a Python hater codes in Python.  Well, somebody told
> 	me I had to code in it until I do not hate it anymore.

Looks ok to me. :)

>  contrib/hg-to-git/hg-to-git.py |   18 +++++++++++++-----
>  1 files changed, 13 insertions(+), 5 deletions(-)
>
> diff --git a/contrib/hg-to-git/hg-to-git.py
> b/contrib/hg-to-git/hg-to-git.py index d72ffbb..daad399 100755
> --- a/contrib/hg-to-git/hg-to-git.py
> +++ b/contrib/hg-to-git/hg-to-git.py
> @@ -46,6 +46,7 @@ options:
>                           for incrementals
>      -n, --nrepack=INT:   number of changesets that will trigger
>                           a repack (default=0, -1 to deactivate)
> +    -v, --verbose:       be verbose
>
>  required:
>      hgprj:  name of the HG project to import (directory)
> @@ -75,15 +76,18 @@ def getgitenv(user, date):
>
>  state = ''
>  opt_nrepack = 0
> +verbose = ''

Maybe this should be
	verbose = false
since it indicates your intent to exclusively use this variable as a
boolean.

The rest is ok, AFAICS.


Have fun! :)

...Johan


-- 
Johan Herland, <johan@herland.net>
www.herland.net

```

## Johannes Schindelin, 2008-05-26 13:14

Subject: Re: [PATCH] hg-to-git: add --verbose option
Message-ID: <alpine.DEB.1.00.0805261414140.30431@racer>
URL: https://gitlist.dev/e/alpine.DEB.1.00.0805261414140.30431%40racer
In-Reply-To: <200805261509.49841.johan@herland.net>

```
Hi,

On Mon, 26 May 2008, Johan Herland wrote:

> On Monday 26 May 2008, Johannes Schindelin wrote:
>
> > @@ -75,15 +76,18 @@ def getgitenv(user, date):
> >
> >  state = ''
> >  opt_nrepack = 0
> > +verbose = ''
> 
> Maybe this should be
> 	verbose = false
> since it indicates your intent to exclusively use this variable as a
> boolean.

Now, that is not even funny, as that was my initial version, and Python 
complained about not knowing "false".

Ciao,
Dscho

```

## Johannes Schindelin, 2008-05-26 13:20

Subject: [PATCH v2] hg-to-git: add --verbose option
Message-ID: <alpine.DEB.1.00.0805261419440.30431@racer>
URL: https://gitlist.dev/e/alpine.DEB.1.00.0805261419440.30431%40racer
In-Reply-To: <200805261509.49841.johan@herland.net>

```

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>
---

	On Mon, 26 May 2008, Johan Herland wrote:

	> 	verbose = false

	Pieter on IRC just pointed out that it should be capitalized.

 contrib/hg-to-git/hg-to-git.py |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/contrib/hg-to-git/hg-to-git.py b/contrib/hg-to-git/hg-to-git.py
index d72ffbb..f68ef72 100755
--- a/contrib/hg-to-git/hg-to-git.py
+++ b/contrib/hg-to-git/hg-to-git.py
@@ -46,6 +46,7 @@ options:
                          for incrementals
     -n, --nrepack=INT:   number of changesets that will trigger
                          a repack (default=0, -1 to deactivate)
+    -v, --verbose:       be verbose
 
 required:
     hgprj:  name of the HG project to import (directory)
@@ -75,15 +76,18 @@ def getgitenv(user, date):
 
 state = ''
 opt_nrepack = 0
+verbose = False
 
 try:
-    opts, args = getopt.getopt(sys.argv[1:], 's:t:n:', ['gitstate=', 'tempdir=', 'nrepack='])
+    opts, args = getopt.getopt(sys.argv[1:], 's:t:n:v', ['gitstate=', 'tempdir=', 'nrepack=', 'verbose'])
     for o, a in opts:
         if o in ('-s', '--gitstate'):
             state = a
             state = os.path.abspath(state)
         if o in ('-n', '--nrepack'):
             opt_nrepack = int(a)
+        if o in ('-v', '--verbose'):
+            verbose = True
     if len(args) != 1:
         raise('params')
 except:
@@ -95,17 +99,20 @@ os.chdir(hgprj)
 
 if state:
     if os.path.exists(state):
-        print 'State does exist, reading'
+        if verbose:
+            print 'State does exist, reading'
         f = open(state, 'r')
         hgvers = pickle.load(f)
     else:
         print 'State does not exist, first run'
 
 tip = os.popen('hg tip --template "{rev}"').read()
-print 'tip is', tip
+if verbose:
+    print 'tip is', tip
 
 # Calculate the branches
-print 'analysing the branches...'
+if verbose:
+    print 'analysing the branches...'
 hgchildren["0"] = ()
 hgparents["0"] = (None, None)
 hgbranch["0"] = "master"
@@ -232,7 +239,8 @@ if hgnewcsets >= opt_nrepack and opt_nrepack != -1:
 
 # write the state for incrementals
 if state:
-    print 'Writing state'
+    if verbose:
+        print 'Writing state'
     f = open(state, 'w')
     pickle.dump(hgvers, f)
 
-- 
1.5.5.GIT

```

## Sverre Rabbelier, 2008-05-26 13:28

Subject: Re: [PATCH] hg-to-git: add --verbose option
Message-ID: <bd6139dc0805260628l1b073f52i1f33bd0c707a4329@mail.gmail.com>
URL: https://gitlist.dev/e/bd6139dc0805260628l1b073f52i1f33bd0c707a4329%40mail.gmail.com
In-Reply-To: <alpine.DEB.1.00.0805261414140.30431@racer>

```
On Mon, May 26, 2008 at 3:14 PM, Johannes Schindelin
<Johannes.Schindelin@gmx.de> wrote:
> Now, that is not even funny, as that was my initial version, and Python
> complained about not knowing "false".

That is because in python the keyword is "False" (note the capital 'F').

-- 
Cheers,

Sverre Rabbelier

```

## Stelian Pop, 2008-05-26 14:33

Subject: Re: [PATCH v2] hg-to-git: add --verbose option
Message-ID: <1211812380.12728.7.camel@galileo>
URL: https://gitlist.dev/e/1211812380.12728.7.camel%40galileo
In-Reply-To: <alpine.DEB.1.00.0805261419440.30431@racer>

```
Le lundi 26 mai 2008 à 14:20 +0100, Johannes Schindelin a écrit :
> 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>

Thanks, 
-- 
Stelian Pop <stelian@popies.net>

```

## Junio C Hamano, 2008-05-26 17:19

Subject: Re: [PATCH] hg-to-git: add --verbose option
Message-ID: <7vlk1xc7aa.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vlk1xc7aa.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <bd6139dc0805260628l1b073f52i1f33bd0c707a4329@mail.gmail.com>

```
"Sverre Rabbelier" <alturin@gmail.com> writes:

> On Mon, May 26, 2008 at 3:14 PM, Johannes Schindelin
> <Johannes.Schindelin@gmx.de> wrote:
>> Now, that is not even funny, as that was my initial version, and Python
>> complained about not knowing "false".
>
> That is because in python the keyword is "False" (note the capital 'F').

I too write True/False in my recent Python code, but I vaguely recall they
were relatively new to the language.  I think it was 2.3 which is probably
5 years old by now, so if that is the case we probably are safe (and they
are used in p4import anyway).

I think I spotted a bug in Python documentation, by the way ;-)

http://docs.python.org/ref/ref.html does not even list "True" and "False"
in its section 2.4 (Literals) yet, and that document is for version 2.5.2.

```

## David Symonds, 2008-05-26 21:29

Subject: Re: [PATCH] hg-to-git: add --verbose option
Message-ID: <ee77f5c20805261429h14b1ce66tf9585132279c4f8e@mail.gmail.com>
URL: https://gitlist.dev/e/ee77f5c20805261429h14b1ce66tf9585132279c4f8e%40mail.gmail.com
In-Reply-To: <7vlk1xc7aa.fsf@gitster.siamese.dyndns.org>

```
On Tue, May 27, 2008 at 3:19 AM, Junio C Hamano <gitster@pobox.com> wrote:

> I think I spotted a bug in Python documentation, by the way ;-)
>
> http://docs.python.org/ref/ref.html does not even list "True" and "False"
> in its section 2.4 (Literals) yet, and that document is for version 2.5.2.

That's because they aren't literals. They are, in fact, objects, and
redefinable objects at that.

Try:

True=False
print True



Dave.

```

## Johannes Schindelin, 2008-05-26 21:47

Subject: Re: [PATCH] hg-to-git: add --verbose option
Message-ID: <alpine.DEB.1.00.0805262247020.30431@racer>
URL: https://gitlist.dev/e/alpine.DEB.1.00.0805262247020.30431%40racer
In-Reply-To: <ee77f5c20805261429h14b1ce66tf9585132279c4f8e@mail.gmail.com>

```
Hi,

On Tue, 27 May 2008, David Symonds wrote:

> On Tue, May 27, 2008 at 3:19 AM, Junio C Hamano <gitster@pobox.com> wrote:
> 
> > I think I spotted a bug in Python documentation, by the way ;-)
> >
> > http://docs.python.org/ref/ref.html does not even list "True" and 
> > "False" in its section 2.4 (Literals) yet, and that document is for 
> > version 2.5.2.
> 
> That's because they aren't literals. They are, in fact, objects, and 
> redefinable objects at that.
> 
> Try:
> 
> True=False
> print True

Hey, I said that I had to code in Python until I do not hate it anymore!

You just made that task harder.

Thanks,
Dscho

```
