##// 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 self.dest.copyfile(copyf, f)
227 self.dest.copyfile(copyf, f)
228
228
229 newnode = self.dest.putcommit(filenames, parents, commit)
229 newnode = self.dest.putcommit(filenames, parents, commit)
230 self.source.converted(rev, newnode)
230 self.map[rev] = newnode
231 self.map[rev] = newnode
231
232
232 def convert(self):
233 def convert(self):
@@ -115,6 +115,11 b' class converter_source(object):'
115 """
115 """
116 raise NotImplementedError()
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 class converter_sink(object):
123 class converter_sink(object):
119 """Conversion sink (target) interface"""
124 """Conversion sink (target) interface"""
120
125
@@ -24,8 +24,6 b' class mercurial_sink(converter_sink):'
24 if os.path.isdir(path) and len(os.listdir(path)) > 0:
24 if os.path.isdir(path) and len(os.listdir(path)) > 0:
25 try:
25 try:
26 self.repo = hg.repository(self.ui, path)
26 self.repo = hg.repository(self.ui, path)
27 ui.status(_('destination %s is a Mercurial repository\n') %
28 path)
29 except hg.RepoError, err:
27 except hg.RepoError, err:
30 ui.print_exc()
28 ui.print_exc()
31 raise NoRepo(err.args[0])
29 raise NoRepo(err.args[0])
@@ -195,6 +193,7 b' class mercurial_source(converter_source)'
195 self.lastrev = None
193 self.lastrev = None
196 self.lastctx = None
194 self.lastctx = None
197 self._changescache = None
195 self._changescache = None
196 self.convertfp = None
198
197
199 def changectx(self, rev):
198 def changectx(self, rev):
200 if self.lastrev != rev:
199 if self.lastrev != rev:
@@ -241,7 +240,7 b' class mercurial_source(converter_source)'
241 ctx = self.changectx(rev)
240 ctx = self.changectx(rev)
242 parents = [hex(p.node()) for p in ctx.parents() if p.node() != nullid]
241 parents = [hex(p.node()) for p in ctx.parents() if p.node() != nullid]
243 return commit(author=ctx.user(), date=util.datestr(ctx.date()),
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 branch=ctx.branch(), extra=ctx.extra())
244 branch=ctx.branch(), extra=ctx.extra())
246
245
247 def gettags(self):
246 def gettags(self):
@@ -258,3 +257,9 b' class mercurial_source(converter_source)'
258
257
259 return changes[0] + changes[1] + changes[2]
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 self.head = self.revid(self.last_changed)
154 self.head = self.revid(self.last_changed)
155 self._changescache = None
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 def setrevmap(self, revmap):
163 def setrevmap(self, revmap):
158 lastrevs = {}
164 lastrevs = {}
159 for revid in revmap.iterkeys():
165 for revid in revmap.iterkeys():
@@ -298,6 +304,15 b' class svn_source(converter_source):'
298 self.ui.note('no tags found at revision %d\n' % start)
304 self.ui.note('no tags found at revision %d\n' % start)
299 return tags
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 # -- helper functions --
316 # -- helper functions --
302
317
303 def revid(self, revnum, module=None):
318 def revid(self, revnum, module=None):
@@ -749,6 +764,9 b' class svn_sink(converter_sink, commandli'
749 fp.close()
764 fp.close()
750 util.set_exec(hook, True)
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 def wjoin(self, *names):
770 def wjoin(self, *names):
753 return os.path.join(self.wc, *names)
771 return os.path.join(self.wc, *names)
754
772
@@ -837,10 +855,13 b' class svn_sink(converter_sink, commandli'
837 def addchild(self, parent, child):
855 def addchild(self, parent, child):
838 self.childmap[parent] = child
856 self.childmap[parent] = child
839
857
858 def revid(self, rev):
859 return u"svn:%s@%s" % (self.uuid, rev)
860
840 def putcommit(self, files, parents, commit):
861 def putcommit(self, files, parents, commit):
841 for parent in parents:
862 for parent in parents:
842 try:
863 try:
843 return self.childmap[parent]
864 return self.revid(self.childmap[parent])
844 except KeyError:
865 except KeyError:
845 pass
866 pass
846 entries = set(self.delete)
867 entries = set(self.delete)
@@ -873,7 +894,7 b' class svn_sink(converter_sink, commandli'
873 revprop=True, revision=rev)
894 revprop=True, revision=rev)
874 for parent in parents:
895 for parent in parents:
875 self.addchild(parent, rev)
896 self.addchild(parent, rev)
876 return rev
897 return self.revid(rev)
877 finally:
898 finally:
878 os.unlink(messagefile)
899 os.unlink(messagefile)
879
900
General Comments 0
You need to be logged in to leave comments. Login now