[[[
Make sure that the current working copy and the working copy
dir (if PATH) provided by the head parameter belong to the same
repository.
* contrib/client-side/svnmerge.py
(wc_of_same_repos): New function. Given two working copy dirs,
read the entries file, and make sure that both of them belong
to the same repository.
(main): Add check to make sure that the provided head parameter
and the branch dir are working copies and belong to the same
repository.
]]]
Index: contrib/client-side/svnmerge.py
===================================================================
--- contrib/client-side/svnmerge.py (revision 19186)
+++ contrib/client-side/svnmerge.py (working copy)
@@ -630,6 +630,51 @@
return os.path.isdir(os.path.join(dir, ".svn")) or \
os.path.isdir(os.path.join(dir, "_svn"))
+def wc_of_same_repos(branch_dir, head):
+ """Check if the branch_dir and head dir belong
+ to the same repository.
+ Return False, even if either of the provided dirs
+ is not a working copy."""
+
+ # read the branch_dir entries file
+ if os.path.isdir(os.path.join(branch_dir, ".svn")):
+ _svn_dir = ".svn"
+ elif os.path.isdir(os.path.join(branch_dir, "_svn")):
+ _svn_dir = "_svn"
+ else:
+ # is not a working copy
+ return False
+
+ branch_dir_entries = open(os.path.join( \
+ branch_dir,_svn_dir,"entries"),"r").readlines()
+
+ # read the head dir entries file
+ if os.path.isdir(os.path.join(head, ".svn")):
+ _svn_dir = ".svn"
+ elif os.path.isdir(os.path.join(head, "_svn")):
+ _svn_dir = "_svn"
+ else:
+ # is not a working copy
+ return False
+
+ head_entries = open(os.path.join( \
+ head,_svn_dir,"entries"),"r").readlines()
+
+ # join list of lines into one searchable line
+ branch_dir_entries = "".join(branch_dir_entries)
+ head_entries = "".join(head_entries)
+
+ # extract the value of the 'repos' key
+ repos_re = re.compile(".*repos\=\"(.*?)\".*", re.DOTALL)
+ branch_repos = repos_re.findall(branch_dir_entries)[0]
+ head_repos = repos_re.findall(head_entries)[0]
+
+ # return True if the repos keys are identical
+ if branch_repos == head_repos:
+ return True
+
+ return False
+
_cache_svninfo = {}
def get_svninfo(path):
"""Extract the subversion information for a path (through 'svn info').
@@ -1679,6 +1724,11 @@
head = rstrip(head, "/")
if not is_wc(head) and not is_url(head):
error('"%s" is not a valid URL or working directory' % head)
+ # check to see if the head specific belongs to the same repos
+ if is_wc(head) and not wc_of_same_repos(branch_dir, head):
+ err_msg = '"%s" and "%s"' % (head, branch_dir)
+ err_msg += 'are working copies of different repositories'
+ error(err_msg)
opts["head-url"] = target_to_url(head)
opts["head-path"] = url_to_rlpath(opts["head-url"])
Make sure that the current working copy and the working copy dir (if PATH) provided by the head parameter belong to the same repository.
* contrib/client-side/svnmerge.py (wc_of_same_repos): New function. Given two working copy dirs, read the entries file, and make sure that both of them belong to the same repository. (main): Add check to make sure that the provided head parameter and the branch dir are working copies and belong to the same repository.
_______________________________________________ Svnmerge mailing list [email protected] http://www.orcaware.com/mailman/listinfo/svnmerge
