Manuals

Pencabangan / Pembuatan Tag

Salah satu fitur dari sistem kontrol versi adalah kemampuan untuk mengisolasi perubahan ke dalam baris terpisah dari pengembangan. Baris ini dikenal sebagai cabang. Cabang sering digunakan untuk mencoba fitur baru tanpa mengganggu baris pengembangan utama dengan kesalahan kompilator dan bug. Segera setelah fitur baru cukup stabil maka cabang pengembangan digabung kembali ke dalam cabang utama (trunk).

Fitur lain dari sistem kontrol versi adalah kemampuan untuk menandai revisi tertentu (contoh. versi rilis), agar Anda bisa membuat ulang kapan saja buatan tertentu atau lingkungan. Proses ini dikenal sebagai pembuatan tag.

Subversion does not have special commands for branching or tagging, but uses so-called cheap copies instead. Cheap copies are similar to hard links in Unix, which means that instead of making a complete copy in the repository, an internal link is created, pointing to a specific tree/revision. As a result branches and tags are very quick to create, and take up almost no extra space in the repository.

Membuat Cabang atau Tag

Jika Anda sudah mengimpor proyek Anda dengan struktur direktori yang direkomendasikan, membuat sebuah cabang atau versi tag sangat sederhana:

Gambar 4.54. Dialog Cabang/Tag

Dialog Cabang/Tag


Pilih folder dalam copy pekerjaan Anda yang ingin Anda copy ke cabang atau tag, lalu pilih perintah TortoiseSVNCabang/Tag....

The default destination URL for the new branch will be the source URL on which your working copy is based. You will need to edit that URL to the new path for your branch/tag. So instead of

http://svn.collab.net/repos/ProjectName/trunk
      

you might now use something like

http://svn.collab.net/repos/ProjectName/tags/Release_1.10
      

If you can't remember the naming convention you used last time, click the button on the right to open the repository browser so you can view the existing repository structure.

intermediate folders

When you specify the target URL, all the folders up to the last one must already exist or you will get an error message. In the above example, the URL http://svn.collab.net/repos/ProjectName/tags/ must exist to create the Release_1.10 tag.

However if you want to create a branch/tag to an URL that has intermediate folders that don't exist yet you can check the option Create intermediate folders at the bottom of the dialog. If that option is activated, all intermediate folders are automatically created.

Note that this option is disabled by default to avoid typos. For example, if you typed the target URL as http://svn.collab.net/repos/ProjectName/Tags/Release_1.10 instead of http://svn.collab.net/repos/ProjectName/tags/Release_1.10, you would get an error with the option disabled, but with the option enabled a folder Tags would be automatically created, and you would end up with a folder Tags and a folder tags.

Sekarang Anda harus memilih sumber yang dicopy. Disini Anda mempunyai tiga opsi:

Revisi HEAD dalam repositori

Cabang baru dicopy secara langsung dalam repositori dari revisi HEAD. Tidak ada data perlu ditransfer dari copy pekerjaan Anda, dan cabang dibuat sangat cepat.

Revisi tertentu dalam repositori

Cabang baru dicopy secara langsung dalam repositori tapi Anda bisa memilih revisi yang lebih lama. Ini berguna jika Anda lupa untuk membuat tag saat Anda merilis proyek Anda minggu lalu. Jika Anda tidak ingat angka revisi, klik tombol di kanan untuk menampilkan log revisi, dan memilih angka revisi dari sana. Sekali lagi tidak ada data yang ditransfer dari copy pekerjaan Anda, dan cabang dibuat dengan sangat cepat.

Copy pekerjaan

Cabang baru adalah copy identik dari copy pekerjaan lokal Anda. Jika Anda telah memutahirkan beberapa file ke revisi lebih lama dalam WC Anda, atau jika Anda telah membuat perubahan lokal, itulah yang akan masuk ke dalam copy. Secara alami ini semacam tag kompleks yang melibatkan pentransferan data dari WC Anda kembali ke repositori jika belum ada disana.

Jika Anda ingin copy pekerjaan Anda ditukar ke cabang yang baru dibuat secara otomatis, gunakan kotak centang Tukar copy pekerjaan ke cabang/tag baru. Tapi jika Anda melakukannya, pertama pastikan bahwa copy pekerjaan Anda tidak berisi modifikasi. Jika ada, perubahan itu akan digabung ke dalam cabang WC ketika Anda menukar.

If your working copy has other projects included with svn:externals properties, those externals will be listed at the bottom of the branch/tag dialog. For each external, the target path and the source URL is shown.

