work in progress: bidirectional sync
I'm working on "bi-directional sync" which is one of the reasons behind the move to Plastic SCM 4.0.
What is it?
Simple: a way to sync a branch with another scm and handle conflicting changes.
I'm writing down a very initial session below:
Sync with Subversion - initial import
Here we go, first thing is to make myself admin of the repo due to a bug I still didn't fix on the import code (ouch!)
$ cm setowner -user=pablo repserver:localhost:8084
Now launch the first sync, note I specify the branch in Plastic, the type of scm (svn, it could also be "tfs" now) and the scm url
$ cm sync main@default@localhost:8084 svn svn://localhost
Latest cset on foreign SCM: 6
Changesets to pull
1 - 01/10/2011 7:18:16 - - trunk created
2 - 01/10/2011 7:19:30 - - initial code import
3 - 01/10/2011 7:28:25 - - hud.txt modified
4 - 01/10/2011 7:30:28 - - trunk created
5 - 01/10/2011 8:00:04 - - hello.txt added
6 - 01/10/2011 8:03:00 - - modified hello.txt
Now a second hack due to another bug I still didn't fix
$ cm au pablo
User pablo has been successfully activated
Then create a new workspace, update to get the code imported from SVN and so on
$ cm mkwk plasticwk .
Workspace plasticwk has been correctly created
$ cm update .
Copied c:\Users\pablo\wkspaces\testwkspaces\svnsync\plasticwk\hello.txt
$ cm ls
01/10/2011 08:03 dir br:/main#6 .
01/10/2011 08:05 txt br:/main#1 hello.txt
Make a change in Plastic and push it to SVN
Create a new file, checkin and push to SVN.
$ echo bye > bye.txt
$ cm add bye.txt
The selected items are about to be added. Please wait ...
Item bye.txt was correctly added
$ cm ci -c="added bye.txt"
The selected items are about to be checked in. Please wait ...
Assembling checkin data
Validating checkin data
Uploading file data
Uploaded 6 bytes of 6 bytes (100%)
Confirming checkin operation
Modified c:\Users\pablo\wkspaces\testwkspaces\svnsync\plasticwk
Added c:\Users\pablo\wkspaces\testwkspaces\svnsync\plasticwk\bye.txt
Created changeset cs:7@br:/main@rep:default@repserver:TRISKELION:8084
Now launch the sync, please note I don't have to specify the type of remote scm anymore, and I don't have to type the svn url either because it gets "saved" after the first sync.
$ cm sync main
Last equivalence found 6 -> 6
No new revisions to pull from the foreign SCM
Changesets to push
7 - 01/10/2011 8:06:19 - pablo - added bye.txt
Check commit
Committed changeset 7
Launch the sync again and it tells there are no changes to push or pull anymore.
$ cm sync main
Last equivalence found 7 -> 7
No new revisions to pull from the foreign SCM
Branches are in sync. There are no changesets to push or pull
Concurrent change scenario
Now, the guy at the plastic and the svn sides make changes concurrently, what will it happen? Let's go.
Add a new file in plastic:
$ echo newest > newest.txt
$ cm add newest.txt
The selected items are about to be added. Please wait ...
Item newest.txt was correctly added
$ cm ci -c="added newest.txt on plastic"
The selected items are about to be checked in. Please wait ...
Assembling checkin data
Validating checkin data
Uploading file data
Uploaded 9 bytes of 9 bytes (100%)
Confirming checkin operation
Modified c:\Users\pablo\wkspaces\testwkspaces\svnsync\plasticwk
Added c:\Users\pablo\wkspaces\testwkspaces\svnsync\plasticwk\newest.txt
Created changeset cs:8@br:/main@rep:default@repserver:TRISKELION:8084
Now we modify a different file in SVN, ok?
I launch the sync again, read the details
$ cm sync main
Last equivalence found 7 -> 7
Latest cset on foreign SCM: 8
Changesets to pull
8 - 01/10/2011 8:08:12 - - =modified bye.txt on svn
Changesets to push
8 - 01/10/2011 8:08:24 - pablo - added newest.txt on plastic
There are changesets to push and pull.
Will pull the remote changes then you'll have to merge them and push the changes back.
What happened?
$ cm find changeset
10 0 /main 01/10/2011 08:04:35 all default Root dir
20 1 /main 01/10/2011 07:18:16 pablo default trunk created
4348 2 /main 01/10/2011 07:19:30 pablo default initial code import
4367 3 /main 01/10/2011 07:28:25 pablo default hud.txt modified
4379 4 /main 01/10/2011 07:30:28 pablo default trunk created
4384 5 /main 01/10/2011 08:00:04 pablo default hello.txt added
4388 6 /main 01/10/2011 08:03:00 pablo default modified hello.txt
4397 7 /main 01/10/2011 08:06:19 pablo default added bye.txt
4405 8 /main 01/10/2011 08:08:24 pablo default added newest.txt on plastic
4410 9 /main 01/10/2011 08:08:12 pablo default =modified bye.txt on svn
Total: 10
The "remote" changeset from SVN has been pulled but since there's a conflict, I'll have to merge before pushing back to svn.
$ cm merge cs:9
The file /bye.txt#br:/main#1 was modified on source and will replace the destination version
$ cm merge cs:9 --merge
The file /bye.txt#br:/main#1 was modified on source and will replace the destination version
Merging c:\Users\pablo\wkspaces\testwkspaces\svnsync\plasticwk\bye.txt
The revision c:\Users\pablo\wkspaces\testwkspaces\svnsync\plasticwk\bye.txt@9 has been loaded
$ cm ci -c="merged from cs9 coming from svn"
The selected items are about to be checked in. Please wait ...
Assembling checkin data
Validating checkin data
Uploading file data
Confirming checkin operation
Modified c:\Users\pablo\wkspaces\testwkspaces\svnsync\plasticwk
Copied c:\Users\pablo\wkspaces\testwkspaces\svnsync\plasticwk\bye.txt
Created changeset cs:10@br:/main@rep:default@repserver:TRISKELION:8084
Now I run the sync again. Plastic is going to push the new cset (the merged cset) that will contain the changes between the merged cset (10) and the imported cset from svn (9) hence the changes introduced in 8.
$ cm sync main --preview
Last equivalence found 9 -> 8
No new revisions to pull from the foreign SCM
Changesets to push
10 - 01/10/2011 8:09:58 - pablo - merged from cs9 coming from svn
$ cm sync main
Last equivalence found 9 -> 8
No new revisions to pull from the foreign SCM
Changesets to push
10 - 01/10/2011 8:09:58 - pablo - merged from cs9 coming from svn
Check commit
Committed changeset 9
Now, how does it look like from the SVN side?
$ svn diff -r 9:8
Index: newest.txt
===================================================================
--- newest.txt (revision 9)
+++ newest.txt (revision 8)
The file "newest.txt" was added on changeset 8 in Plastic and is now in SVN!
Great, isn't it? I expect to get it merged asap into the next 4.0 beta release.
Pablo Santos
I'm the CTO and Founder at Códice.
I've been leading Plastic SCM since 2005. My passion is helping teams work better through version control.
I had the opportunity to see teams from many different industries at work while I helped them improving their version control practices.
I really enjoy teaching (I've been a University professor for 6+ years) and sharing my experience in talks and articles.
And I love simple code.
You can reach me at
@psluaces.
0 comentarios: