[Svnmerge] Better support of automatic revision determination for 'init' command

Larry Streepy larry at lightspeed.com
Mon Dec 18 13:00:20 PST 2006


I couldn't find a "search" function for the email archive, so I browsed 
several months of messages and didn't find anything relevant to this, so I 
decided to post it.  I'm sorry if this has been discussed in the past.

I've been studying svnmerge.py and getting a handle on it and it seems to 
support a model where "trunk" changes are merged into a branch with ease 
(no requirement for the user to determine which revisions are included in 
the init command).  However, the reverse (merging from the branch back to 
the truck) seems to require additional work by the user.

I'd like to propose a change, and I'm sure I'll be quickly told if I'm in 
the weeds :-)

I've got a patch (probably not optimal with my current knowledge level of 
the code), that better supports the 'init' command when the current 
directory is the trunk and the "source" being specified is a branch off of 
the trunk (or current working directory).  So, assume that the current 
working directory is a checkout of the HEAD revision of the trunk.

Currently, the documentation says I need to use a command like this to init 
the trunk:

     svnmerge.py init -r1-XXX <url-to-branch>

It would seem to me that a simple check to see if the <url-to-branch> is a 
branch of the current working directory would allow one to determine the -r 
settings automatically.

Here's a simple patch that accomplishes that.  I'd like to get some 
feedback on the approach, and if I've missed some big picture thingy that 
makes this impractical/wrong in any way.

Thanks,
Larry.


--- /tmp/client-side/svnmerge.py.orig   2006-12-18 14:09:29.000000000 -0600
+++ /tmp/client-side/svnmerge.py        2006-12-18 14:57:56.000000000 -0600
@@ -1020,6 +1020,22 @@
      # Check branch directory is ready for being modified
      check_dir_clean(branch_dir)

+    # If the user hasn't specified the revisions to use,
+    # see if the "source" is a branch from the current tree
+    # and if so, we can use the version data obtained
+    # from it.
+    if not opts["revision"]:
+        cf_source, cf_rev = get_copyfrom(opts["source-url"])
+        branch_path = target_to_repos_relative_path(branch_dir)
+
+        # If the branch_path is the source path of "source",
+        # then "source" was branched from the current working tree
+        # and we can use the revisions determined by get_copyfrom
+
+        if branch_path == cf_source:
+            report("SOURCE is branch of current tree")
+            opts["revision"] = "1-" + cf_rev
+
      # Get the initial revision set if not explicitly specified.
      revs = opts["revision"] or "1-" + get_latest_rev(opts["source-url"])
      revs = RevisionSet(revs)



More information about the Svnmerge mailing list