Title: [PATCH][SVNMERGE] Make get_default_head() more generic(get_heads()).

This is a preparatory step for 'svnmerge log'.


[[[
Make the get_default_head() function more generic.

* contrib/client-side/svnmerge.py
  (get_default_head): Removed.
  (get_heads): New function similar to get_default_head(), but can return
  all the available head values. Also takes an extra parameter
  `get_only_default'. If `get_only_default' is True, expect only one
  head (error out if not), and return it. If `get_only_default' is
  False, return all the available heads as a list.
  (main): Modify call of get_default_head() to get_heads().
]]]

Index: contrib/client-side/svnmerge.py
===================================================================
--- contrib/client-side/svnmerge.py     (revision 19320)
+++ contrib/client-side/svnmerge.py     (working copy)
@@ -749,9 +749,10 @@
     messages.append('')
     return longest_sep.join(messages)
 
-def get_default_head(branch_dir, branch_props):
-    """Return the default head for branch_dir (given its branch_props). Error
-    out if there is ambiguity."""
+def get_heads(branch_dir, branch_props, get_only_default=False):
+    """Return all the heads for branch_dir (given its branch_props). If
+    the get_only_default parameter is True, expect only one head (error
+    out if there is ambiguity) and return it."""
     if not branch_props:
         error("no integration info available")
 
@@ -764,11 +765,17 @@
     if props.has_key(directory):
         del props[directory]
 
-    if len(props) > 1:
+    if get_only_default and len(props) > 1:
         error('multiple heads found. '
               'Explicit head argument (-S/--head) required.')
 
-    return props.keys()[0]
+    # Is this correct? Return a list/string depending on the
+    # value of get_only_default. I think the return value of
+    # any function should always be of the same type.
+    if get_only_default:
+        return props.keys()[0]
+    else:
+        return props.keys()
 
 def check_old_prop_version(branch_dir, props):
     """Check if props (of branch_dir) are svnmerge properties in old format,
@@ -1683,7 +1690,7 @@
             if not opts["revision"]:
                 opts["revision"] = "1-" + cf_rev
         else:
-            opts["head-path"] = get_default_head(branch_dir, branch_props)
+            opts["head-path"] = get_heads(branch_dir, branch_props, True)
 
         assert opts["head-path"][0] == '/'
         opts["head-url"] = get_repo_root(branch_dir) + opts["head-path"]
Make the get_default_head() function more generic.

* contrib/client-side/svnmerge.py
  (get_default_head): Removed.
  (get_heads): New function similar to get_default_head(), but can return
  all the available head values. Also takes an extra parameter
  `get_only_default'. If `get_only_default' is True, expect only one
  head (error out if not), and return it. If `get_only_default' is
  False, return all the available heads as a list.
  (main): Modify call of get_default_head() to get_heads().
_______________________________________________
Svnmerge mailing list
[email protected]
http://www.orcaware.com/mailman/listinfo/svnmerge

Reply via email to