"hg import" can't handle multiple changesets per file

Josh Triplett josht at us.ibm.com
Thu Aug 25 15:00:30 CDT 2005


On Wed, 2005-08-24 at 20:02 -0700, TK Soh wrote:
> --- Matt Mackall <mpm at selenic.com> wrote:
> > On Wed, Aug 24, 2005 at 07:09:21PM -0700, Josh Triplett wrote:
> > > [Please CC me on replies, as I am not subscribed to the list.]
> > > 
> > > If you do "hg export 1 2 3 > file.patch", file.patch will contain a set
> > > of hg changesets in exported form, including the hg header comment
> > > before each.  However, "hg import file.patch" will ignore all but the
> > > first header, and treat the entire file as a representation of that one
> > > changeset.  In my case, this caused three large changesets to be
> > > committed as one changeset, amusingly titled "formatting fixes". :)
> > 
> > There isn't really a clean way to fix this. But you probably wanted:
> > 
> > hg export -o "file-%n.patch" 1 2 3
> > hg import file-*.patch
> 
> Or in case the changesets have been exported all to one file. You can use the
> csplit utility to split the changesets into files (xx*), then pass the files to
> import.
> 
>    $ csplit patches '/^# HG changeset patch/' "{*}"
>    $ cd repo
>    $ hg import ../xx*

I do understand that it is quite possible to split the changesets into
separate files and then import them individually.  I'm suggesting that
"hg import" should just Do The Right Thing automatically, by looking for
the '#'-prefixed hg header at the beginning of a new changeset, and
treating that as a new changeset.

- Josh Triplett




More information about the Mercurial mailing list