• Non ci sono risultati.

Risolvere i conflitti(Mettere insieme i cambiamenti operati da al- al-tri)

Nel documento Controllo di versione con Subversion (pagine 64-67)

We've already seen how svn status -u can predict conflicts. Suppose you run svn update and some interesting things occur: Si è già visto come il comando svn status -u può prevedere i conflitti. Si supponga di eseguire il comando svn update e che acca-da qualcosa di interessante: $ svn update U INSTALL G README C bar.c Updated to revision 46.

TheUandGcodes are no cause for concern; those files cleanly absorbed changes from the repository. The files marked withU

had local changes to begin with, but the changes coming from the repository didn't overlap with the local changes.

I codici di outputUeGnon sono utili alla causa; questi file hanno semplicemente assorbito le modifiche dal repository. I file mar-cati conUnon contengono modifiche locali ma sono stati aggiornati con le modifiche presenti nel repository. LaGindica la fusio-ne, il che significa che il file ha modifiche locali ma che le modifiche provenienti dal repository non hanno sovrascritto quelle loca-li.

But theCstands for conflict. This means that the changes from the server overlapped with your own, and now you have to manual-ly choose between them.

LaCindica un conflitto. Questo vuol dire che le modifiche del server hanno sovrascritto quelle locali, ed ora bisogna scegliere ma-nualmente tra esse.

Whenever a conflict occurs, three things typically occur to assist you in noticing and resolving that conflict: Ogni volta che si crea un conflitto, servono tipicamente tre cose per avvisare del conflitto ed aiutare a risolverlo:

Subversion prints aCduring the update, and remembers that the file is in a state of conflict.

Subversion visualizza unaCdurante l'aggiornamento, e ricorda che il file è in stato di conflitto. •

If Subversion considers the file to be of a mergeable type, it places conflict markers—special strings of text which delimit the “sides” of the conflict—into the file to visibly demonstrate the overlapping areas. (Subversion uses thesvn:mime-type pro-perty to decide if a file is capable of contextual, line-based merging. Seesezione chiamata «svn:mime-type»to learn more.)

Se Subversion considera che il file possa essere fuso, inserisce dei marcatori di conflitto — stringhe speciali di testo che delimi-tano gli «estremi» del conflitto — all'interno del file per rendere visibili le aree sovrapponibili. (Subversion usa la proprietà

svn:mime-typeper decidere se si può fare il merge del file. Per saperne di più si veda sezione chiamata «svn:mime-type».)

For every conflicted file, Subversion places up to three extra unversioned files in your working copy:

Per ogni file che ha avuto un conflitto, Subversion mette nella propria copia di lavoro tre file extra che non sono sotto il control-lo di versione.

filename.mine

This is your file as it existed in your working copy before you updated your working copy—that is, without conflict markers. This file has your latest changes in it and nothing else. (If Subversion considers the file to be unmergeable, then the.mine fi-le isn't created, since it would be identical to the working fifi-le.)

Questo è il file che c'era nella copia di lavoro prima dell'aggiornamento — ovvero, che non ha marcatori di conflitto. Questo file contiene le ultime modifiche fatte e nient'altro. (Se Subversion considera il file non fondibile, allora il file.minenon vie-ne creato, poiché potrebbe essere identico al file di lavoro).

filename.rOLDREV

This is the file that was theBASErevision before you updated your working copy. That is, the file that you checked out before you made your latest edits.

Questo è il file nella versioneBASEprecedente all'aggiornamento della copia di lavoro. È il file di cui si è fatto il check out prima delle ultime modifiche.

filename.rNEWREV

corre-sponds to theHEADrevision of the repository.

Questo è il file che il client di Subversion ha appena ricevuto dal server quando si è fatto l'aggiornamento della copia di lavoro. Questo file corrisponde alla revisioneHEADdel repository.

HereOLDREVis the revision number of the file in your.svndirectory andNEWREVis the revision number of the repository

HEAD.

OLDREVè il numero di revisione del file nella directory.svneNEWREVè il numero di revisione del repositoryHEAD.

For example, Sally makes changes to the filesandwich.txtin the repository. Harry has just changed the file in his working co-py and checked it in. Sally updates her working coco-py before checking in and she gets a conflict:

Ad esempio, Sally modifica il filesandwich.txtnel repository. Harry ha appena modificato il file nella sua copia di lavoro e ha fatto la commit. Sally ha aggiornato la sua copia di lavoro prima della propria commit ed ottiene un conflitto:

$ svn update C sandwich.txt Updated to revision 2. $ ls -1 sandwich.txt sandwich.txt.mine sandwich.txt.r1 sandwich.txt.r2

At this point, Subversion will not allow you to commit the filesandwich.txtuntil the three temporary files are removed. A questo punto, Subversion non permetterà la commit del filesandwich.txtfinché non verranno rimossi i tre files temporanei.

$ svn commit --message "Add a few more things" svn: Commit failed (details follow):

svn: Aborting commit: '/home/sally/svn-work/sandwich.txt' remains in conflict

If you get a conflict, you need to do one of three things: Se si ha un conflitto, è necessario fare una di queste tre cose:

Merge the conflicted text “by hand” (by examining and editing the conflict markers within the file). Sistemare il conflitto «a mano» (esaminando e modificando i marcatori di conflitto all'interno del file).

Copy one of the temporary files on top of your working file. Usare uno dei file temporanei per sovrascrivere il file di lavoro.

Run svn revert <filename> to throw away all of your local changes.

Eseguire il comando svn revert < filename> per annullare tutte le modifiche fatte in locale.

fi-5

You can always remove the temporary files yourself, but would you really want to do that when Subversion can do it for you? We didn't think so.

6Si possono sempre rimuovere i file autonomamente, ma perché farlo se Subversion può farlo al nostro posto? Non la pensavamo così.

les and Subversion no longer considers the file to be in a state of conflict.5

Una volta risolto il conflitto, bisogna informare Subversion eseguendo il comando svn resolved. In questo modo vengono rimossi i tre file temporanei e Subversion non considera più il file in stato di conflitto.6

$ svn resolved sandwich.txt

Resolved conflicted state of 'sandwich.txt'

Nel documento Controllo di versione con Subversion (pagine 64-67)

Documenti correlati