Mercurial > hgsubversion
changeset 474:63cb630d667d
tags: handle the most recent commit being an edit to an svn tag properly
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Sat, 18 Jul 2009 22:30:59 -0500 |
parents | 45df4d9320fa |
children | 15443c592f7a |
files | hgsubversion/svncommands.py hgsubversion/svnmeta.py tests/fixtures/most-recent-is-edit-tag.sh tests/fixtures/most-recent-is-edit-tag.svndump tests/test_rebuildmeta.py tests/test_tags.py |
diffstat | 6 files changed, 305 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/hgsubversion/svncommands.py +++ b/hgsubversion/svncommands.py @@ -27,7 +27,7 @@ def verify(ui, repo, *args, **opts): srev = int(srev.split('@')[1]) ui.write('verifying %s against r%i\n' % (ctx, srev)) - + url = repo.ui.expandpath('default') if args: url = args[0] @@ -176,9 +176,14 @@ def rebuildmeta(ui, repo, hg_repo_path, branchinfo[branch] = (parentbranch, noderevnums.get(parent.node(), 0), revision) - + droprev = lambda x: x.rsplit('@', 1)[0] for cctx in ctx.children(): - if cctx.extra().get('close'): + # check if a child of this change closes this branch + # that's true if the close flag is set and the svn revision + # path is the same. droprev removes the revnumber so we + # can verify it is the same branch easily + if (cctx.extra().get('close') + and droprev(cctx.extra().get('convert_revision', '@')) == droprev(convinfo)): branchinfo.pop(branch, None) break
--- a/hgsubversion/svnmeta.py +++ b/hgsubversion/svnmeta.py @@ -418,6 +418,8 @@ class SVNMeta(object): self.branches.update(tbdelta['branches'][0]) def movetag(self, tag, hash, branch, rev, date): + if self.tags[tag] == hash: + return if branch == 'default': branch = None parentctx = self.repo[self.get_parent_revision(rev.revnum+1, branch)]
copy from tests/fixtures/unusual_tags.sh copy to tests/fixtures/most-recent-is-edit-tag.sh --- a/tests/fixtures/unusual_tags.sh +++ b/tests/fixtures/most-recent-is-edit-tag.sh @@ -27,16 +27,15 @@ svn add iota svn ci -m 'branch changes' cd ../.. svn up -svn cp branches/dev_branch tags/versions/branch_version -svn ci -m 'Make a tag in tags/versions from branches/dev_branch' -svn up -svn cp trunk tags/blah/trunktag -svn ci -m 'Make a tag in tags/blah from trunk' +svn cp branches/dev_branch tags/some-tag +svn ci -m 'Make a tag.' svn up +echo foo > tags/some-tag/alpha +svn ci -m 'edit that tag' cd ../.. -svnadmin dump temp/repo > unusual_tags.svndump +svnadmin dump temp/repo > most-recent-is-edit-tag.svndump echo echo 'Complete.' echo 'You probably want to clean up temp now.' -echo 'Dump in unusual_tags.svndump' +echo 'Dump in most-recent-is-edit-tag.svndump' exit 0
new file mode 100644 --- /dev/null +++ b/tests/fixtures/most-recent-is-edit-tag.svndump @@ -0,0 +1,265 @@ +SVN-fs-dump-format-version: 2 + +UUID: 65efcde9-3b35-4f89-9c6b-23da1cf93d9b + +Revision-number: 0 +Prop-content-length: 56 +Content-length: 56 + +K 8 +svn:date +V 27 +2009-07-19T03:04:55.657240Z +PROPS-END + +Revision-number: 1 +Prop-content-length: 102 +Content-length: 102 + +K 7 +svn:log +V 3 +btt +K 10 +svn:author +V 5 +durin +K 8 +svn:date +V 27 +2009-07-19T03:04:56.082834Z +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: tags/blah +Node-kind: dir +Node-action: add +Prop-content-length: 10 +Content-length: 10 + +PROPS-END + + +Node-path: tags/versions +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: 110 +Content-length: 110 + +K 7 +svn:log +V 10 +Add files. +K 10 +svn:author +V 5 +durin +K 8 +svn:date +V 27 +2009-07-19T03:04:57.109656Z +PROPS-END + +Node-path: trunk/alpha +Node-kind: file +Node-action: add +Prop-content-length: 10 +Text-content-length: 6 +Text-content-md5: 9f9f90dbe3e5ee1218c86b8839db1995 +Content-length: 16 + +PROPS-END +alpha + + +Node-path: trunk/beta +Node-kind: file +Node-action: add +Prop-content-length: 10 +Text-content-length: 5 +Text-content-md5: f0cf2a92516045024a0c99147b28f05b +Content-length: 15 + +PROPS-END +beta + + +Node-path: trunk/delta +Node-kind: file +Node-action: add +Prop-content-length: 10 +Text-content-length: 6 +Text-content-md5: d2840cc81bc032bd1141b56687d0f93c +Content-length: 16 + +PROPS-END +delta + + +Node-path: trunk/gamma +Node-kind: file +Node-action: add +Prop-content-length: 10 +Text-content-length: 6 +Text-content-md5: 303febb9068384eca46b5b6516843b35 +Content-length: 16 + +PROPS-END +gamma + + +Revision-number: 3 +Prop-content-length: 105 +Content-length: 105 + +K 7 +svn:log +V 6 +branch +K 10 +svn:author +V 5 +durin +K 8 +svn:date +V 27 +2009-07-19T03:05:00.048169Z +PROPS-END + +Node-path: branches/dev_branch +Node-kind: dir +Node-action: add +Node-copyfrom-rev: 2 +Node-copyfrom-path: trunk + + +Revision-number: 4 +Prop-content-length: 114 +Content-length: 114 + +K 7 +svn:log +V 14 +branch changes +K 10 +svn:author +V 5 +durin +K 8 +svn:date +V 27 +2009-07-19T03:05:01.081946Z +PROPS-END + +Node-path: branches/dev_branch/alpha +Node-kind: file +Node-action: change +Text-content-length: 5 +Text-content-md5: 5e723ed52db2000686425ca28bc5ba4a +Content-length: 5 + +narf + + +Node-path: branches/dev_branch/iota +Node-kind: file +Node-action: add +Prop-content-length: 10 +Text-content-length: 5 +Text-content-md5: ebcf3971120220589f1dfbf8d56e25b9 +Content-length: 15 + +PROPS-END +iota + + +Node-path: branches/dev_branch/delta +Node-action: delete + + +Revision-number: 5 +Prop-content-length: 111 +Content-length: 111 + +K 7 +svn:log +V 11 +Make a tag. +K 10 +svn:author +V 5 +durin +K 8 +svn:date +V 27 +2009-07-19T03:05:04.056268Z +PROPS-END + +Node-path: tags/some-tag +Node-kind: dir +Node-action: add +Node-copyfrom-rev: 4 +Node-copyfrom-path: branches/dev_branch + + +Revision-number: 6 +Prop-content-length: 113 +Content-length: 113 + +K 7 +svn:log +V 13 +edit that tag +K 10 +svn:author +V 5 +durin +K 8 +svn:date +V 27 +2009-07-19T03:05:06.057723Z +PROPS-END + +Node-path: tags/some-tag/alpha +Node-kind: file +Node-action: change +Text-content-length: 4 +Text-content-md5: d3b07384d113edec49eaa6238ad5ff00 +Content-length: 4 + +foo + +
--- a/tests/test_rebuildmeta.py +++ b/tests/test_rebuildmeta.py @@ -34,7 +34,7 @@ def _do_case(self, name, stupid): self.assertTrue(os.path.isfile(dtf), '%r is missing!' % tf) old, new = open(stf).read(), open(dtf).read() # uncomment next line for easy-ish debugging. - os.system('diff -u %s %s' % (stf, dtf)) + # os.system('diff -u %s %s' % (stf, dtf)) self.assertEqual(old, new) self.assertEqual(src.branchtags(), dest.branchtags()) srcbi = pickle.load(open(os.path.join(src.path, 'svn', 'branch_info')))
--- a/tests/test_tags.py +++ b/tests/test_tags.py @@ -8,6 +8,7 @@ from mercurial import ui import test_util +from hgsubversion import svncommands from hgsubversion import svnrepo class TestTags(test_util.TestBase): @@ -88,6 +89,28 @@ class TestTags(test_util.TestBase): 'versions/branch_version': 'I\x89\x1c>z#\xfc._K#@:\xd6\x1f\x96\xd6\x83\x1b|', }) + def test_most_recent_is_edited_stupid(self): + self.test_most_recent_is_edited(True) + + def test_most_recent_is_edited(self, stupid=False): + repo = self._load_fixture_and_fetch('most-recent-is-edit-tag.svndump', + stupid=stupid) + self.repo.ui.status( + "Note: this test failing may be because of a rebuildmeta failure.\n" + "You should check that before assuming issues with this test.\n") + wc2_path = self.wc_path + '2' + src, dest = hg.clone(repo.ui, self.wc_path, wc2_path, update=False) + svncommands.rebuildmeta(repo.ui, + dest, + os.path.dirname(dest.path), + args=[test_util.fileurl(self.repo_path), ]) + commands.pull(self.repo.ui, self.repo, stupid=stupid) + dtags, srctags = dest.tags(), self.repo.tags() + dtags.pop('tip') + srctags.pop('tip') + self.assertEqual(dtags, srctags) + self.assertEqual(dest.heads(), self.repo.heads()) + def test_edited_tag_stupid(self): self.test_edited_tag(True)