File: test-clone.t

package info (click to toggle)
hg-git 1.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,432 kB
  • sloc: python: 8,200; sh: 185; makefile: 23
file content (211 lines) | stat: -rw-r--r-- 6,293 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
#testcases secret draft

Load commonly used test logic
  $ . "$TESTDIR/testutil"

#if secret
The phases setting should not affect hg-git
  $ cat >> $HGRCPATH <<EOF
  > [phases]
  > new-commit = secret
  > EOF
#endif

  $ git init gitrepo
  Initialized empty Git repository in $TESTTMP/gitrepo/.git/
  $ cd gitrepo
  $ echo alpha > alpha
  $ git add alpha
  $ fn_git_commit -m 'add alpha'

  $ git tag alpha

  $ git checkout -b beta 2>&1 | sed s/\'/\"/g
  Switched to a new branch "beta"
  $ echo beta > beta
  $ git add beta
  $ fn_git_commit -m 'add beta'
  $ git checkout -b gamma 2>&1 | sed s/\'/\"/g
  Switched to a new branch "gamma"
  $ echo gamma > gamma
  $ git add gamma
  $ fn_git_commit -m 'add gamma'
  $ git checkout -q beta


  $ cd ..

clone a tag

  $ hg clone -r alpha gitrepo hgrepo-a
  importing 1 git commits
  new changesets ff7a2f2d8d70 (1 drafts)
  updating to branch default
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ hg -R hgrepo-a bookmarks
     master                    0:ff7a2f2d8d70
  $ hg -R hgrepo-a log --graph --template=phases
  @  changeset:   0:ff7a2f2d8d70
     bookmark:    master
     tag:         alpha
     tag:         default/master
     tag:         tip
     phase:       draft
     user:        test <test@example.org>
     date:        Mon Jan 01 00:00:10 2007 +0000
     summary:     add alpha
  
Make sure this is still draft since we didn't pull remote's HEAD
  $ hg -R hgrepo-a phase -r alpha
  0: draft

clone a branch
  $ hg clone -r beta gitrepo hgrepo-b
  importing 2 git commits
  new changesets ff7a2f2d8d70:7fe02317c63d (2 drafts)
  updating to branch default
  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ hg -R hgrepo-b bookmarks
   * beta                      1:7fe02317c63d
     master                    0:ff7a2f2d8d70
  $ hg -R hgrepo-b log --graph
  @  changeset:   1:7fe02317c63d
  |  bookmark:    beta
  |  tag:         default/beta
  |  tag:         tip
  |  user:        test <test@example.org>
  |  date:        Mon Jan 01 00:00:11 2007 +0000
  |  summary:     add beta
  |
  o  changeset:   0:ff7a2f2d8d70
     bookmark:    master
     tag:         alpha
     tag:         default/master
     user:        test <test@example.org>
     date:        Mon Jan 01 00:00:10 2007 +0000
     summary:     add alpha
  

Make sure that a deleted .hgsubstate does not confuse hg-git

  $ cd gitrepo
  $ echo 'HASH random' > .hgsubstate
  $ git add .hgsubstate
  $ fn_git_commit -m 'add bogus .hgsubstate'
  $ git rm -q .hgsubstate
  $ fn_git_commit -m 'remove bogus .hgsubstate'
  $ cd ..

  $ hg clone -r beta gitrepo hgrepo-c
  importing 4 git commits
  new changesets ff7a2f2d8d70:47d12948785d (4 drafts)
  updating to branch default
  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ hg -R hgrepo-c bookmarks
   * beta                      3:47d12948785d
     master                    0:ff7a2f2d8d70
  $ hg --cwd hgrepo-c status

test shared repositories

  $ hg clone gitrepo hgrepo-base
  importing 5 git commits
  new changesets ff7a2f2d8d70:47d12948785d (5 drafts)
  updating to branch default (no-hg57 !)
  updating to bookmark beta (hg57 !)
  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ hg -R hgrepo-base bookmarks
   * beta                      4:47d12948785d
     gamma                     2:ca33a262eb46
     master                    0:ff7a2f2d8d70
  $ hg  --config extensions.share= share hgrepo-base hgrepo-shared
  updating working directory
  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ hg -R hgrepo-shared pull gitrepo
  pulling from gitrepo
  no changes found
  adding bookmark beta
  adding bookmark gamma
  adding bookmark master
  $ hg -R hgrepo-shared push gitrepo
  pushing to gitrepo
  searching for changes
  no changes found
  [1]
  $ ls hgrepo-shared/.hg | grep git
  [1]
  $ hg -R hgrepo-shared git-cleanup
  git commit map cleaned
  $ rm -rf hgrepo-base hgrepo-shared

test cloning HEAD

  $ cd gitrepo
  $ git checkout -q master
  $ cd ..
  $ hg clone gitrepo hgrepo-2
  importing 5 git commits
  new changesets ff7a2f2d8d70:47d12948785d (5 drafts)
  updating to bookmark master (hg57 !)
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved (hg57 !)
  updating to branch default (no-hg57 !)
  2 files updated, 0 files merged, 0 files removed, 0 files unresolved (no-hg57 !)
  $ rm -rf hgrepo-2

clone empty repo
  $ git init empty
  Initialized empty Git repository in $TESTTMP/empty/.git/
  $ hg clone empty emptyhg
  updating to branch default
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ rm -rf empty emptyhg

test cloning detached HEAD, but pointing to a branch; we detect this
and activate the corresponding bookmark

  $ cd gitrepo
  $ git checkout -q -d master
  $ cd ..
#if hg57
  $ hg clone gitrepo hgrepo-2
  importing 5 git commits
  new changesets ff7a2f2d8d70:47d12948785d (5 drafts)
  updating to bookmark master
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
#else
  $ hg clone gitrepo hgrepo-2
  importing 5 git commits
  new changesets ff7a2f2d8d70:47d12948785d (5 drafts)
  updating to branch default
  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
#endif
  $ hg -R hgrepo-2 book
     beta                      4:47d12948785d
     gamma                     2:ca33a262eb46
   * master                    0:ff7a2f2d8d70
  $ rm -rf hgrepo-2

test cloning fully detached HEAD; we don't convert the
anonymous/detached head, so we just issue a warning and don't do
anything special

  $ cd gitrepo
  $ git checkout -q -d master
  $ echo delta > delta
  $ git add delta
  $ fn_git_commit -m 'add delta'
  $ cd ..
  $ hg clone gitrepo hgrepo-2
  importing 5 git commits
  new changesets ff7a2f2d8d70:47d12948785d (5 drafts)
  warning: the git source repository has a detached head
  (you may want to update to a bookmark)
  updating to branch default
  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ hg -R hgrepo-2 book
     beta                      4:47d12948785d
     gamma                     2:ca33a262eb46
     master                    0:ff7a2f2d8d70
  $ hg -R hgrepo-2 id --tags
  default/beta tip
  $ rm -rf hgrepo-2