[PATCH 02 of 10] Pass cvsps output through file instead of stdin
Edouard Gomez
ed.gomez at free.fr
Sun Dec 17 15:31:48 UTC 2006
# HG changeset patch
# User Edouard Gomez <ed.gomez at free.fr>
# Date 1166365118 -3600
# Node ID 477b544463c609d728cb279ed6763d774877b3a9
# Parent 50cf5a2bec63f22693c37ca4e6120919230e98f6
Pass cvsps output through file instead of stdin
Using stdin inconditionnaly makes it hard to plug pdb when debugging. So
make cvsps input possible from file or stdin (default)
diff -r 50cf5a2bec63 -r 477b544463c6 hg-cvs-import
--- a/hg-cvs-import Sun Dec 17 15:18:36 2006 +0100
+++ b/hg-cvs-import Sun Dec 17 15:18:38 2006 +0100
@@ -22,7 +22,7 @@ for name, value in optlist:
if not cvsroot or not module or not hgpath:
sys.stderr.write(
-"""Usage: hg-cvs-import <-d path> <-M modulename> <-C path> [OPTIONS]
+"""Usage: hg-cvs-import <-d path> <-M modulename> <-C path> [OPTIONS] [cvsps file]
Mandatory options:
-C path: path to an initialized hg repository where patchsets will be pushed
@@ -30,6 +30,7 @@ Mandatory options:
-M modulename: name of the CVS module to convert
Optional options:
+ cvsps file: filename of the cvsps file. Can be '-' for stdin (default: stdin)
-m mapfile: file where (cvs,hg) node couples are saved (default: map)
Inline manual
@@ -257,14 +258,23 @@ def addrev(branch, tag, r, user, date, l
addtag(branch, hg.hex(n))
addtag(tag, hg.hex(n))
-cvspipe = sys.stdin
+if args is None or len(args) == 0:
+ args = ['-']
+
+cvspipe = None
+if args[0] == '-':
+ cvspipe = sys.stdin
+else:
+ try:
+ cvspipe = open(args[0], 'r')
+ except IOError:
+ sys.stderr.write('Could not read %s\n' % args[0])
+ sys.exit(1)
+
time.tzset()
lastpatch = None
-while True:
- try:
- l = raw_input()
- except EOFError:
- break
+for l in cvspipe:
+ l = l.rstrip()
if l.startswith('PatchSet') and (state == 'dashes' or patchset == None):
if patchset != None:
addrev(branch, tag, patchset, user, date, log, files)
More information about the Mercurial-devel
mailing list