##// END OF EJS Templates
convert: fix history topology when using hg.tagsbranch...
Patrick Mezard -
r9431:d1b135f2 default
parent child Browse files
Show More
@@ -0,0 +1,64 b''
1 #!/bin/sh
2
3 "$TESTDIR/hghave" git || exit 80
4
5 echo "[extensions]" >> $HGRCPATH
6 echo "convert=" >> $HGRCPATH
7 echo 'hgext.graphlog =' >> $HGRCPATH
8 echo '[convert]' >> $HGRCPATH
9 echo 'hg.usebranchnames = True' >> $HGRCPATH
10 echo 'hg.tagsbranch = tags-update' >> $HGRCPATH
11
12 GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
13 GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
14 GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE
15 GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME
16 GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL
17 GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE
18
19 count=10
20 action()
21 {
22 GIT_AUTHOR_DATE="2007-01-01 00:00:$count +0000"
23 GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
24 git "$@" >/dev/null 2>/dev/null || echo "git command error"
25 count=`expr $count + 1`
26 }
27
28 glog()
29 {
30 hg glog --template '{rev} "{desc|firstline}" files: {files}\n' "$@"
31 }
32
33 convertrepo()
34 {
35 hg convert --datesort git-repo hg-repo
36 }
37
38 # Build a GIT repo with at least 1 tag
39 mkdir git-repo
40 cd git-repo
41 git init >/dev/null 2>&1
42 echo a > a
43 git add a
44 action commit -m "rev1"
45 action tag -m "tag1" tag1
46 cd ..
47
48 # Do a first conversion
49 convertrepo
50
51 # Simulate upstream updates after first conversion
52 cd git-repo
53 echo b > a
54 git add a
55 action commit -m "rev2"
56 action tag -m "tag2" tag2
57 cd ..
58
59 # Perform an incremental conversion
60 convertrepo
61
62 # Print the log
63 cd hg-repo
64 glog
@@ -0,0 +1,19 b''
1 initializing destination hg-repo repository
2 scanning source...
3 sorting...
4 converting...
5 0 rev1
6 updating tags
7 scanning source...
8 sorting...
9 converting...
10 0 rev2
11 updating tags
12 o 3 "update tags" files: .hgtags
13 |
14 | o 2 "rev2" files: a
15 | |
16 o | 1 "update tags" files: .hgtags
17 /
18 o 0 "rev1" files: a
19
@@ -203,6 +203,8 b' class converter_sink(object):'
203 203 """Put tags into sink.
204 204
205 205 tags: {tagname: sink_rev_id, ...} where tagname is an UTF-8 string.
206 Return a pair (tag_revision, tag_parent_revision), or (None, None)
207 if nothing was changed.
206 208 """
207 209 raise NotImplementedError()
208 210
@@ -336,11 +336,14 b' class converter(object):'
336 336 ctags[k] = self.map[v]
337 337
338 338 if c and ctags:
339 nrev = self.dest.puttags(ctags)
340 # write another hash correspondence to override the previous
341 # one so we don't end up with extra tag heads
342 if nrev:
343 self.map[c] = nrev
339 nrev, tagsparent = self.dest.puttags(ctags)
340 if nrev and tagsparent:
341 # write another hash correspondence to override the previous
342 # one so we don't end up with extra tag heads
343 tagsparents = [e for e in self.map.iteritems()
344 if e[1] == tagsparent]
345 if tagsparents:
346 self.map[tagsparents[0][0]] = nrev
344 347
345 348 self.writeauthormap()
346 349 finally:
@@ -189,7 +189,7 b' class mercurial_sink(converter_sink):'
189 189
190 190 newlines = sorted([("%s %s\n" % (tags[tag], tag)) for tag in tags])
191 191 if newlines == oldlines:
192 return None
192 return None, None
193 193 data = "".join(newlines)
194 194 def getfilectx(repo, memctx, f):
195 195 return context.memfilectx(f, data, False, False, None)
@@ -201,7 +201,7 b' class mercurial_sink(converter_sink):'
201 201 [".hgtags"], getfilectx, "convert-repo", date,
202 202 extra)
203 203 self.repo.commitctx(ctx)
204 return hex(self.repo.changelog.tip())
204 return hex(self.repo.changelog.tip()), hex(tagparent)
205 205
206 206 def setfilemapmode(self, active):
207 207 self.filemapmode = active
@@ -18,12 +18,12 b' marked working directory as branch branc'
18 18 % incremental conversion
19 19 2 c1
20 20 pulling from branch0 into branch1
21 2 changesets found
21 4 changesets found
22 22 1 c2
23 23 pulling from branch0 into branch2
24 2 changesets found
24 4 changesets found
25 25 0 c3
26 26 pulling from branch2 into branch3
27 3 changesets found
27 5 changesets found
28 28 pulling from branch1 into branch3
29 29 1 changesets found
General Comments 0
You need to be logged in to leave comments. Login now