| 1 |
#require p4 |
| 2 |
|
| 3 |
$ echo "[extensions]" >> $HGRCPATH |
| 4 |
$ echo "convert = " >> $HGRCPATH |
| 5 |
|
| 6 |
create p4 depot |
| 7 |
$ P4ROOT=`pwd`/depot; export P4ROOT |
| 8 |
$ P4AUDIT=$P4ROOT/audit; export P4AUDIT |
| 9 |
$ P4JOURNAL=$P4ROOT/journal; export P4JOURNAL |
| 10 |
$ P4LOG=$P4ROOT/log; export P4LOG |
| 11 |
$ P4PORT=localhost:$HGPORT; export P4PORT |
| 12 |
$ P4DEBUG=1; export P4DEBUG |
| 13 |
|
| 14 |
start the p4 server |
| 15 |
$ [ ! -d $P4ROOT ] && mkdir $P4ROOT |
| 16 |
$ p4d -f -J off >$P4ROOT/stdout 2>$P4ROOT/stderr & |
| 17 |
$ echo $! >> $DAEMON_PIDS |
| 18 |
$ trap "echo stopping the p4 server ; p4 admin stop" EXIT |
| 19 |
|
| 20 |
$ # wait for the server to initialize |
| 21 |
$ while ! p4 ; do |
| 22 |
> sleep 1 |
| 23 |
> done >/dev/null 2>/dev/null |
| 24 |
|
| 25 |
create a client spec |
| 26 |
$ P4CLIENT=hg-p4-import; export P4CLIENT |
| 27 |
$ DEPOTPATH=//depot/test-mercurial-import/... |
| 28 |
$ p4 client -o | sed '/^View:/,$ d' >p4client |
| 29 |
$ echo View: >>p4client |
| 30 |
$ echo " $DEPOTPATH //$P4CLIENT/..." >>p4client |
| 31 |
$ p4 client -i <p4client |
| 32 |
Client hg-p4-import saved. |
| 33 |
|
| 34 |
populate the depot |
| 35 |
$ echo a > a |
| 36 |
$ mkdir b |
| 37 |
$ echo c > b/c |
| 38 |
$ p4 add a b/c |
| 39 |
//depot/test-mercurial-import/a#1 - opened for add |
| 40 |
//depot/test-mercurial-import/b/c#1 - opened for add |
| 41 |
$ p4 submit -d initial |
| 42 |
Submitting change 1. |
| 43 |
Locking 2 files ... |
| 44 |
add //depot/test-mercurial-import/a#1 |
| 45 |
add //depot/test-mercurial-import/b/c#1 |
| 46 |
Change 1 submitted. |
| 47 |
|
| 48 |
change some files |
| 49 |
$ p4 edit a |
| 50 |
//depot/test-mercurial-import/a#1 - opened for edit |
| 51 |
$ echo aa >> a |
| 52 |
$ p4 submit -d "change a" |
| 53 |
Submitting change 2. |
| 54 |
Locking 1 files ... |
| 55 |
edit //depot/test-mercurial-import/a#2 |
| 56 |
Change 2 submitted. |
| 57 |
|
| 58 |
$ p4 edit b/c |
| 59 |
//depot/test-mercurial-import/b/c#1 - opened for edit |
| 60 |
$ echo cc >> b/c |
| 61 |
$ p4 submit -d "change b/c" |
| 62 |
Submitting change 3. |
| 63 |
Locking 1 files ... |
| 64 |
edit //depot/test-mercurial-import/b/c#2 |
| 65 |
Change 3 submitted. |
| 66 |
|
| 67 |
convert |
| 68 |
$ hg convert -s p4 $DEPOTPATH dst |
| 69 |
initializing destination dst repository |
| 70 |
scanning source... |
| 71 |
reading p4 views |
| 72 |
collecting p4 changelists |
| 73 |
1 initial |
| 74 |
2 change a |
| 75 |
3 change b/c |
| 76 |
sorting... |
| 77 |
converting... |
| 78 |
2 initial |
| 79 |
1 change a |
| 80 |
0 change b/c |
| 81 |
$ hg -R dst log --template 'rev={rev} desc="{desc}" tags="{tags}" files="{files}"\n' |
| 82 |
rev=2 desc="change b/c" tags="tip" files="b/c" |
| 83 |
rev=1 desc="change a" tags="" files="a" |
| 84 |
rev=0 desc="initial" tags="" files="a b/c" |
| 85 |
|
| 86 |
change some files |
| 87 |
$ p4 edit a b/c |
| 88 |
//depot/test-mercurial-import/a#2 - opened for edit |
| 89 |
//depot/test-mercurial-import/b/c#2 - opened for edit |
| 90 |
$ echo aaa >> a |
| 91 |
$ echo ccc >> b/c |
| 92 |
$ p4 submit -d "change a b/c" |
| 93 |
Submitting change 4. |
| 94 |
Locking 2 files ... |
| 95 |
edit //depot/test-mercurial-import/a#3 |
| 96 |
edit //depot/test-mercurial-import/b/c#3 |
| 97 |
Change 4 submitted. |
| 98 |
|
| 99 |
convert again |
| 100 |
$ hg convert -s p4 $DEPOTPATH dst |
| 101 |
scanning source... |
| 102 |
reading p4 views |
| 103 |
collecting p4 changelists |
| 104 |
4 change a b/c |
| 105 |
sorting... |
| 106 |
converting... |
| 107 |
0 change a b/c |
| 108 |
$ hg -R dst log --template 'rev={rev} desc="{desc}" tags="{tags}" files="{files}"\n' |
| 109 |
rev=3 desc="change a b/c" tags="tip" files="a b/c" |
| 110 |
rev=2 desc="change b/c" tags="" files="b/c" |
| 111 |
rev=1 desc="change a" tags="" files="a" |
| 112 |
rev=0 desc="initial" tags="" files="a b/c" |
| 113 |
|
| 114 |
interesting names |
| 115 |
$ echo dddd > "d d" |
| 116 |
$ mkdir " e" |
| 117 |
$ echo fff >" e/ f" |
| 118 |
$ p4 add "d d" " e/ f" |
| 119 |
//depot/test-mercurial-import/d d#1 - opened for add |
| 120 |
//depot/test-mercurial-import/ e/ f#1 - opened for add |
| 121 |
$ p4 submit -d "add d e f" |
| 122 |
Submitting change 5. |
| 123 |
Locking 2 files ... |
| 124 |
add //depot/test-mercurial-import/ e/ f#1 |
| 125 |
add //depot/test-mercurial-import/d d#1 |
| 126 |
Change 5 submitted. |
| 127 |
|
| 128 |
convert again |
| 129 |
$ hg convert -s p4 $DEPOTPATH dst |
| 130 |
scanning source... |
| 131 |
reading p4 views |
| 132 |
collecting p4 changelists |
| 133 |
5 add d e f |
| 134 |
sorting... |
| 135 |
converting... |
| 136 |
0 add d e f |
| 137 |
$ hg -R dst log --template 'rev={rev} desc="{desc}" tags="{tags}" files="{files}"\n' |
| 138 |
rev=4 desc="add d e f" tags="tip" files=" e/ f d d" |
| 139 |
rev=3 desc="change a b/c" tags="" files="a b/c" |
| 140 |
rev=2 desc="change b/c" tags="" files="b/c" |
| 141 |
rev=1 desc="change a" tags="" files="a" |
| 142 |
rev=0 desc="initial" tags="" files="a b/c" |
| 143 |
|
| 144 |
empty commit message |
| 145 |
$ p4 edit a |
| 146 |
//depot/test-mercurial-import/a#3 - opened for edit |
| 147 |
$ echo aaaaa >> a |
| 148 |
$ p4 submit -d "" |
| 149 |
Submitting change 6. |
| 150 |
Locking 1 files ... |
| 151 |
edit //depot/test-mercurial-import/a#4 |
| 152 |
Change 6 submitted. |
| 153 |
$ hg convert -s p4 $DEPOTPATH dst |
| 154 |
scanning source... |
| 155 |
reading p4 views |
| 156 |
collecting p4 changelists |
| 157 |
6 **empty changelist description** |
| 158 |
sorting... |
| 159 |
converting... |
| 160 |
0 |
| 161 |
|
| 162 |
exit trap: |
| 163 |
stopping the p4 server |