# HG changeset patch # User Patrick Mezard # Date 2008-12-06 19:17:45 # Node ID 1e8d7339f350c441987b11a26d29ebd6f61ca2b7 # Parent b2cbced7bb50b6a3e67e9c074c67160be8d1af18 # Parent 6644c111f9e9baee1cd98493428914e2e71a282e Merge with crew-stable diff --git a/hgext/convert/subversion.py b/hgext/convert/subversion.py --- a/hgext/convert/subversion.py +++ b/hgext/convert/subversion.py @@ -724,12 +724,6 @@ class svn_source(converter_source): self.child_cset = None - def isdescendantof(parent, child): - if not child or not parent or not child.startswith(parent): - return False - subpath = child[len(parent):] - return len(subpath) > 1 and subpath[0] == '/' - def parselogentry(orig_paths, revnum, author, date, message): """Return the parsed commit object or None, and True if the revision is a branch root. @@ -752,21 +746,10 @@ class svn_source(converter_source): if root_paths: path, ent = root_paths[-1] if ent.copyfrom_path: - # If dir was moved while one of its file was removed - # the log may look like: - # A /dir (from /dir:x) - # A /dir/a (from /dir/a:y) - # A /dir/b (from /dir/b:z) - # ... - # for all remaining children. - # Let's take the highest child element from rev as source. - copies = [(p,e) for p,e in orig_paths[:-1] - if isdescendantof(ent.copyfrom_path, e.copyfrom_path)] - fromrev = max([e.copyfrom_rev for p,e in copies] + [ent.copyfrom_rev]) branched = True newpath = ent.copyfrom_path + self.module[len(path):] # ent.copyfrom_rev may not be the actual last revision - previd = self.latest(newpath, fromrev) + previd = self.latest(newpath, ent.copyfrom_rev) if previd is not None: prevmodule, prevnum = self.revsplit(previd)[1:] if prevnum >= self.startrev: diff --git a/tests/svn/branches.svndump b/tests/svn/branches.svndump new file mode 100644 --- /dev/null +++ b/tests/svn/branches.svndump @@ -0,0 +1,415 @@ +SVN-fs-dump-format-version: 2 + +UUID: 7b60030a-5a1f-4344-a009-73f0c1c2adf2 + +Revision-number: 0 +Prop-content-length: 56 +Content-length: 56 + +K 8 +svn:date +V 27 +2008-12-06T12:47:52.296168Z +PROPS-END + +Revision-number: 1 +Prop-content-length: 112 +Content-length: 112 + +K 7 +svn:log +V 10 +init projA +K 10 +svn:author +V 7 +pmezard +K 8 +svn:date +V 27 +2008-12-06T12:47:52.342238Z +PROPS-END + +Node-path: branches +Node-kind: dir +Node-action: add +Prop-content-length: 10 +Content-length: 10 + +PROPS-END + + +Node-path: tags +Node-kind: dir +Node-action: add +Prop-content-length: 10 +Content-length: 10 + +PROPS-END + + +Node-path: trunk +Node-kind: dir +Node-action: add +Prop-content-length: 10 +Content-length: 10 + +PROPS-END + + +Revision-number: 2 +Prop-content-length: 106 +Content-length: 106 + +K 7 +svn:log +V 5 +hello +K 10 +svn:author +V 7 +pmezard +K 8 +svn:date +V 27 +2008-12-06T12:47:53.190046Z +PROPS-END + +Node-path: branches/notinbranch +Node-kind: file +Node-action: add +Prop-content-length: 10 +Text-content-length: 2 +Text-content-md5: e29311f6f1bf1af907f9ef9f44b8328b +Content-length: 12 + +PROPS-END +d + + +Node-path: trunk/a +Node-kind: file +Node-action: add +Prop-content-length: 10 +Text-content-length: 2 +Text-content-md5: 60b725f10c9c85c70d97880dfe8191b3 +Content-length: 12 + +PROPS-END +a + + +Node-path: trunk/b +Node-kind: file +Node-action: add +Prop-content-length: 10 +Text-content-length: 2 +Text-content-md5: 3b5d5c3712955042212316173ccf37be +Content-length: 12 + +PROPS-END +b + + +Node-path: trunk/c +Node-kind: file +Node-action: add +Prop-content-length: 10 +Text-content-length: 2 +Text-content-md5: 2cd6ee2c70b0bde53fbe6cac3c8b8bb1 +Content-length: 12 + +PROPS-END +c + + +Revision-number: 3 +Prop-content-length: 124 +Content-length: 124 + +K 7 +svn:log +V 22 +branch trunk, remove c +K 10 +svn:author +V 7 +pmezard +K 8 +svn:date +V 27 +2008-12-06T12:47:55.188535Z +PROPS-END + +Node-path: branches/old +Node-kind: dir +Node-action: add +Node-copyfrom-rev: 1 +Node-copyfrom-path: trunk +Prop-content-length: 34 +Content-length: 34 + +K 13 +svn:mergeinfo +V 0 + +PROPS-END + + +Node-path: branches/old/a +Node-kind: file +Node-action: add +Node-copyfrom-rev: 2 +Node-copyfrom-path: trunk/a +Text-copy-source-md5: 60b725f10c9c85c70d97880dfe8191b3 + + +Node-path: branches/old/b +Node-kind: file +Node-action: add +Node-copyfrom-rev: 2 +Node-copyfrom-path: trunk/b +Text-copy-source-md5: 3b5d5c3712955042212316173ccf37be + + +Revision-number: 4 +Prop-content-length: 109 +Content-length: 109 + +K 7 +svn:log +V 8 +change a +K 10 +svn:author +V 7 +pmezard +K 8 +svn:date +V 27 +2008-12-06T12:47:57.146347Z +PROPS-END + +Node-path: trunk/a +Node-kind: file +Node-action: change +Text-content-length: 4 +Text-content-md5: 0d227f1abf8c2932d342e9b99cc957eb +Content-length: 4 + +a +a + + +Revision-number: 5 +Prop-content-length: 109 +Content-length: 109 + +K 7 +svn:log +V 8 +change b +K 10 +svn:author +V 7 +pmezard +K 8 +svn:date +V 27 +2008-12-06T12:47:58.150124Z +PROPS-END + +Node-path: branches/old/b +Node-kind: file +Node-action: change +Text-content-length: 4 +Text-content-md5: 06ac26ed8b614fc0b141e4542aa067c2 +Content-length: 4 + +b +b + + +Revision-number: 6 +Prop-content-length: 119 +Content-length: 119 + +K 7 +svn:log +V 17 +move and update c +K 10 +svn:author +V 7 +pmezard +K 8 +svn:date +V 27 +2008-12-06T12:48:00.161336Z +PROPS-END + +Node-path: branches/old/c +Node-kind: file +Node-action: add +Node-copyfrom-rev: 3 +Node-copyfrom-path: trunk/b +Text-copy-source-md5: 3b5d5c3712955042212316173ccf37be +Prop-content-length: 34 +Text-content-length: 4 +Text-content-md5: 33cb6785d50937d8d307ebb66d6259a7 +Content-length: 38 + +K 13 +svn:mergeinfo +V 0 + +PROPS-END +b +c + + +Node-path: trunk/b +Node-action: delete + + +Revision-number: 7 +Prop-content-length: 116 +Content-length: 116 + +K 7 +svn:log +V 14 +change b again +K 10 +svn:author +V 7 +pmezard +K 8 +svn:date +V 27 +2008-12-06T12:48:01.153724Z +PROPS-END + +Node-path: branches/old/b +Node-kind: file +Node-action: change +Text-content-length: 6 +Text-content-md5: cdcfb41554e2d092c13f5e6839e63577 +Content-length: 6 + +b +b +b + + +Revision-number: 8 +Prop-content-length: 114 +Content-length: 114 + +K 7 +svn:log +V 12 +move to old2 +K 10 +svn:author +V 7 +pmezard +K 8 +svn:date +V 27 +2008-12-06T12:48:04.150915Z +PROPS-END + +Node-path: branches/old2 +Node-kind: dir +Node-action: add +Node-copyfrom-rev: 7 +Node-copyfrom-path: branches/old + + +Node-path: branches/old +Node-action: delete + + +Revision-number: 9 +Prop-content-length: 118 +Content-length: 118 + +K 7 +svn:log +V 16 +move back to old +K 10 +svn:author +V 7 +pmezard +K 8 +svn:date +V 27 +2008-12-06T12:48:06.149560Z +PROPS-END + +Node-path: branches/old +Node-kind: dir +Node-action: add +Node-copyfrom-rev: 8 +Node-copyfrom-path: branches/old2 + + +Node-path: branches/old2 +Node-action: delete + + +Revision-number: 10 +Prop-content-length: 118 +Content-length: 118 + +K 7 +svn:log +V 16 +last change to a +K 10 +svn:author +V 7 +pmezard +K 8 +svn:date +V 27 +2008-12-06T12:48:07.268498Z +PROPS-END + +Node-path: trunk/a +Node-kind: file +Node-action: change +Text-content-length: 2 +Text-content-md5: 60b725f10c9c85c70d97880dfe8191b3 +Content-length: 2 + +a + + +Revision-number: 11 +Prop-content-length: 126 +Content-length: 126 + +K 7 +svn:log +V 24 +branch trunk@1 into old3 +K 10 +svn:author +V 7 +pmezard +K 8 +svn:date +V 27 +2008-12-06T12:48:09.151702Z +PROPS-END + +Node-path: branches/old3 +Node-kind: dir +Node-action: add +Node-copyfrom-rev: 1 +Node-copyfrom-path: trunk + + diff --git a/tests/svn/move.svndump b/tests/svn/move.svndump new file mode 100644 --- /dev/null +++ b/tests/svn/move.svndump @@ -0,0 +1,401 @@ +SVN-fs-dump-format-version: 2 + +UUID: 0682b859-320d-4a69-a164-a7cab5695072 + +Revision-number: 0 +Prop-content-length: 56 +Content-length: 56 + +K 8 +svn:date +V 27 +2008-12-06T13:33:36.768573Z +PROPS-END + +Revision-number: 1 +Prop-content-length: 112 +Content-length: 112 + +K 7 +svn:log +V 10 +init projA +K 10 +svn:author +V 7 +pmezard +K 8 +svn:date +V 27 +2008-12-06T13:33:37.083146Z +PROPS-END + +Node-path: trunk +Node-kind: dir +Node-action: add +Prop-content-length: 10 +Content-length: 10 + +PROPS-END + + +Node-path: trunk/a +Node-kind: file +Node-action: add +Prop-content-length: 10 +Text-content-length: 2 +Text-content-md5: 60b725f10c9c85c70d97880dfe8191b3 +Content-length: 12 + +PROPS-END +a + + +Node-path: trunk/d1 +Node-kind: dir +Node-action: add +Prop-content-length: 10 +Content-length: 10 + +PROPS-END + + +Node-path: trunk/d1/b +Node-kind: file +Node-action: add +Prop-content-length: 10 +Text-content-length: 2 +Text-content-md5: 3b5d5c3712955042212316173ccf37be +Content-length: 12 + +PROPS-END +b + + +Node-path: trunk/d1/c +Node-kind: file +Node-action: add +Prop-content-length: 10 +Text-content-length: 2 +Text-content-md5: 2cd6ee2c70b0bde53fbe6cac3c8b8bb1 +Content-length: 12 + +PROPS-END +c + + +Node-path: trunk/d2 +Node-kind: dir +Node-action: add +Prop-content-length: 10 +Content-length: 10 + +PROPS-END + + +Node-path: trunk/d2/d +Node-kind: file +Node-action: add +Prop-content-length: 10 +Text-content-length: 2 +Text-content-md5: e29311f6f1bf1af907f9ef9f44b8328b +Content-length: 12 + +PROPS-END +d + + +Revision-number: 2 +Prop-content-length: 118 +Content-length: 118 + +K 7 +svn:log +V 16 +commitbeforemove +K 10 +svn:author +V 7 +pmezard +K 8 +svn:date +V 27 +2008-12-06T13:33:38.152773Z +PROPS-END + +Node-path: trunk/a +Node-kind: file +Node-action: change +Text-content-length: 4 +Text-content-md5: 0d227f1abf8c2932d342e9b99cc957eb +Content-length: 4 + +a +a + + +Node-path: trunk/d1/c +Node-kind: file +Node-action: change +Text-content-length: 4 +Text-content-md5: 63fad9092ad37713ebe26b3193f89c41 +Content-length: 4 + +c +c + + +Revision-number: 3 +Prop-content-length: 112 +Content-length: 112 + +K 7 +svn:log +V 10 +movedtrunk +K 10 +svn:author +V 7 +pmezard +K 8 +svn:date +V 27 +2008-12-06T13:33:39.146388Z +PROPS-END + +Node-path: subproject +Node-kind: dir +Node-action: add +Node-copyfrom-rev: 2 +Node-copyfrom-path: trunk + + +Node-path: trunk +Node-action: delete + + +Revision-number: 4 +Prop-content-length: 113 +Content-length: 113 + +K 7 +svn:log +V 11 +createtrunk +K 10 +svn:author +V 7 +pmezard +K 8 +svn:date +V 27 +2008-12-06T13:33:40.179944Z +PROPS-END + +Node-path: subproject/trunk +Node-kind: dir +Node-action: add +Prop-content-length: 10 +Content-length: 10 + +PROPS-END + + +Revision-number: 5 +Prop-content-length: 116 +Content-length: 116 + +K 7 +svn:log +V 14 +createbranches +K 10 +svn:author +V 7 +pmezard +K 8 +svn:date +V 27 +2008-12-06T13:33:41.184505Z +PROPS-END + +Node-path: subproject/branches +Node-kind: dir +Node-action: add +Prop-content-length: 10 +Content-length: 10 + +PROPS-END + + +Revision-number: 6 +Prop-content-length: 107 +Content-length: 107 + +K 7 +svn:log +V 6 +moved1 +K 10 +svn:author +V 7 +pmezard +K 8 +svn:date +V 27 +2008-12-06T13:33:42.153312Z +PROPS-END + +Node-path: subproject/trunk/d1 +Node-kind: dir +Node-action: add +Node-copyfrom-rev: 5 +Node-copyfrom-path: subproject/d1 + + +Node-path: subproject/d1 +Node-action: delete + + +Revision-number: 7 +Prop-content-length: 107 +Content-length: 107 + +K 7 +svn:log +V 6 +moved2 +K 10 +svn:author +V 7 +pmezard +K 8 +svn:date +V 27 +2008-12-06T13:33:42.206313Z +PROPS-END + +Node-path: subproject/trunk/d2 +Node-kind: dir +Node-action: add +Node-copyfrom-rev: 6 +Node-copyfrom-path: subproject/d2 + + +Node-path: subproject/d2 +Node-action: delete + + +Revision-number: 8 +Prop-content-length: 119 +Content-length: 119 + +K 7 +svn:log +V 17 +changeb and rm d2 +K 10 +svn:author +V 7 +pmezard +K 8 +svn:date +V 27 +2008-12-06T13:33:43.182355Z +PROPS-END + +Node-path: subproject/trunk/d1/b +Node-kind: file +Node-action: change +Text-content-length: 4 +Text-content-md5: 06ac26ed8b614fc0b141e4542aa067c2 +Content-length: 4 + +b +b + + +Node-path: subproject/trunk/d2 +Node-action: delete + + +Revision-number: 9 +Prop-content-length: 113 +Content-length: 113 + +K 7 +svn:log +V 11 +moved1again +K 10 +svn:author +V 7 +pmezard +K 8 +svn:date +V 27 +2008-12-06T13:33:44.153682Z +PROPS-END + +Node-path: subproject/branches/d1 +Node-kind: dir +Node-action: add +Node-copyfrom-rev: 8 +Node-copyfrom-path: subproject/trunk/d1 + + +Node-path: subproject/trunk/d1 +Node-action: delete + + +Revision-number: 10 +Prop-content-length: 118 +Content-length: 118 + +K 7 +svn:log +V 16 +copyfilefrompast +K 10 +svn:author +V 7 +pmezard +K 8 +svn:date +V 27 +2008-12-06T13:33:44.298011Z +PROPS-END + +Node-path: subproject/trunk/d +Node-kind: file +Node-action: add +Node-copyfrom-rev: 7 +Node-copyfrom-path: subproject/trunk/d2/d +Text-copy-source-md5: e29311f6f1bf1af907f9ef9f44b8328b + + +Revision-number: 11 +Prop-content-length: 117 +Content-length: 117 + +K 7 +svn:log +V 15 +copydirfrompast +K 10 +svn:author +V 7 +pmezard +K 8 +svn:date +V 27 +2008-12-06T13:33:44.349920Z +PROPS-END + +Node-path: subproject/trunk/d2 +Node-kind: dir +Node-action: add +Node-copyfrom-rev: 7 +Node-copyfrom-path: subproject/trunk/d2 + + diff --git a/tests/svn/startrev.svndump b/tests/svn/startrev.svndump new file mode 100644 --- /dev/null +++ b/tests/svn/startrev.svndump @@ -0,0 +1,240 @@ +SVN-fs-dump-format-version: 2 + +UUID: c731c652-65e9-4325-a17e-fed96a319f22 + +Revision-number: 0 +Prop-content-length: 56 +Content-length: 56 + +K 8 +svn:date +V 27 +2008-12-06T13:44:21.642421Z +PROPS-END + +Revision-number: 1 +Prop-content-length: 112 +Content-length: 112 + +K 7 +svn:log +V 10 +init projA +K 10 +svn:author +V 7 +pmezard +K 8 +svn:date +V 27 +2008-12-06T13:44:21.759281Z +PROPS-END + +Node-path: branches +Node-kind: dir +Node-action: add +Prop-content-length: 10 +Content-length: 10 + +PROPS-END + + +Node-path: tags +Node-kind: dir +Node-action: add +Prop-content-length: 10 +Content-length: 10 + +PROPS-END + + +Node-path: trunk +Node-kind: dir +Node-action: add +Prop-content-length: 10 +Content-length: 10 + +PROPS-END + + +Revision-number: 2 +Prop-content-length: 109 +Content-length: 109 + +K 7 +svn:log +V 8 +createab +K 10 +svn:author +V 7 +pmezard +K 8 +svn:date +V 27 +2008-12-06T13:44:22.179257Z +PROPS-END + +Node-path: trunk/a +Node-kind: file +Node-action: add +Prop-content-length: 10 +Text-content-length: 2 +Text-content-md5: 60b725f10c9c85c70d97880dfe8191b3 +Content-length: 12 + +PROPS-END +a + + +Node-path: trunk/b +Node-kind: file +Node-action: add +Prop-content-length: 10 +Text-content-length: 2 +Text-content-md5: 3b5d5c3712955042212316173ccf37be +Content-length: 12 + +PROPS-END +b + + +Revision-number: 3 +Prop-content-length: 108 +Content-length: 108 + +K 7 +svn:log +V 7 +removeb +K 10 +svn:author +V 7 +pmezard +K 8 +svn:date +V 27 +2008-12-06T13:44:23.176546Z +PROPS-END + +Node-path: trunk/b +Node-action: delete + + +Revision-number: 4 +Prop-content-length: 109 +Content-length: 109 + +K 7 +svn:log +V 8 +changeaa +K 10 +svn:author +V 7 +pmezard +K 8 +svn:date +V 27 +2008-12-06T13:44:25.147151Z +PROPS-END + +Node-path: trunk/a +Node-kind: file +Node-action: change +Text-content-length: 4 +Text-content-md5: 0d227f1abf8c2932d342e9b99cc957eb +Content-length: 4 + +a +a + + +Revision-number: 5 +Prop-content-length: 119 +Content-length: 119 + +K 7 +svn:log +V 17 +branch, changeaaa +K 10 +svn:author +V 7 +pmezard +K 8 +svn:date +V 27 +2008-12-06T13:44:28.158475Z +PROPS-END + +Node-path: branches/branch1 +Node-kind: dir +Node-action: add +Node-copyfrom-rev: 4 +Node-copyfrom-path: trunk +Prop-content-length: 34 +Content-length: 34 + +K 13 +svn:mergeinfo +V 0 + +PROPS-END + + +Node-path: branches/branch1/a +Node-kind: file +Node-action: change +Text-content-length: 6 +Text-content-md5: 7d4ebf8f298d22fc349a91725b00af1c +Content-length: 6 + +a +a +a + + +Revision-number: 6 +Prop-content-length: 117 +Content-length: 117 + +K 7 +svn:log +V 15 +addc,changeaaaa +K 10 +svn:author +V 7 +pmezard +K 8 +svn:date +V 27 +2008-12-06T13:44:29.180655Z +PROPS-END + +Node-path: branches/branch1/a +Node-kind: file +Node-action: change +Text-content-length: 8 +Text-content-md5: d12178e74d8774e34361e0a08d1fd2b7 +Content-length: 8 + +a +a +a +a + + +Node-path: branches/branch1/c +Node-kind: file +Node-action: add +Prop-content-length: 10 +Text-content-length: 2 +Text-content-md5: 2cd6ee2c70b0bde53fbe6cac3c8b8bb1 +Content-length: 12 + +PROPS-END +c + + diff --git a/tests/svn/svndump-branches.sh b/tests/svn/svndump-branches.sh new file mode 100755 --- /dev/null +++ b/tests/svn/svndump-branches.sh @@ -0,0 +1,70 @@ +#!/bin/sh +# +# Use this script to generate branches.svndump +# + +mkdir temp +cd temp + +mkdir project-orig +cd project-orig +mkdir trunk +mkdir branches +mkdir tags +cd .. + +svnadmin create svn-repo +svnurl=file://`pwd`/svn-repo +svn import project-orig $svnurl -m "init projA" + +svn co $svnurl project +cd project +echo a > trunk/a +echo b > trunk/b +echo c > trunk/c +# Add a file within branches, used to confuse branch detection +echo d > branches/notinbranch +svn add trunk/a trunk/b trunk/c branches/notinbranch +svn ci -m hello + +# Branch to old +svn copy trunk branches/old +svn rm branches/old/c +svn ci -m "branch trunk, remove c" +svn up + +# Update trunk +echo a >> trunk/a +svn ci -m "change a" + +# Update old branch +echo b >> branches/old/b +svn ci -m "change b" + +# Create a cross-branch revision +svn move trunk/b branches/old/c +echo c >> branches/old/c +svn ci -m "move and update c" + +# Update old branch again +echo b >> branches/old/b +svn ci -m "change b again" + +# Move back and forth between branch of similar names +# This used to generate fake copy records +svn up +svn move branches/old branches/old2 +svn ci -m "move to old2" +svn move branches/old2 branches/old +svn ci -m "move back to old" + +# Update trunk again +echo a > trunk/a +svn ci -m "last change to a" + +# Branch again from a converted revision +svn copy -r 1 $svnurl/trunk branches/old3 +svn ci -m "branch trunk@1 into old3" +cd .. + +svnadmin dump svn-repo > ../branches.svndump diff --git a/tests/svn/svndump-move.sh b/tests/svn/svndump-move.sh new file mode 100755 --- /dev/null +++ b/tests/svn/svndump-move.sh @@ -0,0 +1,62 @@ +#!/bin/sh +# +# Use this script to generate move.svndump +# + +mkdir temp +cd temp + +mkdir project-orig +cd project-orig +mkdir trunk +echo a > trunk/a +mkdir trunk/d1 +mkdir trunk/d2 +echo b > trunk/d1/b +echo c > trunk/d1/c +echo d > trunk/d2/d +cd .. + +svnadmin create svn-repo +svnurl=file://`pwd`/svn-repo +svn import project-orig $svnurl -m "init projA" + +svn co $svnurl project +cd project +# Build a module renaming chain which used to confuse the converter. +# Update svn repository +echo a >> trunk/a +echo c >> trunk/d1/c +svn ci -m commitbeforemove +svn mv $svnurl/trunk $svnurl/subproject -m movedtrunk +svn up +mkdir subproject/trunk +svn add subproject/trunk +svn ci -m createtrunk +mkdir subproject/branches +svn add subproject/branches +svn ci -m createbranches +svn mv $svnurl/subproject/d1 $svnurl/subproject/trunk/d1 -m moved1 +svn mv $svnurl/subproject/d2 $svnurl/subproject/trunk/d2 -m moved2 +svn up +echo b >> subproject/trunk/d1/b + +svn rm subproject/trunk/d2 +svn ci -m "changeb and rm d2" +svn mv $svnurl/subproject/trunk/d1 $svnurl/subproject/branches/d1 -m moved1again + +if svn help copy | grep 'SRC\[@REV\]' > /dev/null 2>&1; then + # SVN >= 1.5 replaced the -r REV syntax with @REV + # Copy a file from a past revision + svn copy $svnurl/subproject/trunk/d2/d@7 $svnurl/subproject/trunk -m copyfilefrompast + # Copy a directory from a past revision + svn copy $svnurl/subproject/trunk/d2@7 $svnurl/subproject/trunk -m copydirfrompast +else + # Copy a file from a past revision + svn copy -r 7 $svnurl/subproject/trunk/d2/d $svnurl/subproject/trunk -m copyfilefrompast + # Copy a directory from a past revision + svn copy -r 7 $svnurl/subproject/trunk/d2 $svnurl/subproject/trunk -m copydirfrompast +fi +cd .. + +svnadmin dump svn-repo > ../move.svndump \ No newline at end of file diff --git a/tests/svn/svndump-startrev.sh b/tests/svn/svndump-startrev.sh new file mode 100755 --- /dev/null +++ b/tests/svn/svndump-startrev.sh @@ -0,0 +1,45 @@ +#!/bin/sh +# +# Use this script to generate startrev.svndump +# + +mkdir temp +cd temp + +mkdir project-orig +cd project-orig +mkdir trunk +mkdir branches +mkdir tags +cd .. + +svnadmin create svn-repo +svnurl=file://`pwd`/svn-repo +svn import project-orig $svnurl -m "init projA" + +svn co $svnurl project +cd project +echo a > trunk/a +echo b > trunk/b +svn add trunk/a trunk/b +svn ci -m createab +svn rm trunk/b +svn ci -m removeb +svn up +echo a >> trunk/a +svn ci -m changeaa + +# Branch +svn up +svn copy trunk branches/branch1 +echo a >> branches/branch1/a +svn ci -m "branch, changeaaa" + +echo a >> branches/branch1/a +echo c > branches/branch1/c +svn add branches/branch1/c +svn ci -m "addc,changeaaaa" +svn up +cd .. + +svnadmin dump svn-repo > ../startrev.svndump \ No newline at end of file diff --git a/tests/svn/svndump-tags.sh b/tests/svn/svndump-tags.sh new file mode 100755 --- /dev/null +++ b/tests/svn/svndump-tags.sh @@ -0,0 +1,49 @@ +#!/bin/sh +# +# Use this script to generate tags.svndump +# + +mkdir temp +cd temp + +mkdir project-orig +cd project-orig +mkdir trunk +mkdir branches +mkdir tags +mkdir unrelated +cd .. + +svnadmin create svn-repo +svnurl=file://`pwd`/svn-repo +svn import project-orig $svnurl -m "init projA" + +svn co $svnurl project +cd project +echo a > trunk/a +svn add trunk/a +svn ci -m adda +echo a >> trunk/a +svn ci -m changea +echo a >> trunk/a +svn ci -m changea2 +# Add an unrelated commit to test that tags are bound to the +# correct "from" revision and not a dummy one +echo a >> unrelated/dummy +svn add unrelated/dummy +svn ci -m unrelatedchange +# Tag current revision +svn up +svn copy trunk tags/trunk.v1 +svn copy trunk tags/trunk.badtag +svn ci -m "tagging trunk.v1 trunk.badtag" +echo a >> trunk/a +svn ci -m changea3 +# Fix the bad tag +# trunk.badtag should not show in converted tags +svn up +svn mv tags/trunk.badtag tags/trunk.goodtag +svn ci -m "fix trunk.badtag" +cd .. + +svnadmin dump svn-repo > ../tags.svndump \ No newline at end of file diff --git a/tests/svn/tags.svndump b/tests/svn/tags.svndump new file mode 100644 --- /dev/null +++ b/tests/svn/tags.svndump @@ -0,0 +1,295 @@ +SVN-fs-dump-format-version: 2 + +UUID: 65371b91-a2cf-4cb1-a047-08b28c3b4c40 + +Revision-number: 0 +Prop-content-length: 56 +Content-length: 56 + +K 8 +svn:date +V 27 +2008-12-06T13:50:23.869747Z +PROPS-END + +Revision-number: 1 +Prop-content-length: 112 +Content-length: 112 + +K 7 +svn:log +V 10 +init projA +K 10 +svn:author +V 7 +pmezard +K 8 +svn:date +V 27 +2008-12-06T13:50:23.944361Z +PROPS-END + +Node-path: branches +Node-kind: dir +Node-action: add +Prop-content-length: 10 +Content-length: 10 + +PROPS-END + + +Node-path: tags +Node-kind: dir +Node-action: add +Prop-content-length: 10 +Content-length: 10 + +PROPS-END + + +Node-path: trunk +Node-kind: dir +Node-action: add +Prop-content-length: 10 +Content-length: 10 + +PROPS-END + + +Node-path: unrelated +Node-kind: dir +Node-action: add +Prop-content-length: 10 +Content-length: 10 + +PROPS-END + + +Revision-number: 2 +Prop-content-length: 105 +Content-length: 105 + +K 7 +svn:log +V 4 +adda +K 10 +svn:author +V 7 +pmezard +K 8 +svn:date +V 27 +2008-12-06T13:50:25.174397Z +PROPS-END + +Node-path: trunk/a +Node-kind: file +Node-action: add +Prop-content-length: 10 +Text-content-length: 2 +Text-content-md5: 60b725f10c9c85c70d97880dfe8191b3 +Content-length: 12 + +PROPS-END +a + + +Revision-number: 3 +Prop-content-length: 108 +Content-length: 108 + +K 7 +svn:log +V 7 +changea +K 10 +svn:author +V 7 +pmezard +K 8 +svn:date +V 27 +2008-12-06T13:50:26.148468Z +PROPS-END + +Node-path: trunk/a +Node-kind: file +Node-action: change +Text-content-length: 4 +Text-content-md5: 0d227f1abf8c2932d342e9b99cc957eb +Content-length: 4 + +a +a + + +Revision-number: 4 +Prop-content-length: 109 +Content-length: 109 + +K 7 +svn:log +V 8 +changea2 +K 10 +svn:author +V 7 +pmezard +K 8 +svn:date +V 27 +2008-12-06T13:50:27.147988Z +PROPS-END + +Node-path: trunk/a +Node-kind: file +Node-action: change +Text-content-length: 6 +Text-content-md5: 7d4ebf8f298d22fc349a91725b00af1c +Content-length: 6 + +a +a +a + + +Revision-number: 5 +Prop-content-length: 117 +Content-length: 117 + +K 7 +svn:log +V 15 +unrelatedchange +K 10 +svn:author +V 7 +pmezard +K 8 +svn:date +V 27 +2008-12-06T13:50:28.174989Z +PROPS-END + +Node-path: unrelated/dummy +Node-kind: file +Node-action: add +Prop-content-length: 10 +Text-content-length: 2 +Text-content-md5: 60b725f10c9c85c70d97880dfe8191b3 +Content-length: 12 + +PROPS-END +a + + +Revision-number: 6 +Prop-content-length: 131 +Content-length: 131 + +K 7 +svn:log +V 29 +tagging trunk.v1 trunk.badtag +K 10 +svn:author +V 7 +pmezard +K 8 +svn:date +V 27 +2008-12-06T13:50:32.157783Z +PROPS-END + +Node-path: tags/trunk.badtag +Node-kind: dir +Node-action: add +Node-copyfrom-rev: 5 +Node-copyfrom-path: trunk +Prop-content-length: 34 +Content-length: 34 + +K 13 +svn:mergeinfo +V 0 + +PROPS-END + + +Node-path: tags/trunk.v1 +Node-kind: dir +Node-action: add +Node-copyfrom-rev: 5 +Node-copyfrom-path: trunk +Prop-content-length: 34 +Content-length: 34 + +K 13 +svn:mergeinfo +V 0 + +PROPS-END + + +Revision-number: 7 +Prop-content-length: 109 +Content-length: 109 + +K 7 +svn:log +V 8 +changea3 +K 10 +svn:author +V 7 +pmezard +K 8 +svn:date +V 27 +2008-12-06T13:50:33.145803Z +PROPS-END + +Node-path: trunk/a +Node-kind: file +Node-action: change +Text-content-length: 8 +Text-content-md5: d12178e74d8774e34361e0a08d1fd2b7 +Content-length: 8 + +a +a +a +a + + +Revision-number: 8 +Prop-content-length: 118 +Content-length: 118 + +K 7 +svn:log +V 16 +fix trunk.badtag +K 10 +svn:author +V 7 +pmezard +K 8 +svn:date +V 27 +2008-12-06T13:50:36.153842Z +PROPS-END + +Node-path: tags/trunk.goodtag +Node-kind: dir +Node-action: add +Node-copyfrom-rev: 7 +Node-copyfrom-path: tags/trunk.badtag + + +Node-path: tags/trunk.badtag +Node-action: delete + + diff --git a/tests/test-convert-svn-branches b/tests/test-convert-svn-branches --- a/tests/test-convert-svn-branches +++ b/tests/test-convert-svn-branches @@ -12,6 +12,7 @@ echo "convert = " >> $HGRCPATH echo "hgext.graphlog =" >> $HGRCPATH svnadmin create svn-repo +cat "$TESTDIR/svn/branches.svndump" | svnadmin load svn-repo > /dev/null svnpath=`pwd | fix_path` # SVN wants all paths to start with a slash. Unfortunately, @@ -20,73 +21,10 @@ expr $svnpath : "\/" > /dev/null if [ $? -ne 0 ]; then svnpath='/'$svnpath fi - -echo % initial svn import -mkdir projA -cd projA -mkdir trunk -mkdir branches -mkdir tags -cd .. - -svnurl=file://$svnpath/svn-repo/projA -svn import -m "init projA" projA $svnurl | fix_path - -echo % update svn repository -svn co $svnurl A | fix_path -cd A -echo a > trunk/a -echo b > trunk/b -echo c > trunk/c -# Add a file within branches, used to confuse branch detection -echo d > branches/notinbranch -svn add trunk/a trunk/b trunk/c branches/notinbranch -svn ci -m hello - -echo % branch to old -svn copy trunk branches/old -svn rm branches/old/c -svn ci -m "branch trunk, remove c" -svn up - -echo % update trunk -"$TESTDIR/svn-safe-append.py" a trunk/a -svn ci -m "change a" - -echo % update old branch -"$TESTDIR/svn-safe-append.py" b branches/old/b -svn ci -m "change b" - -echo % create a cross-branch revision -svn move trunk/b branches/old/c -"$TESTDIR/svn-safe-append.py" c branches/old/c -svn ci -m "move and update c" - -echo % update old branch again -"$TESTDIR/svn-safe-append.py" b branches/old/b -svn ci -m "change b again" - -echo % move back and forth between branch of similar names -# This used to generate fake copy records -svn up -svn move branches/old branches/old2 -svn ci -m "move to old2" -svn move branches/old2 branches/old -svn ci -m "move back to old" - -echo % update trunk again -"$TESTDIR/svn-safe-append.py" a trunk/a -svn ci -m "last change to a" -cd .. +svnurl=file://$svnpath/svn-repo echo % convert trunk and branches -hg convert --datesort $svnurl A-hg - -echo % branch again from a converted revision -cd A -svn copy -r 1 $svnurl/trunk branches/old3 -svn ci -m "branch trunk@1 into old3" -cd .. +hg convert --datesort -r 10 $svnurl A-hg echo % convert again hg convert --datesort $svnurl A-hg diff --git a/tests/test-convert-svn-branches.out b/tests/test-convert-svn-branches.out --- a/tests/test-convert-svn-branches.out +++ b/tests/test-convert-svn-branches.out @@ -1,77 +1,3 @@ -% initial svn import -Adding projA/trunk -Adding projA/branches -Adding projA/tags - -Committed revision 1. -% update svn repository -A A/trunk -A A/branches -A A/tags -Checked out revision 1. -A trunk/a -A trunk/b -A trunk/c -A branches/notinbranch -Adding branches/notinbranch -Adding trunk/a -Adding trunk/b -Adding trunk/c -Transmitting file data .... -Committed revision 2. -% branch to old -A branches/old -D branches/old/c -Adding branches/old -Adding branches/old/a -Adding branches/old/b -Deleting branches/old/c - -Committed revision 3. -At revision 3. -% update trunk -Sending trunk/a -Transmitting file data . -Committed revision 4. -% update old branch -Sending branches/old/b -Transmitting file data . -Committed revision 5. -% create a cross-branch revision -A branches/old/c -D trunk/b -Adding branches/old/c -Deleting trunk/b -Transmitting file data . -Committed revision 6. -% update old branch again -Sending branches/old/b -Transmitting file data . -Committed revision 7. -% move back and forth between branch of similar names -At revision 7. -A branches/old2 -D branches/old/a -D branches/old/b -D branches/old/c -D branches/old -Deleting branches/old -Adding branches/old2 - -Committed revision 8. -A branches/old -D branches/old2/a -D branches/old2/b -D branches/old2/c -D branches/old2 -Adding branches/old -Deleting branches/old2 - -Committed revision 9. -% update trunk again -Sending trunk/a -Transmitting file data . -Committed revision 10. % convert trunk and branches initializing destination A-hg repository scanning source... @@ -88,12 +14,6 @@ 3 change b again 2 move to old2 1 move back to old 0 last change to a -% branch again from a converted revision -Checked out revision 1. -A branches/old3 -Adding branches/old3 - -Committed revision 11. % convert again scanning source... sorting... @@ -117,8 +37,8 @@ o branch=old3 11 branch trunk@1 into ol | | | | o | branch= 3 change a files: a | | | -| | o branch=old 2 branch trunk, remove c files: -| |/ ++---o branch=old 2 branch trunk, remove c files: a b +| | | o branch= 1 hello files: a b c |/ o branch= 0 init projA files: diff --git a/tests/test-convert-svn-move b/tests/test-convert-svn-move --- a/tests/test-convert-svn-move +++ b/tests/test-convert-svn-move @@ -12,6 +12,7 @@ echo "convert = " >> $HGRCPATH echo "hgext.graphlog =" >> $HGRCPATH svnadmin create svn-repo +cat "$TESTDIR/svn/move.svndump" | svnadmin load svn-repo > /dev/null svnpath=`pwd | fix_path` # SVN wants all paths to start with a slash. Unfortunately, @@ -20,58 +21,7 @@ expr $svnpath : "\/" > /dev/null if [ $? -ne 0 ]; then svnpath='/'$svnpath fi - -echo % initial svn import -mkdir projA -cd projA -mkdir trunk -echo a > trunk/a -mkdir trunk/d1 -mkdir trunk/d2 -echo b > trunk/d1/b -echo c > trunk/d1/c -echo d > trunk/d2/d -cd .. - -svnurl=file://$svnpath/svn-repo/projA -svn import -m "init projA" projA $svnurl | fix_path - -# Build a module renaming chain which used to confuse the converter. -echo % update svn repository -svn co $svnurl A | fix_path -cd A -"$TESTDIR/svn-safe-append.py" a trunk/a -"$TESTDIR/svn-safe-append.py" c trunk/d1/c -svn ci -m commitbeforemove -svn mv $svnurl/trunk $svnurl/subproject -m movedtrunk -svn up -mkdir subproject/trunk -svn add subproject/trunk -svn ci -m createtrunk -mkdir subproject/branches -svn add subproject/branches -svn ci -m createbranches -svn mv $svnurl/subproject/d1 $svnurl/subproject/trunk/d1 -m moved1 -svn mv $svnurl/subproject/d2 $svnurl/subproject/trunk/d2 -m moved2 -svn up -"$TESTDIR/svn-safe-append.py" b subproject/trunk/d1/b -svn rm subproject/trunk/d2 -svn ci -m "changeb and rm d2" -svn mv $svnurl/subproject/trunk/d1 $svnurl/subproject/branches/d1 -m moved1again - -if svn help copy | grep 'SRC\[@REV\]' > /dev/null 2>&1; then - # SVN >= 1.5 replaced the -r REV syntax with @REV - echo % copy a file from a past revision - svn copy $svnurl/subproject/trunk/d2/d@7 $svnurl/subproject/trunk -m copyfilefrompast - echo % copy a directory from a past revision - svn copy $svnurl/subproject/trunk/d2@7 $svnurl/subproject/trunk -m copydirfrompast -else - echo % copy a file from a past revision - svn copy -r 7 $svnurl/subproject/trunk/d2/d $svnurl/subproject/trunk -m copyfilefrompast - echo % copy a directory from a past revision - svn copy -r 7 $svnurl/subproject/trunk/d2 $svnurl/subproject/trunk -m copydirfrompast -fi -cd .. +svnurl=file://$svnpath/svn-repo echo % convert trunk and branches hg convert --datesort $svnurl/subproject A-hg diff --git a/tests/test-convert-svn-move.out b/tests/test-convert-svn-move.out --- a/tests/test-convert-svn-move.out +++ b/tests/test-convert-svn-move.out @@ -1,71 +1,3 @@ -% initial svn import -Adding projA/trunk -Adding projA/trunk/a -Adding projA/trunk/d1 -Adding projA/trunk/d1/b -Adding projA/trunk/d1/c -Adding projA/trunk/d2 -Adding projA/trunk/d2/d - -Committed revision 1. -% update svn repository -A A/trunk -A A/trunk/a -A A/trunk/d1 -A A/trunk/d1/b -A A/trunk/d1/c -A A/trunk/d2 -A A/trunk/d2/d -Checked out revision 1. -Sending trunk/a -Sending trunk/d1/c -Transmitting file data .. -Committed revision 2. - -Committed revision 3. -D trunk -A subproject -A subproject/a -A subproject/d1 -A subproject/d1/b -A subproject/d1/c -A subproject/d2 -A subproject/d2/d -Updated to revision 3. -A subproject/trunk -Adding subproject/trunk - -Committed revision 4. -A subproject/branches -Adding subproject/branches - -Committed revision 5. - -Committed revision 6. - -Committed revision 7. -A subproject/trunk/d1 -A subproject/trunk/d1/b -A subproject/trunk/d1/c -A subproject/trunk/d2 -A subproject/trunk/d2/d -D subproject/d1 -D subproject/d2 -Updated to revision 7. -D subproject/trunk/d2/d -D subproject/trunk/d2 -Sending subproject/trunk/d1/b -Deleting subproject/trunk/d2 -Transmitting file data . -Committed revision 8. - -Committed revision 9. -% copy a file from a past revision - -Committed revision 10. -% copy a directory from a past revision - -Committed revision 11. % convert trunk and branches initializing destination A-hg repository scanning source... diff --git a/tests/test-convert-svn-startrev b/tests/test-convert-svn-startrev --- a/tests/test-convert-svn-startrev +++ b/tests/test-convert-svn-startrev @@ -12,6 +12,7 @@ echo "convert = " >> $HGRCPATH echo "hgext.graphlog =" >> $HGRCPATH svnadmin create svn-repo +cat "$TESTDIR/svn/startrev.svndump" | svnadmin load svn-repo > /dev/null svnpath=`pwd | fix_path` # SVN wants all paths to start with a slash. Unfortunately, @@ -20,43 +21,7 @@ expr $svnpath : "\/" > /dev/null if [ $? -ne 0 ]; then svnpath='/'$svnpath fi - -echo % initial svn import -mkdir projA -cd projA -mkdir trunk -mkdir branches -mkdir tags -cd .. - -svnurl=file://$svnpath/svn-repo/projA -svn import -m "init projA" projA $svnurl | fix_path - -echo % update svn repository -svn co $svnurl A | fix_path -cd A -echo a > trunk/a -echo b > trunk/b -svn add trunk/a trunk/b -svn ci -m createab -svn rm trunk/b -svn ci -m removeb -svn up -"$TESTDIR/svn-safe-append.py" a trunk/a -svn ci -m changeaa - -echo % branch -svn up -svn copy trunk branches/branch1 -"$TESTDIR/svn-safe-append.py" a branches/branch1/a -svn ci -m "branch, changeaaa" - -"$TESTDIR/svn-safe-append.py" a branches/branch1/a -echo c > branches/branch1/c -svn add branches/branch1/c -svn ci -m "addc,changeaaaa" -svn up -cd .. +svnurl=file://$svnpath/svn-repo convert() { diff --git a/tests/test-convert-svn-startrev.out b/tests/test-convert-svn-startrev.out --- a/tests/test-convert-svn-startrev.out +++ b/tests/test-convert-svn-startrev.out @@ -1,41 +1,3 @@ -% initial svn import -Adding projA/trunk -Adding projA/branches -Adding projA/tags - -Committed revision 1. -% update svn repository -A A/trunk -A A/branches -A A/tags -Checked out revision 1. -A trunk/a -A trunk/b -Adding trunk/a -Adding trunk/b -Transmitting file data .. -Committed revision 2. -D trunk/b -Deleting trunk/b - -Committed revision 3. -At revision 3. -Sending trunk/a -Transmitting file data . -Committed revision 4. -% branch -At revision 4. -A branches/branch1 -Adding branches/branch1 -Sending branches/branch1/a -Transmitting file data . -Committed revision 5. -A branches/branch1/c -Sending branches/branch1/a -Adding branches/branch1/c -Transmitting file data .. -Committed revision 6. -At revision 6. % convert before branching point initializing destination A-r3-hg repository scanning source... diff --git a/tests/test-convert-svn-tags b/tests/test-convert-svn-tags --- a/tests/test-convert-svn-tags +++ b/tests/test-convert-svn-tags @@ -12,6 +12,7 @@ echo "convert = " >> $HGRCPATH echo "hgext.graphlog =" >> $HGRCPATH svnadmin create svn-repo +cat "$TESTDIR/svn/tags.svndump" | svnadmin load svn-repo > /dev/null svnpath=`pwd | fix_path` # SVN wants all paths to start with a slash. Unfortunately, @@ -20,47 +21,7 @@ expr $svnpath : "\/" > /dev/null if [ $? -ne 0 ]; then svnpath='/'$svnpath fi - -echo % initial svn import -mkdir projA -cd projA -mkdir trunk -mkdir branches -mkdir tags -mkdir unrelated -cd .. - -svnurl=file://$svnpath/svn-repo/projA -svn import -m "init projA" projA $svnurl | fix_path | sort - -echo % update svn repository -svn co $svnurl A | fix_path -cd A -echo a > trunk/a -svn add trunk/a -svn ci -m adda -"$TESTDIR/svn-safe-append.py" a trunk/a -svn ci -m changea -"$TESTDIR/svn-safe-append.py" a trunk/a -svn ci -m changea2 -# Add an unrelated commit to test that tags are bound to the -# correct "from" revision and not a dummy one -"$TESTDIR/svn-safe-append.py" a unrelated/dummy -svn add unrelated/dummy -svn ci -m unrelatedchange -echo % tag current revision -svn up -svn copy trunk tags/trunk.v1 -svn copy trunk tags/trunk.badtag -svn ci -m "tagging trunk.v1 trunk.badtag" -"$TESTDIR/svn-safe-append.py" a trunk/a -svn ci -m changea3 -echo % fix the bad tag -# trunk.badtag should not show in converted tags -svn up -svn mv tags/trunk.badtag tags/trunk.goodtag -svn ci -m "fix trunk.badtag" -cd .. +svnurl=file://$svnpath/svn-repo echo % convert hg convert --datesort $svnurl A-hg diff --git a/tests/test-convert-svn-tags.out b/tests/test-convert-svn-tags.out --- a/tests/test-convert-svn-tags.out +++ b/tests/test-convert-svn-tags.out @@ -1,50 +1,3 @@ -% initial svn import - -Adding projA/branches -Adding projA/tags -Adding projA/trunk -Adding projA/unrelated -Committed revision 1. -% update svn repository -A A/trunk -A A/unrelated -A A/branches -A A/tags -Checked out revision 1. -A trunk/a -Adding trunk/a -Transmitting file data . -Committed revision 2. -Sending trunk/a -Transmitting file data . -Committed revision 3. -Sending trunk/a -Transmitting file data . -Committed revision 4. -A unrelated/dummy -Adding unrelated/dummy -Transmitting file data . -Committed revision 5. -% tag current revision -At revision 5. -A tags/trunk.v1 -A tags/trunk.badtag -Adding tags/trunk.badtag -Adding tags/trunk.v1 - -Committed revision 6. -Sending trunk/a -Transmitting file data . -Committed revision 7. -% fix the bad tag -At revision 7. -A tags/trunk.goodtag -D tags/trunk.badtag/a -D tags/trunk.badtag -Deleting tags/trunk.badtag -Adding tags/trunk.goodtag - -Committed revision 8. % convert initializing destination A-hg repository scanning source...