[PATCH] csplit support in hg import
TK Soh
teekaysoh at yahoo.com
Wed Aug 31 10:45:37 CDT 2005
--- TK Soh <teekaysoh at yahoo.com> wrote:
> --- Bryan O'Sullivan <bos at serpentine.com> wrote:
> > On Tue, 2005-08-30 at 19:41 -0700, TK Soh wrote:
> >
> > > + def csplit(pf):
> >
> > Please give this a descriptive name, such as perhaps splitpatch.
> >
> > > + flist = []
> > > + nodes = []
> > > + f = None
> > > + node = None
> > > + for line in file(pf):
> > > + if line.startswith("# HG changeset patch"):
> > > + if f:
> > > + f.close()
> > > + flist.append(tfile)
> > > + nodes.append(node)
> >
> > Please get rid of tfile, and use f.name instead.
> >
> > > + tfile = tempfile.mktemp()
> > > + f = open(tfile, 'w')
> > > + f.write(line)
> >
> > tempfile.mktemp is deprecated because it is not secure.
> >
> > > + elif f:
> > > + if line.startswith("# Node ID "):
> > > + node = line[10:]
> > > + node = node.rstrip()
> > > + f.write(line)
> >
> > I don't see much value in saving this information and printing it. In
> > particular, patches generated with mq don't contain this information.
> >
> > If you want to print something more useful, just ui.status the number of
> > Mercurial patches that a patch file contains, if that number is > 1.
>
> I made a few changes including use of mkstemp(), but I am not sure what you
> really mean with f.name. See if this patch is better.
Oops, forgot about help and manpage.
# HG changeset patch
# User TK Soh <teekaysoh at yahoo.com>
# Node ID be9574baf3c5ff539bfbd2580d53235ee27660f7
# Parent c80f99f079ef925c9c516b593bd9836648b5a9b7
Fixed help and manpage for import command
diff -r c80f99f079ef -r be9574baf3c5 doc/hg.1.txt
--- a/doc/hg.1.txt Wed Aug 31 15:33:11 2005
+++ b/doc/hg.1.txt Wed Aug 31 15:44:51 2005
@@ -223,10 +223,11 @@
aliases: id
-import [-p <n> -b <base> -f] <patches>::
+import [-c -p <n> -b <base> -f] <patches>::
Import a list of patches and commit them individually.
options:
+ -c, --csplit split changsets in patch files
-p, --strip <n> directory strip option for patch. This has the same
meaning as the corresponding patch option
-b <path> base directory to read patches from
diff -r c80f99f079ef -r be9574baf3c5 mercurial/commands.py
--- a/mercurial/commands.py Wed Aug 31 15:33:11 2005
+++ b/mercurial/commands.py Wed Aug 31 15:44:51 2005
@@ -1616,7 +1616,7 @@
('c', 'csplit', None, 'split changsets in patch files'),
('f', 'force', None, 'skip check for outstanding changes'),
('b', 'base', "", 'base path')],
- "hg import [-f] [-p NUM] [-b BASE] PATCH..."),
+ "hg import [-c] [-f] [-p NUM] [-b BASE] PATCH..."),
"incoming|in": (incoming, [], 'hg incoming [SOURCE]'),
"^init": (init, [], 'hg init [DEST]'),
"locate":
__________________________________
Yahoo! Mail
Stay connected, organized, and protected. Take the tour:
http://tour.mail.yahoo.com/mailtour.html
More information about the Mercurial
mailing list