vscode-hg icon indicating copy to clipboard operation
vscode-hg copied to clipboard

Support subrepositories

Open opus-2 opened this issue 8 years ago • 3 comments

Are there any plans for this?

opus-2 avatar Dec 10 '17 01:12 opus-2

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.

kchang718 avatar Dec 25 '20 15:12 kchang718

@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();
}

incidentist avatar Dec 25 '20 21:12 incidentist

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

kchang718 avatar May 03 '21 15:05 kchang718