The svn switch command transforms an
existing working copy into a different branch. While this
command isn't strictly necessary for working with branches, it
provides a nice shortcut to users. In our earlier example,
after creating your private branch, you checked out a fresh
working copy of the new repository directory. Instead, you can
simply ask Subversion to change your working copy of
/calc/trunk
to mirror the new branch
location:
Il comando svn switch trasforma una
copia di lavoro esistente in modo da riflettere diverso ramo. Anche se
questo comando non è strettamente necessario per lavorare con
i rami, fornisce ai utenti una bella scorciatoia. In uno dei primi esempi
dopo aver creato vostro privato ramo, avete tirato fuori (check out)
una fresca copia della nuova cartella del deposito(repository). Invece,
potete semplicemente chiedere a Subversion di cambiare vostra
copia di lavoro del /calc/trunk
per riflettere
nuovo ramo:
$ cd calc $ svn info | grep URL URL: http://svn.example.com/repos/calc/trunk $ svn switch http://svn.example.com/repos/calc/branches/my-calc-branch U integer.c U button.c U Makefile Updated to revision 341. $ svn info | grep URL URL: http://svn.example.com/repos/calc/branches/my-calc-branch
After “switching” to the branch, your working copy is no different than what you would get from doing a fresh checkout of the directory. And it's usually more efficient to use this command, because often branches only differ by a small degree. The server sends only the minimal set of changes necessary to make your working copy reflect the branch directory.
Dopo «switching» [cerco una traduzione calzante] al ramo, vostra copia di lavoro non è diversa da tale che potevate ottenere facendo checkout fresco fresco della cartella. E molte volte è anche più efficace di usare questo comando, perche spesso rami differiscono di piccolo grado. Il server manda solo un insieme minimo delle modifiche necessari per allineare vostra copia di lavoro con la cartella del ramo.
The svn switch command also takes a
--revision
(-r
) option, so you
need not always move your working copy to the “tip”
of the branch.
Il comando svn switch prende anche una opzione
--revision
(-r
), so you
need not always move your working copy to the «tip»
of the branch.
Of course, most projects are more complicated than our
calc
example, containing multiple
subdirectories. Subversion users often follow a specific
algorithm when using branches:
Certo, molti progetti sono più complicati di nostro esempio
calc
, contendo sottocartelle multiple.
Utenti di Subversion spesso seguono un algoritmo specifico
quando usano i rami:
Copy the project's entire “trunk” to a new branch directory.
Copiare tutto il «trunk» del progetto nella cartella del nuovo ramo.
Switch only part of the trunk working copy to mirror the branch.
Cambiare(switch) solo una parte della copia di lavoro del tronco per rispechiare il ramo.
In other words, if a user knows that the branch-work only needs to happen on a specific subdirectory, they use svn switch to move only that subdirectory to the branch. (Or sometimes users will switch just a single working file to the branch!) That way, they can continue to receive normal “trunk” updates to most of their working copy, but the switched portions will remain immune (unless someone commits a change to their branch). This feature adds a whole new dimension to the concept of a “mixed working copy”—not only can working copies contain a mixture of working revisions, but a mixture of repository locations as well.
In altre parole, se un utente sa che lavoro sul ramo è neccessario solo in una specifica sottocartella, usa svn switch per spostare solo quella sottocartella sul ramo. (O qualche volta utenti cambiano(switch) solo un file di lavoro sul ramo!) In quel modo, continuano a ricevere normali aggiornamenti del «trunk» per maggior parte della loro copia di lavoro, ma la parte ??switchata? :) rimarrà imune (finché qualcuno non deposita cambiamenti su loro raomo). Questa caratteristica aggiunge completamente nuova dimensione al concetto di «copia di lavoro mista»—mom solo la copia di lavoro può contenere una miscella delle revisioni, ma con la stessa facilità anche miscella delle locazioni del deposito(repository).
If your working copy contains a number of switched subtrees from different repository locations, it continues to function as normal. When you update, you'll receive patches to each subtree as appropriate. When you commit, your local changes will still be applied as a single, atomic change to the repository.
Nonostante vostra copia di lavoro contiene una quantità delle sottostrutture alternate da diversi posti del deposito(repository), continua funzionare normalmente. Durante aggiornamenti riceve modifiche per ogni sottostruttura dal posto giusto. Quando depositate, vostre modifiche locali sono ancora applicate come una singola, atomica modifica del deposito(repository).
Note that while it's okay for your working copy to reflect a mixture of repository locations, these locations must all be within the same repository. Subversion repositories aren't yet able to communicate with one another; that's a feature planned beyond Subversion 1.0.[24]
Da notare: anche se è consentito alla vostra copia di lavoro di riflettere miscella dei posti del deposito(repository), questi posti devono tutti provenire dal unico deposito(repository). I depositi di Subversion non sono ancora capaci di communicare tra loro; questa caratteristica è pianificata oltre Subversion 1.0.[25]
Because svn switch is essentially a variant of svn update, it shares the same behaviors; any local modifications in your working copy are preserved when new data arrives from the repository. This allows you to perform all sorts of clever tricks.
Perché svn switch è esenzialmente una variante di svn update, condivide lo stesso comportamento; qualsiasi modifica locale nella vostra copia di lavoro è conservata quando arrivano nuovi dati dal deposito(repository). Questo vi permette di fare ogni sorta di truchetti intelligenti.
For example, suppose you have a working copy of
/calc/trunk
and make a number of changes to
it. Then you suddenly realize that you meant to make the
changes to a branch instead. No problem! When you svn
switch your working copy to the branch, the local
changes will remain. You can then test and commit them to the
branch.
Per esempio, supponiamo che avete copia di lavoro di
/calc/trunk
e fatte una quantità di cambiamenti.
Solo dopo scoprite che avete pensavate di fare modifiche
sulla copia del ramo. No problem! Dopo svn
switch della vostra copia su ramo, i cambiamenti locali
restano. Potete testarli e poi depositarli sul ramo.
[24] You can, however, use
svn switch with the
--relocate
switch if the URL of your server
changes and you don't want to abandon an existing working copy.
See the svn switch section in Capitolo 9, Riferimento completo di Subversion for more information and an example.
[25] Potete, comunque,
usare svn switch con la opzione
--relocate
se URL del vostro server cambia e
voi non volete abbandonare una copia di lavoro esistente.
Vedi sezione svn switch in Capitolo 9, Riferimento completo di Subversion per avere più informazioni e un esempio.