Madan U Sreenivasan wrote:
> Another question I have been wanting to ask(I have not thought this
> through): Isn't handling svnmerge-blocked necessary here?
I think you're right. Block has its own "unblock" command, so there are
two options:
1) Have uninit remove the blocked property as well as the merge property.
2) Have uninit error out, telling the user that there are blocked revisions
and that unblock must therefore be executed first.
The advantage of 1 is that it is more intuitive and easier, and that it
can be done in one commit (without using --force on uninit). The advantage
of 2 is that it forces the user to understand the ramifications of what
they are doing as well as bettor mirroring the init/block commands.
I am +1 on option 1 (with appropriate documentation in the uninit help).
I have attached patch v4 with Daniel's and Madan's latest comments, plus
option 1 implemented above.
Log message:
Add the uninit command, which removes merge tracking information for a given
head URL, including blocked revision information. This is especially useful
if multiple heads are being tracked -- without uninit, this situation requires
the new property value to be manually set by the user via svn propset.
* svnmerge.py: Added uninit to command table.
(action_uninit): New method for uninitialization of merge tracking info.
* svnmerge_test.py
(TestCase_TestRepo.testUninit): New test case, checking that uninit works.
(TestCase_TestRepo.testUninitForce): New test case.
(TestCase_TestRepo.getproperty): Prevent array index errors when
retrieving a property with no value.
(TestCase_TestRepo.getBlockedProperty): New method to get the value
of the svnmerge blocked property.
Patch by: Raman Gupta <[EMAIL PROTECTED]>
Review by: Daniel Rall <[EMAIL PROTECTED]>
Madan U Sreenivasan <[EMAIL PROTECTED]>
Giovanni Bajo <[EMAIL PROTECTED]>
Cheers,
Raman
Index: svnmerge_test.py
===================================================================
--- svnmerge_test.py (revision 19635)
+++ svnmerge_test.py (working copy)
@@ -463,8 +463,18 @@
def getproperty(self):
out = svnmerge.launch("svn pg %s ." % svnmerge.opts["prop"])
- return out[0].strip()
+ if len(out) == 0:
+ return None
+ else:
+ return out[0].strip()
+ def getBlockedProperty(self):
+ out = svnmerge.launch("svn pg %s ." % svnmerge.opts["block-prop"])
+ if len(out) == 0:
+ return None
+ else:
+ return out[0].strip()
+
def testNoWc(self):
os.mkdir("foo")
os.chdir("foo")
@@ -569,6 +579,105 @@
p = self.getproperty()
self.assertEqual("/trunk:1-6", p)
+ def testUninit(self):
+ """Test that uninit works, for both merged and blocked revisions."""
+ os.chdir("..")
+ self.launch("svn co %(TEST_REPO_URL)s/branches/testYYY-branch testYYY-branch")
+
+ os.chdir("trunk")
+ # Not using switch, so must update to get latest repository rev.
+ self.launch("svn update", match=r"At revision 13")
+ self.svnmerge2(["init", self.test_repo_url + "/branches/test-branch"])
+ self.launch("svn commit -F svnmerge-commit-message.txt",
+ match=r"Committed revision 14")
+
+ self.svnmerge2(["init", self.test_repo_url + "/branches/testYYY-branch"])
+ self.launch("svn commit -F svnmerge-commit-message.txt",
+ match=r"Committed revision 15")
+
+ # Create changes on test-branch that we can block
+ os.chdir("..")
+ os.chdir("test-branch")
+ # Not using switch, so must update to get latest repository rev.
+ self.launch("svn update", match=r"At revision 15")
+
+ open("test1", "w").write("test 1-changed_on_test-branch")
+
+ self.launch("svn commit -m \"Change to test1 on test-branch\"",
+ match=r"Committed revision 16")
+
+ # Create changes on testYYY-branch that we can block
+ os.chdir("..")
+ os.chdir("testYYY-branch")
+ # Not using switch, so must update to get latest repository rev.
+ self.launch("svn update", match=r"At revision 16")
+
+ open("test2", "w").write("test 2-changed_on_testYYY-branch")
+
+ self.launch("svn commit -m \"Change to test2 on testYYY-branch\"",
+ match=r"Committed revision 17")
+
+ # Block changes from both branches on the trunk
+ os.chdir("..")
+ os.chdir("trunk")
+ # Not using switch, so must update to get latest repository rev.
+ self.launch("svn update", match=r"At revision 17")
+ self.svnmerge("block -S testYYY-branch", match=r"'svnmerge-blocked' set")
+ self.launch("svn commit -F svnmerge-commit-message.txt",
+ match=r"Committed revision 18")
+
+ self.svnmerge("block -S test-branch", match=r"'svnmerge-blocked' set")
+ self.launch("svn commit -F svnmerge-commit-message.txt",
+ match=r"Committed revision 19")
+
+ # Do the uninit
+ self.svnmerge2(["uninit", "--source", self.test_repo_url + "/branches/testYYY-branch"])
+
+ # Check that the merged property for testYYY-branch was removed, but
+ # not for test-branch
+ pmerged = self.getproperty()
+ self.assertEqual("/branches/test-branch:1-13", pmerged)
+
+ # Check that the blocked property for testYYY-branch was removed, but
+ # not for test-branch
+ pblocked = self.getBlockedProperty()
+ self.assertEqual("/branches/test-branch:16", pblocked)
+
+ self.launch("svn commit -F svnmerge-commit-message.txt",
+ match=r"Committed revision 20")
+
+ self.svnmerge2(["uninit", "--source", self.test_repo_url + "/branches/test-branch"])
+
+ # Check that the merged and blocked properties for test-branch have been removed too
+ pmerged = self.getproperty()
+ self.assertEqual(None, pmerged)
+
+ pblocked = self.getBlockedProperty()
+ self.assertEqual(None, pblocked)
+
+ def testUninitForce(self):
+ self.svnmerge2(["init", self.test_repo_url + "/branches/test-branch"])
+
+ self.launch("svn commit -F svnmerge-commit-message.txt",
+ match=r"Committed revision")
+
+ self.svnmerge2(["init", self.test_repo_url + "/branches/testYYY-branch"])
+
+ self.launch("svn commit -F svnmerge-commit-message.txt",
+ match=r"Committed revision")
+
+ p = self.getproperty()
+ self.assertEqual("/branches/test-branch:1-13 /branches/testYYY-branch:1-14", p)
+
+ open("test1", "a").write("foo")
+
+ self.svnmerge("uninit --source " + self.test_repo_url + "/branches/testYYY-branch",
+ error=True, match=r"clean")
+
+ self.svnmerge("uninit -F --source " + self.test_repo_url + "/branches/testYYY-branch")
+ p = self.getproperty()
+ self.assertEqual("/branches/test-branch:1-13", p)
+
def testCheckInitializeEverything(self):
self.svnmerge2(["init", self.test_repo_url + "/trunk"])
p = self.getproperty()
Index: svnmerge.py
===================================================================
--- svnmerge.py (revision 19635)
+++ svnmerge.py (working copy)
@@ -1208,7 +1208,33 @@
f.close()
report('wrote commit message to "%s"' % opts["commit-file"])
+def action_uninit(branch_dir, branch_props):
+ """Uninit HEAD URL."""
+ # Check branch directory is ready for being modified
+ check_dir_clean(branch_dir)
+ # If the head-path does not have an entry in the svnmerge-integrated
+ # property, simply error out.
+ if not branch_props.has_key(opts["head-path"]):
+ error('"%s" does not contain merge tracking information for "%s"' \
+ % (opts["head-path"], branch_dir))
+
+ del branch_props[opts["head-path"]]
+
+ # Set merge property with the selected head deleted
+ set_merge_props(branch_dir, branch_props)
+
+ # Set blocked revisions for the selected head to None
+ set_blocked_revs(branch_dir, opts["head-path"], None)
+
+ # Write out commit message if desired
+ if opts["commit-file"]:
+ f = open(opts["commit-file"], "w")
+ print >>f, 'Removed merge tracking for "%s" for ' % NAME
+ print >>f, '%s' % opts["head-url"]
+ f.close()
+ report('wrote commit message to "%s"' % opts["commit-file"])
+
###############################################################################
# Command line parsing -- options and commands management
###############################################################################
@@ -1659,6 +1685,14 @@
[
"-f", "-r", "-S", # import common opts
]),
+
+ "uninit": (action_uninit,
+ "uninit [OPTION...] [HEAD]",
+ """Remove merge tracking information, including blocked revisions, for
+ HEAD on the current working directory.""",
+ [
+ "-f", "-S", # import common opts
+ ]),
}
_______________________________________________
Svnmerge mailing list
[email protected]
http://www.orcaware.com/mailman/listinfo/svnmerge