If you want to make sure that the new tag always is in a consistent state, check all the externals to have their revisions pinned. If you don't check the externals and those externals point to a HEAD revision which might change in the future, checking out the new tag will check out that HEAD revision of the external and your tag might not compile anymore. So it's always a good idea to set the externals to an explicit revision when creating a tag.

The externals are automatically pinned to either the current HEAD revision or the working copy BASE revision, depending on the source of the branch/tag:

Tabel 4.1. Pinned Revision

Copy SourcePinned Revision
Revisi HEAD dalam repositoriexternal's repos HEAD revision
Revisi spesifik dalam repositoriexternal's repos HEAD revision
Copy pekerjaanexternal's WC BASE revision


externals within externals

If a project that is included as an external has itself included externals, then those will not be tagged! Only externals that are direct children can be tagged.

Tekan OK untuk mengkomit copy baru ke repositori. Jangan lupa untuk menyertakan log pesan. Catatan bahwa copy dibuat di dalam repositori.

Note that unless you opted to switch your working copy to the newly created branch, creating a Branch or Tag does not affect your working copy. Even if you create the branch from your WC, those changes are committed to the new branch, not to the trunk, so your WC may still be marked as modified with respect to the trunk.

Other ways to create a branch or tag

You can also create a branch or tag without having a working copy. To do that, open the repository browser. You can there drag folders to a new location. You have to hold down the Ctrl key while you drag to create a copy, otherwise the folder gets moved, not copied.

You can also drag a folder with the right mouse button. Once you release the mouse button you can choose from the context menu whether you want the folder to be moved or copied. Of course to create a branch or tag you must copy the folder, not move it.

Yet another way is from the log dialog. You can show the log dialog for e.g. trunk, select a revision (either the HEAD revision at the very top or an earlier revision), right click and choose create branch/tag from revision....

Untuk Checkout atau Menukar...

...that is (not really) the question. While a checkout downloads everything from the desired branch in the repository to your working directory, TortoiseSVNSwitch... only transfers the changed data to your working copy. Good for the network load, good for your patience. :-)

To be able to work with your freshly generated branch or tag you have several ways to handle it. You can:

  • TortoiseSVNCheckout untuk membuat checkout segar dalam folder kosong. Anda bisa memeriksa setiap lokasi pada disk lokal Anda dan Anda bisa membuat banyak copy pekerjaan dari repositori sesuka Anda.

  • Menukar copy pekerjaan Anda ke copy yang baru saja dibuat dalam repositori Anda. Sekali lagi pilih level atas folder dari proyek Anda dan gunakan TortoiseSVNTukar... dari menu konteks.

    Dalam dialog berikut masukan URL dari cabang yang baru Anda buat. Pilih Revisi Head tombol radio dan klik OK. Copy pekerjaan Anda ditukar ke cabang/tag Anda.

    Menukar pekerjaan mirip seperti Mutahirkan dalam kecuali ia tidak pernah mengabaikan perubahan lokal Anda. Setiap perubahan Anda telah membuat copy pekerjaan Anda yang belum dikomit akan digabung ketika Anda melakukan Tukar. Jika Anda tidak ingin ini terjadi ketika Anda harus baik mengkomit perubahan sebelum penukaran, atau memulihkan copy pekerjaan Anda ke revisi yang sudah-dikomit (umumnya HEAD).

  • If you want to work on trunk and branch, but don't want the expense of a fresh checkout, you can use Windows Explorer to make a copy of your trunk checkout in another folder, then TortoiseSVNSwitch... that copy to your new branch.

Gambar 4.55. Dialog Tukar

Dialog Tukar


Meskipun Subversion sendiri tidak membuat perbedaan antara tag dan cabang, cara mereka biasanya digunakan agak sedikit berbeda.

  • Tags are typically used to create a static snapshot of the project at a particular stage. As such they are not normally used for development - that's what branches are for, which is the reason we recommended the /trunk /branches /tags repository structure in the first place. Working on a tag revision is not a good idea, but because your local files are not write protected there is nothing to stop you doing this by mistake. However, if you try to commit to a path in the repository which contains /tags/, TortoiseSVN will warn you.

  • Itu dimungkinkan bahwa Anda perlu untuk membuat perubahan selanjutnya ke rilis yang sudah Anda tag. Cara yang benar untuk menangani ini adalah membuat cabang baru dari tag pertama dan mengkomit ke cabang. Lakukan perubahan Anda pada cabang ini dan lalu buat tag baru dari cabang baru ini, contoh Versi_1.0.1.

  • Jika Anda mengubah copy pekerjaan yang dibuat dari cabang dan mengkomit, maka semua perubahan pergi ke cabang baru dan bukan ke trunk. Hanya modifikasi yang disimpan. Sisanya tetap copy murah.

TortoiseSVN homepage