##// END OF EJS Templates
Merge with crew
Bryan O'Sullivan -
r5555:86405ff6 merge default
parent child Browse files
Show More
@@ -0,0 +1,66 b''
1 #!/bin/sh
2
3 "$TESTDIR/hghave" svn svn-bindings || exit 80
4
5 fix_path()
6 {
7 tr '\\' /
8 }
9
10 echo "[extensions]" >> $HGRCPATH
11 echo "convert = " >> $HGRCPATH
12
13 svnpath=`pwd`/svn-repo
14 svnadmin create $svnpath
15
16 cat > $svnpath/hooks/pre-revprop-change <<'EOF'
17 #!/bin/sh
18
19 REPOS="$1"
20 REV="$2"
21 USER="$3"
22 PROPNAME="$4"
23 ACTION="$5"
24
25 if [ "$ACTION" = "M" -a "$PROPNAME" = "svn:log" ]; then exit 0; fi
26 if [ "$ACTION" = "A" -a "$PROPNAME" = "hg:convert-branch" ]; then exit 0; fi
27 if [ "$ACTION" = "A" -a "$PROPNAME" = "hg:convert-rev" ]; then exit 0; fi
28
29 echo "Changing prohibited revision property" >&2
30 exit 1
31 EOF
32 chmod +x $svnpath/hooks/pre-revprop-change
33
34 svnurl=file://$svnpath
35 svn co $svnurl $svnpath-wc
36
37 cd $svnpath-wc
38 echo a > a
39 svn add a
40 svn ci -m'added a' a
41
42 cd ..
43
44 echo % initial roundtrip
45 hg convert -s svn -d hg $svnpath-wc $svnpath-hg | grep -v initializing
46 hg convert -s hg -d svn $svnpath-hg $svnpath-wc
47
48 echo % second roundtrip should do nothing
49 hg convert -s svn -d hg $svnpath-wc $svnpath-hg
50 hg convert -s hg -d svn $svnpath-hg $svnpath-wc
51
52 echo % new hg rev
53
54 hg clone $svnpath-hg $svnpath-work
55 echo b > $svnpath-work/b
56 hg --cwd $svnpath-work add b
57 hg --cwd $svnpath-work ci -mb
58
59 echo % echo hg to svn
60 hg --cwd $svnpath-hg pull -q $svnpath-work
61 hg convert -s hg -d svn $svnpath-hg $svnpath-wc
62
63 echo % svn back to hg should do nothing
64 hg convert -s svn -d hg $svnpath-wc $svnpath-hg
65 echo % hg back to svn should do nothing
66 hg convert -s hg -d svn $svnpath-hg $svnpath-wc
@@ -0,0 +1,35 b''
1 Checked out revision 0.
2 A a
3 Adding a
4 Transmitting file data .
5 Committed revision 1.
6 % initial roundtrip
7 scanning source...
8 sorting...
9 converting...
10 0 added a
11 scanning source...
12 sorting...
13 converting...
14 % second roundtrip should do nothing
15 scanning source...
16 sorting...
17 converting...
18 scanning source...
19 sorting...
20 converting...
21 % new hg rev
22 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
23 % echo hg to svn
24 scanning source...
25 sorting...
26 converting...
27 0 b
28 % svn back to hg should do nothing
29 scanning source...
30 sorting...
31 converting...
32 % hg back to svn should do nothing
33 scanning source...
34 sorting...
35 converting...
@@ -227,6 +227,7 b' class converter(object):'
227 227 self.dest.copyfile(copyf, f)
228 228
229 229 newnode = self.dest.putcommit(filenames, parents, commit)
230 self.source.converted(rev, newnode)
230 231 self.map[rev] = newnode
231 232
232 233 def convert(self):
@@ -115,6 +115,11 b' class converter_source(object):'
115 115 """
116 116 raise NotImplementedError()
117 117
118 def converted(self, rev, sinkrev):
119 '''Notify the source that a revision has been converted.'''
120 pass
121
122
118 123 class converter_sink(object):
119 124 """Conversion sink (target) interface"""
120 125
@@ -24,8 +24,6 b' class mercurial_sink(converter_sink):'
24 24 if os.path.isdir(path) and len(os.listdir(path)) > 0:
25 25 try:
26 26 self.repo = hg.repository(self.ui, path)
27 ui.status(_('destination %s is a Mercurial repository\n') %
28 path)
29 27 except hg.RepoError, err:
30 28 ui.print_exc()
31 29 raise NoRepo(err.args[0])
@@ -195,6 +193,7 b' class mercurial_source(converter_source)'
195 193 self.lastrev = None
196 194 self.lastctx = None
197 195 self._changescache = None
196 self.convertfp = None
198 197
199 198 def changectx(self, rev):
200 199 if self.lastrev != rev:
@@ -241,7 +240,7 b' class mercurial_source(converter_source)'
241 240 ctx = self.changectx(rev)
242 241 parents = [hex(p.node()) for p in ctx.parents() if p.node() != nullid]
243 242 return commit(author=ctx.user(), date=util.datestr(ctx.date()),
244 desc=ctx.description(), parents=parents,
243 desc=ctx.description(), rev=rev, parents=parents,
245 244 branch=ctx.branch(), extra=ctx.extra())
246 245
247 246 def gettags(self):
@@ -258,3 +257,9 b' class mercurial_source(converter_source)'
258 257
259 258 return changes[0] + changes[1] + changes[2]
260 259
260 def converted(self, rev, destrev):
261 if self.convertfp is None:
262 self.convertfp = open(os.path.join(self.path, '.hg', 'shamap'),
263 'a')
264 self.convertfp.write('%s %s\n' % (destrev, rev))
265 self.convertfp.flush()
@@ -154,6 +154,12 b' class svn_source(converter_source):'
154 154 self.head = self.revid(self.last_changed)
155 155 self._changescache = None
156 156
157 if os.path.exists(os.path.join(url, '.svn/entries')):
158 self.wc = url
159 else:
160 self.wc = None
161 self.convertfp = None
162
157 163 def setrevmap(self, revmap):
158 164 lastrevs = {}
159 165 for revid in revmap.iterkeys():
@@ -298,6 +304,15 b' class svn_source(converter_source):'
298 304 self.ui.note('no tags found at revision %d\n' % start)
299 305 return tags
300 306
307 def converted(self, rev, destrev):
308 if not self.wc:
309 return
310 if self.convertfp is None:
311 self.convertfp = open(os.path.join(self.wc, '.svn', 'hg-shamap'),
312 'a')
313 self.convertfp.write('%s %d\n' % (destrev, self.revnum(rev)))
314 self.convertfp.flush()
315
301 316 # -- helper functions --
302 317
303 318 def revid(self, revnum, module=None):
@@ -749,6 +764,9 b' class svn_sink(converter_sink, commandli'
749 764 fp.close()
750 765 util.set_exec(hook, True)
751 766
767 xport = transport.SvnRaTransport(url=geturl(path))
768 self.uuid = svn.ra.get_uuid(xport.ra)
769
752 770 def wjoin(self, *names):
753 771 return os.path.join(self.wc, *names)
754 772
@@ -837,10 +855,13 b' class svn_sink(converter_sink, commandli'
837 855 def addchild(self, parent, child):
838 856 self.childmap[parent] = child
839 857
858 def revid(self, rev):
859 return u"svn:%s@%s" % (self.uuid, rev)
860
840 861 def putcommit(self, files, parents, commit):
841 862 for parent in parents:
842 863 try:
843 return self.childmap[parent]
864 return self.revid(self.childmap[parent])
844 865 except KeyError:
845 866 pass
846 867 entries = set(self.delete)
@@ -873,7 +894,7 b' class svn_sink(converter_sink, commandli'
873 894 revprop=True, revision=rev)
874 895 for parent in parents:
875 896 self.addchild(parent, rev)
876 return rev
897 return self.revid(rev)
877 898 finally:
878 899 os.unlink(messagefile)
879 900
General Comments 0
You need to be logged in to leave comments. Login now