mrcrowl / vscode-hg

Integrated Mercurial source control for Visual Studio Code
MIT License
71 stars 37 forks source link

Support subrepositories #36

Open opus-2 opened 6 years ago

opus-2 commented 6 years ago

Are there any plans for this?

kchang718 commented 3 years ago

I am in need of this feature. I'm happy to take a crack if anyone can help me get pointed in the right direction. I have 0 TypeScript skills, but have used mercurial for a long time.

incidentist commented 3 years ago

@kchangtetrion A PR for this feature would be very welcome! TypeScript is not too difficult if you've used typed languages before. I don't have bandwidth currently to start on this, so if you started on it that might be the fastest way to make it happen, especially if you have a good working knowledge of subrepos.

In general, this extension tries to mirror the structure of the vscode git extension. VSCode has an API for extensions that provide access to a version-control system, so that is also useful documentation: https://code.visualstudio.com/api/extension-guides/scm-provider

hg.ts corresponds to git.ts and is the TypeScript interface to the hg executable. There are a couple of commands in the git version that mention submodules, so you'll probably end up writing equivalent subrepo commands in hg.ts. In particular, you'll want a getSubrepos() function, which should open up .hgsub and return objects that encapsulate data about the subrepos.

From there, call getSubrepos() in Repository.updateModelState() and store the results in a property on the Repository object. Then, you'd look at the Model object, which keeps track of all the repos in a project, including subrepos. Model.open() is called when the extension is activated, so that's where the setup happens. Look at how the git version of that function works with submodules.

The magic happens in Model.eventuallyScanPossibleHgRepositories, which operates on a list of paths. The subrepo list should be added to that list of paths. Can use this function, which is cribbed from the git version:

private eventuallyScanPossibleHgRepository(path: string) {
    this.possibleHgRepositoryPaths.add(path);
    this.eventuallyScanPossibleHgRepositories();
}
kchang718 commented 3 years ago

ok, when time allows, I'll go through the examples and see if I can make some sense of it.