------------------------------------------------------------------------
r19630 | giovannibajo | 2006-05-12 19:10:59 +0200 (ven, 12 mag 2006) | 26
lines

Accept unambiguous substrings of a repository-relative path as head
arguments.

When merging across multiple branches, it is often necessary to specify on
which of the multiple heads the operation must be performed (through
-S/--head). Until today, this parameter accepted either a working copy
directory or a full URL. This is unfortunate since the user really only
wants
to specify one of a few possible heads.

This patch makes svnmerge accepts unambiguous substrings (of any length) of
one of the repository-relative paths recorded as head. For instance, it is
now possible to say: "svnmerge.py avail -S trunk".

Notice that this does not help in the case of "svnmerge.py init", because
you will probably need to specify a new head (as a full URL), not a
previously
initialized one.

 * contrib/client-side/svnmerge.py:
   (main): Check if the head argument is a unambiguous substring of one the
   paths in the branch properties.
   (command_opts, OptionArg("-S")): modify the help string to specify that
   a substring is allowed.

 * contrib/client-side/svnmerge_test.py:
   (TestCase_TestRepo.testBidirectionalMergesMultiBranch): Use substrings
   for head parameters so to check the new feature.

------------------------------------------------------------------------

-- 
Giovanni Bajo
Index: svnmerge_test.py
===================================================================
--- svnmerge_test.py    (revision 19624)
+++ svnmerge_test.py    (working copy)
@@ -720,12 +720,12 @@
         self.launch("svn update", match=r"At revision 19")
 
         # Merge into trunk
-        self.svnmerge("merge -vv --head ../test-branch2",
+        self.svnmerge("merge -vv --head branch2",
                       match=r"merge -r 18:19")
         p = self.getproperty()
         self.assertEqual("/branches/test-branch:1-16 
/branches/test-branch2:1-19", p)
 
-        self.svnmerge("integrated --head ../test-branch2", match=r"^14-19$")
+        self.svnmerge("integrated --head branch2", match=r"^14-19$")
         self.svnmerge("integrated --head ../test-branch", match=r"^13-16$")
 
         self.launch("svn commit -F svnmerge-commit-message.txt",
Index: svnmerge.py
===================================================================
--- svnmerge.py (revision 19627)
+++ svnmerge.py (working copy)
@@ -1532,9 +1532,11 @@
                    'and ranges separated by commas, e.g., "534,537-539,540"'),
     OptionArg("-S", "--head", "--source",
               default=None,
-              help="specify the head for this branch. It can be either a path "
-                   "or an URL. Needed only to disambiguate in case of "
-                   "multiple merge tracking (merging from multiple heads)"),
+              help="specify the head for this branch. It can be either a path,"
+                   " a full URL, or an unambigous substring of one the paths "
+                   "for which merge tracking was already initialized. Needed "
+                   "only to disambiguate in case of multiple merge tracking "
+                   "(merging from multiple heads)"),
 ]
 
 command_table = {
@@ -1725,7 +1727,18 @@
         # trailing /'s.
         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 if it is a substring of a repo-relative URL recorded
+            # within the branch properties.
+            found = []
+            for rlpath in branch_props.keys():
+                if rlpath.find(head) > 0:
+                    found.append(rlpath)
+            if len(found) == 1:
+                head = get_repo_root(branch_dir) + found[0]
+            else:
+                error('"%s" is neither a valid URL (or an unambiguous '
+                      'substring), nor a working directory' % head)
+
         opts["head-url"] = target_to_url(head)
         opts["head-path"] = target_to_rlpath(head)
 
_______________________________________________
Svnmerge mailing list
[email protected]
http://www.orcaware.com/mailman/listinfo/svnmerge

Reply via email to