External Items

Sometimes it is useful to construct a working copy that is made out of a number of different checkouts. For example, you may want different files or subdirectories to come from different locations in a repository, or perhaps from different repositories altogether. If you want every user to have the same layout, you can define the svn:externals properties to pull in the specified resource at the locations where they are needed.

External Folders

Let's say you check out a working copy of /project1 to D:\dev\project1. Select the folder D:\dev\project1, right click and choose Windows MenuProperties from the context menu. The Properties Dialog comes up. Then go to the Subversion tab. There, you can set properties. Click Add.... Select the svn:externals property from the combobox and write in the edit box the repository URL in the format url folder or if you want to specify a particular revision, -rREV url folder You can add multiple external projects, 1 per line. Suppose that you have set these properties on D:\dev\project1:

http://sounds.red-bean.com/repos  sounds
http://graphics.red-bean.com/repos/fast%20graphics  "quick graphs"
-r21 http://svn.red-bean.com/repos/skin-maker  skins/toolkit

Now click Set and commit your changes. When you (or any other user) update your working copy, Subversion will create a sub-folder D:\dev\project1\sounds and checkout the sounds project, another sub-folder D:\dev\project1\quick_graphs containing the graphics project, and finally a nested sub-folder D:\dev\project1\skins\toolkit containing revision 21 of the skin-maker project.

URLs must be properly escaped or they will not work, e.g. you must replace each space with %20 as shown in the second example above.

If you want the local path to include spaces or other special characters, you can enclose it in double quotes, or you can use the \ (backslash) character as a Unix shell style escape character preceding any special character. Of course this also means that you must use / (forward slash) as a path delimiter. Note that this behaviour is new in Subversion 1.6 and will not work with older clients.

Use explicit revision numbers

Priporočamo, da pri navajanju naslovov skladišč za zunanje projekte uporabljate tudi številke revizij, kot je opisano zgoraj. S tem si zagotovite, da se boste sami odločili, kdaj boste uporabili drug posnetek zunanjega projekta in natančno katerega. Poleg logičnega pogleda na stvar - da ne boste presenečeni nad spremembami v zunanjem projektu, nad katerim nimate nadzora - to prinaša tudi prednost pri posodabljanju na staro revizijo. V tem primeru se bodo zunanji projekti posodobili na natančno takšno revizijo, ki ustreza reviziji vaših projektov. Pri projektih razvoja programske opreme to pomeni uspešno oziroma neuspešno gradnjo stare različice kompleksnega projekta.

Older svn:externals definitions

The format shown here was introduced in Subversion 1.5. You may also see the older format which has the same information in a different order. The new format is preferred as it supports several useful features described below, but it will not work on older clients. The differences are shown in the Subversion Book.

If the external project is in the same repository, any changes you make there will be included in the commit list when you commit your main project.

Če se zunanji projekt nahaja v drugem skladišču, bodo vse spremembe, ki jih naredite na zunanjem projektu, prikazane, ko boste objavili glavni projekt, vendar morate zunanje spremembe objaviti posebej.

Če uporabljate absolutne naslove URL v definicijah svn:externals in morate delovno kopijo premestiti (n. pr. če se spremeni naslov skladišča), se zunanji ne bodo spremenili in morda ne bodo več delovali.

V izogib tem težavam odjemalci Subversion verzije 1.5 ali novejše podpirajo relativne zunanje naslove URL. Na voljo so štirje načini podajanja relativnega naslova URL. V naslednjih primerih predpostavljamo, da imamo dve skladišči: enega na naslovu http://primer.com/svn/sklad-1 in drugega na naslovu http://primer.com/svn/sklad-2. Prevzem naslova http://primer.com/svn/sklad-1/projekt/trunk naredimo v mapo C:\Delo, lastnost svn:externals pa je nastavljena na glavno vejo (trunk).

Relativno na nadrejeno mapo

Ti naslovi se vedno začnejo s predpono ../. Primer:

../../widgets/foo  common/foo-widget

S tem se naslov http://primer.com/svn/sklad-1/widgets/foo razširi v C:\Delo\common\foo-widget.

Upoštevajte, da je naslov URL relativen na naslov URL mape, ki ima nastavljeno lastnost svn:externals in ne na mapo, kjer se zunanji elementi nahajajo.

Relativno na korensko pot skladišča

Ti naslovi se vedno začnejo z ^/. Primer:

^/widgets/foo  common/foo-widget

Naslov http://primer.com/svn/sklad-1/widgets/foo ustreza C:\Delo\common\foo-widget.

S tem se enostavno sklicujete na skladišča, ki imajo enako lastnost SVNParentPath (skupna mapa, ki vsebuje več skladišč). Primer:

^/../sklad-2/hammers/claw  common/claw-hammer

Naslov http://primer.com/svn/sklad-2/hammers/claw ustreza C:\Delo\common\claw-hammer.

Relativno na shemo

Naslovi URL, ki se začnejo z nizom //, prekopirajo le shemo naslova URL. To je uporabno, kadar je potrebno gostitelja dosegati z različnimi shemami, odvisno od mrežne lokacije; n. pr. odjemalci v intranetu uporabijo http://, medtem kot zunanji odjemalci uporabijo svn+ssh://. Primer:

//primer.com/svn/sklad-1/widgets/foo  common/foo-widget

ustreza http://primer.com/svn/sklad-1/widgets/foo ali svn+ssh://primer.com/svn/sklad-1/widgets/foo, odvisno od metode, ki je bila uporabljena za prevzem mape C:\Delo.

Relativno na naslov strežnika

Naslovi URL, ki se začnejo z nizom /, prekopirajo shemo in gostitelja naslova URL, n. pr.

/svn/sklad-1/widgets/foo  common/foo-widget

ustreza http://primer.com/svn/sklad-1/widgets/foo v C:\Delo\common\foo-widget. Če ste delovno kopijo prevzeli iz drugega strežnika na naslovu svn+ssh://drug.strežnik.net/svn/sklad-1/projekt1/trunk, zunanje reference ustrezajo svn+ssh://drug.strežnik.net/svn/sklad-1/widgets/foo.

You can also specify a peg revision after the URL if required, e.g. http://sounds.red-bean.com/repos@19.

Če želite izvedeti več o tem, kako Subversion obravnava lastnosti, preberite “Nastavitve projekta”.

Za pregled različnih načinov dostopa do skupnih projektov si preberite “Kako vključim skupni podprojekt”.

External Files

As of Subversion 1.6 you can add single file externals to your working copy using the same syntax as for folders. However, there are some restrictions.

  • The path to the file external must place the file in an existing versioned folder. In general it makes most sense to place the file directly in the folder that has svn:externals set, but it can be in a versioned sub-folder if necessary. By contrast, directory externals will automatically create any intermediate unversioned folders as required.

  • The URL for a file external must be in the same repository as the URL that the file external will be inserted into; inter-repository file externals are not supported.

A file external behaves just like any other versioned file in many respects, but they cannot be moved or deleted using the normal commands; the svn:externals property must be modified instead.

File externals support incomplete in Subversion 1.6

In subversion 1.6 it is not possible to remove a file external from your working copy once you have added it, even if you delete the svn:externals property altogether. You have to checkout a fresh working copy to remove the file.