Xlinks
Use xlinks to connect repositories in Unity Version Control.
Read time 6 minutesLast updated 21 days ago
Often, you have separate repositories for different projects. To share existing components from a different project, you can use Xlinks to mount the component in your project. An Xlink is a directory entry in your repository that points to another directory in a different repository. The Xlink contains information on the specific version of the directory that it points to. You define an Xlink with these three following arguments:
- The directory entry to create in your current repository. This is a directory that you use.
- The target repository.
- The directory to mount in the target repository.
- The version of the directory to mount. This is either a changeset specification or a label specification.
Types of Xlink
Read only Xlinks (Xlink
)
A read only Xlink is ideal if you use an existing component but don’t influence the development of the component. This means you can use the linked component in your project, but can’t change it.
XlinkWritable Xlinks (wXlink
)
With a writable Xlink, you can make changes inside the Xlinked repository.
wXlinkPartial Xlinks
Partial Xlinks are Xlinks that point to a specific relative path in another repository instead of the default root of the repository. Partial Xlinks are read only because writable partial Xlinks overcomplicate merges. You can create partial Xlinks only in the command line. For example, the following command creates a read only partial Xlink that mounts the path/includes/openglFor more information on how to create Xlinks in the command line, use the commandcm xlink opengl\include /includes/opengl 1627@includes@localhost:8087
cm xlink –helpComplex Xlink structures
Since Xlinks can point to repositories that already contain Xlinks, component mounting can address complex development scenarios.Versioning
You can specify, for example, that version 1.1 of project X uses version 2.1 of library Y. When the new version 1.2 of project X is labeled, you can update the code of the project to use a new version 2.2 of library Y. Since Xlinks are versioned, the Xlink in the original project still points to the original version of the library, so you can rebuild that configuration without issues.Xlink expansion rules
Xlink expansion rules define how branches are created on your Xlinked repositories, and how the branches in the parent repository relate to the branches in the Xlinked repository. UVCS automatically creates branches in linked repositories when you make changes.Xlinks in top level branches
In the following example, you have two repositories,quakezlibquakezlibtask001quaketask001zlibSource branch | Destination branch | Is defined by user |
|---|---|---|
| | |
| | |
Xlinks in a second level branch
In the following example, you create a wXlink in a task branch,main/xlink-creationmain/xlink-creationmain/xlink-creation@quake -> main@zlibmain@quake -> main@zlibmain/xlink-creationmain/xlink-creationzlibSource branch | Destination branch | Defined by user? |
|---|---|---|
| | |
| | |
Asymmetric Xlink hierarchies
Symmetric links follow the same branch names, while asymmetric links connect different branch names. In the previous two examples, the wXlinks are symmetric:mainmainmain/task001main/task001main@quakemain/fix@zlibExample Xlink configuration
In the following xlink configuration example, a video game company has an engine that two different game studios use in different locations. You can use Xlinks to optimize this workflow and share the engine code with both studios and still continue individual development:
A diagram that shows how the Xlinks work between different studios.
Example Xlink configuration
The Xlink for each game repository points to the game specific branch of the engine repository. Since both games are connected to the same engine repository, you need to set the branch auto expansion rules.- Xlink branch expansion rules on the repository:
GameA- source branch:
/main - destination branch:
/main/GameA
- source branch:
- Xlink branch expansion rules on the repository:
GameB- source branch:
/main - destination branch:
/main/GameB
- source branch:
- Writable: you need to be able to make changes in the engine repository.
- Relative server: you work on a replicated local version of the repository and don’t need access to the remote server.
Merge Xlinks
When you merge a branch, the merge also affects the auto expanded branches in the wXlinked repositories. You do the merge operation on the top level repository (where the workspace points to) and UVCS also considers the changes in those linked repositories. You only need to merge the top level repository; UVCS automatically merges any changes in linked repositories and updates the wXlink. As in any merge, you might need to manually resolve some merge conflicts in the Xlinked files. This process keeps your Xlinked repositories in sync and ensures that you don't need to manually merge changes in the linked repositories separately.Example merge with Xlinks
In the following example, you have a main repository calledProjectXMyLibraryProjectXMyLibrarytask002task003events.h- Merges the top level repository: UVCS first merges the changes inside the repository.
ProjectX - Checks the linked repositories: UVCS looks for the wXlinks in . Because you made changes to
ProjectXin both branches, it sees thatevents.handtask002point to different versions oftask003.MyLibrary - Handles changes in linked repositories: The merge process merges the changes in to combine the changes to
MyLibraryfrom both branches.events.h - Updates the wXlink: UVCS ensures that the wXlink updates to point to the newly merged version of in
events.h.MyLibrary
Relative Xlinks
When you replicate an Xlink, the Xlink still links to the original target repository. For example, if your Xlink originally pointed to a repository onmainserver.location1.com:8087otherserver.location2.com:8087mainserver
To create a relative Xlink, add the
-rscm xlink -rs component1 / 6@mylibrary