Subtree clone in 2016

Shawn Hoover shawn.hoover at gmail.com
Wed Apr 20 18:14:07 UTC 2016


On Wed, Apr 20, 2016 at 9:11 AM, Augie Fackler <raf at durin42.com> wrote:

>
> > On Apr 19, 2016, at 23:33, anatoly techtonik <techtonik at gmail.com>
> wrote:
> >
> > On Mon, Apr 18, 2016 at 5:36 PM, Augie Fackler <raf at durin42.com> wrote:
> >>
> >>> On Apr 15, 2016, at 16:09, anatoly techtonik <techtonik at gmail.com>
> wrote:
> >>>
> >>> Hi,
> >>>
> >>> I wonder if Mercurial got some modern way to
> >>> get a clone of subtree since 2012?
> >>> https://www.mercurial-scm.org/wiki/PartialClone
> >>
> >> This is in progress at https://bitbucket.org/Google/narrowhg, but it's
> probably not ready enough that you should count on it being reliable.
> >
> > Nice. And what is the criteria to know when it is ready?
>
> Probably when we cut a release of it.
>
> >
> >>>
> >>> I need to make a Python module from Roundup
> >>> repository into a separate project, so I need to
> >>> clone its subtree and push it somewhere else.
> >>
> >> Ah, but you want to produce a new history of part of the repo and push
> it as its own repo somewhere? Then convert is your best bet, because you're
> making a new repo, not merely working locally on a partial checkout.
> >
> > The workflow I want to achieve is that module is developed in Roundup
> > repository, which is in Mercurial, in subtree roundup/web. But I also
> > want to publish it independently and put on GitHub for more pull
> > requests.
>
> Ah, then narrowhg doesn't help you anyway.
>
> > Putting on GitHub means it needs separate README.md and
> > UNLICENSE file to be put in the root. I also need to be able to sync
> > PRs back to Mercurial without those new README.md and UNLICENSE.
> > Ideally all that mapping should be somehow available from repository,
> > so that I continue working on the project from another machine without
> > complicated setup.
>
> This is pretty complicated. I don't know of any tools that'll do what you
> want (you want a bidirectionally synced bridge to take a subdirectory of an
> hg repo and make that the same as a git repo, robustly.)
>

I've been using a script [1] for several months to bidirectionally sync a
monorepo subdirectory with a separate hg repo. The code is short, but it is
definitely complicated and I would not call it robust. That said, it has
been working out with careful use. The filemaps and shamaps must be tracked
in the monorepo, and you have to commit the shamaps each time you run the
script. A merge commit is often needed after the shamaps commit, though I
wonder if that could be safely rebased.

Per the use case at hand, theoretically it would work for git the same way.
The filemap could be used to map or ignore the README.md and UNLICENSE, by
the way.

[1] - https://gist.github.com/shoover/ad1601d342208a75f703
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial/attachments/20160420/751deecd/attachment-0002.html>


More information about the Mercurial mailing list