changeset 547:9e6499c415a9

tags: fix files edited during tag creation This was broken because file edits were skipped if they were in tags, but committags in svnmeta didn't check to see if any files were changed during initial tag creation.
author Augie Fackler <durin42@gmail.com>
date Sat, 06 Feb 2010 10:36:21 -0600
parents d84116dda52d
children 2148eb4b4da4
files hgsubversion/replay.py hgsubversion/stupid.py hgsubversion/svnmeta.py tests/fixtures/commit-to-tag.sh tests/fixtures/commit-to-tag.svndump tests/test_tags.py
diffstat 6 files changed, 55 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/hgsubversion/replay.py
+++ b/hgsubversion/replay.py
@@ -118,9 +118,10 @@ def convert_rev(ui, meta, svn, r, tbdelt
             # New regular tag without modifications, it will be committed by
             # svnmeta.committag(), we can skip the whole branch for now
             tag = meta.get_path_tag(meta.remotename(branch))
-            if (tag and tag not in meta.tags and
-                branch not in meta.branches
-                and branch not in meta.repo.branchtags()):
+            if (tag and tag not in meta.tags
+                and branch not in meta.branches
+                and branch not in meta.repo.branchtags()
+                and not files):
                 continue
 
         parentctx = meta.repo.changectx(parents[0])
@@ -176,6 +177,7 @@ def convert_rev(ui, meta, svn, r, tbdelt
             meta.revmap[rev.revnum, branch] = new_hash
         if tag:
             meta.movetag(tag, new_hash, parentctx.extra().get('branch', None), rev, date)
+            meta.addedtags.pop(tag, None)
 
     # 2. handle branches that need to be committed without any files
     for branch in current.emptybranches:
--- a/hgsubversion/stupid.py
+++ b/hgsubversion/stupid.py
@@ -553,7 +553,8 @@ def convert_rev(ui, meta, svn, r, tbdelt
 
     deleted_branches = {}
     for p in r.paths:
-        if meta.get_path_tag(p):
+        tag = meta.get_path_tag(p)
+        if tag and tag not in meta.tags:
             continue
         branch = meta.localname(p)
         if not (r.paths[p].action == 'R' and branch in meta.branches):
@@ -613,7 +614,8 @@ def convert_rev(ui, meta, svn, r, tbdelt
             # svnmeta.committag(), we can skip the whole branch for now
             if (tag and tag not in meta.tags and
                 b not in meta.branches
-                and b not in meta.repo.branchtags()):
+                and b not in meta.repo.branchtags()
+                and not files_touched):
                 continue
 
         if parentctx.node() == node.nullid and not files_touched:
@@ -653,6 +655,7 @@ def convert_rev(ui, meta, svn, r, tbdelt
             meta.revmap[r.revnum, b] = ha
         else:
             meta.movetag(tag, ha, parentctx.extra().get('branch', None), r, date)
+            meta.addedtags.pop(tag, None)
         util.describe_commit(ui, ha, b)
 
     # These are branches with an 'R' status in svn log. This means they were
--- a/hgsubversion/svnmeta.py
+++ b/hgsubversion/svnmeta.py
@@ -510,7 +510,7 @@ class SVNMeta(object):
         self.branches.update(tbdelta['branches'][0])
 
     def movetag(self, tag, hash, branch, rev, date):
-        if self.tags[tag] == hash:
+        if tag in self.tags and self.tags[tag] == hash:
             return
         if branch == 'default':
             branch = None
--- a/tests/fixtures/commit-to-tag.sh
+++ b/tests/fixtures/commit-to-tag.sh
@@ -64,6 +64,11 @@ svn up
 svn merge -r9:8 $REPOPATH .
 svn ci -m 'Revert revision 9.'
 
+# make a tag from a branch and edit it at the same time
+svn up
+svn cp branches/magic tags/edit-at-create
+echo alpha >> tags/edit-at-create/alpha
+svn ci -m 'make a tag from a branch and edit it at the same time'
 
 cd ../..
 svnadmin dump temp/repo > commit-to-tag.svndump
--- a/tests/fixtures/commit-to-tag.svndump
+++ b/tests/fixtures/commit-to-tag.svndump
@@ -563,3 +563,38 @@ Node-action: add
 Node-copyfrom-rev: 8
 Node-copyfrom-path: tags/will-edit/alpha
 Text-copy-source-md5: 9f9f90dbe3e5ee1218c86b8839db1995
+
+Revision-number: 20
+Prop-content-length: 153
+Content-length: 153
+
+K 7
+svn:log
+V 53
+make a tag from a branch and edit it at the same time
+K 10
+svn:author
+V 5
+augie
+K 8
+svn:date
+V 27
+2010-02-06T13:31:13.153406Z
+PROPS-END
+
+Node-path: tags/edit-at-create
+Node-kind: dir
+Node-action: add
+Node-copyfrom-rev: 19
+Node-copyfrom-path: branches/magic
+
+
+Node-path: tags/edit-at-create/alpha
+Node-kind: file
+Node-action: change
+Text-content-length: 12
+Text-content-md5: 7b77a55a273801087b943dfbe257f4db
+Content-length: 12
+
+alpha
+alpha
--- a/tests/test_tags.py
+++ b/tests/test_tags.py
@@ -131,7 +131,8 @@ rename a tag
     def test_edited_tag(self, stupid=False):
        repo = self._load_fixture_and_fetch('commit-to-tag.svndump',
                                            stupid=stupid)
-       self.assertEqual(len(repo.heads()), 5)
+       headcount = 6
+       self.assertEqual(len(repo.heads()), headcount)
        heads = repo.heads()
        openheads = [h for h in heads if not repo[h].extra().get('close', False)]
        closedheads = set(heads) - set(openheads)
@@ -146,7 +147,7 @@ rename a tag
 
        self.assertEqual(1, len(self.repo.branchheads('magic')))
 
-       alsoedit, editlater, closeme, willedit, = closedheads
+       alsoedit, editlater, closeme, willedit, editcreate, = closedheads
        self.assertEqual(
            repo[willedit].extra(),
            {'close': '1',
@@ -180,6 +181,7 @@ rename a tag
            {'close': '1',
             'branch': 'closeme',
             'convert_revision': 'svn:af82cc90-c2d2-43cd-b1aa-c8a78449440a/branches/closeme@17'})
+       self.assertEqual('alpha\nalpha\n', repo['edit-at-create']['alpha'].data())
 
     def test_tags_in_unusual_location(self):
         repo = self._load_fixture_and_fetch('tag_name_same_as_branch.svndump')