[Svnmerge] [PATCH] Add ability to mark change sets as merged

Daniel Rall dlr at collab.net
Fri Mar 24 16:58:29 PST 2006


This is effectively a way to manipulate the merge memory stored in the
"svnmerge-integrated" property.  It's the flip-side of the 'block'
concept.

Use case: A change set which is sufficiently different when backported
that use of 'svn merge' is no longer appropriate.  Example scenarios:

   o The actual change you want to apply to branch has no overlap with
   its incarnation on the source branch, yet is conceptually
   equivalent.

  o Only a subset of a change set warrants application.

  o The branch content has drifted far enough apart to make automatic
  merging impossible.

Typical usage is paired with manually-issued, targeted 'svn merge'
and/or 'svn diff' commands, stand-alone 'diff' and 'patch', and/or
manual edits to the target branch.
-- 

Daniel Rall


p.s. On a related note, I've got 'svnmerge.py rollback [--memory]'
stubbed out too.

Incidently, these changes are to implement the "Record Manual Merge"
and "Rollback Merge" requirements mentioned in Subversion's Merge
Tracking Requirements doc
<http://subversion.tigris.org/merge-tracking/requirements.html>
-------------- next part --------------
Add the ability to mark change sets as merged, effectively a way to
manipulate the merge memory stored in the "svnmerge-integrated"
property.  This is the flip-side of the 'block' concept.


* contrib/client-side/svnmerge.py
  (action_merge): When the "--memory" argument is specified, avoid
   executing the 'svn merge' command, and adjust output accordingly.

  (common_opts): Add a new "-M"/"--memory" Option.

  (command_table): Add support for "-M" to "merge", and expand help to
   cover it.


* contrib/client-side/svnmerge_test.py
  (test_merge_memory): New test method for 'svnmerge.py merge --memory'.
-------------- next part --------------
Index: contrib/client-side/svnmerge_test.py
===================================================================
--- contrib/client-side/svnmerge_test.py	(revision 19024)
+++ contrib/client-side/svnmerge_test.py	(working copy)
@@ -521,6 +521,15 @@
         self.svnmerge("merge -F -vv -r8-9", match=r"svn log.*-r8:9")
         self.svnmerge("avail -vv -r2", nonmatch=r"svn log")
 
+    def test_merge_memory(self):
+        """Check that flagging revisions as manually merged works."""
+        self.svnmerge("init")
+        self.svnmerge("avail -vv -r9", match=r"svn log.*-r9:9")
+        self.svnmerge("merge --memory -F -vv -r9",
+                      nonmatch=r"svn merge -r 8:9")
+        out = self.svnmerge("avail -r9")
+        self.assertEqual(out.strip(), "")
+
     def testBidirectionalMerges(self):
         """Check that reflected revisions are recognized properly for bidirectional merges."""
 
Index: contrib/client-side/svnmerge.py
===================================================================
--- contrib/client-side/svnmerge.py	(revision 19024)
+++ contrib/client-side/svnmerge.py	(working copy)
@@ -979,8 +979,18 @@
     if not revs:
         report('no revisions to merge, exiting')
         return
-    report('merging in revision(s) %s from "%s"' % (revs, opts["head_url"]))
 
+    # When manually marking change sets as merged, we only update the
+    # integration meta data, and don't perform an actual merge.
+    memory_only = opts["memory"]
+
+    if memory_only:
+        report('recording merge of revision(s) %s from "%s"' %
+               (revs, opts["head_url"]))
+    else:
+        report('merging in revision(s) %s from "%s"' %
+               (revs, opts["head_url"]))
+
     # Do the merge(s). Note: the starting revision number to 'svn merge'
     # is NOT inclusive so we have to subtract one from start.
     # We try to keep the number of merge operations as low as possible,
@@ -995,15 +1005,20 @@
               set_merge_props(branch_dir, new_merge_props)
               old_merge_props = new_merge_props
 
-        # Do the merge
-        svn_command('merge -r %d:%d %s %s' % \
-                    (start-1, end, opts["head_url"], branch_dir))
+        if not memory_only:
+            # Do the merge
+            svn_command("merge -r %d:%d %s %s" % \
+                        (start - 1, end, opts["head_url"], branch_dir))
 
     # Write out commit message if desired
     if opts["commit_file"]:
         f = open(opts["commit_file"], "w")
-        print >>f, 'Merged revisions %s via %s from ' % \
-                    (revs | phantom_revs, NAME)
+        if memory_only:
+            print >>f, 'Recorded merge of revisions %s via %s from ' % \
+                  (revs | phantom_revs, NAME)
+        else:
+            print >>f, 'Merged revisions %s via %s from ' % \
+                  (revs | phantom_revs, NAME)
         print >>f, '%s' % opts["head_url"]
         if opts["commit_verbose"]:
             print >>f
@@ -1392,6 +1407,10 @@
               default="svnmerge-commit-message.txt",
               help="set the name of the file where the suggested log message "
                    "is written to"),
+    Option("-M", "--memory",
+           value=True,
+           default=False,
+           help="affect merge memory meta data only, e.g. not file contents"),
     OptionArg("-r", "--revision",
               metavar="REVLIST",
               default="",
@@ -1474,9 +1493,14 @@
     to appear as available to merged into the branch (as the code
     originated in the branch itself!).  svnmerge can skip these
     so-called "reflected" revisions if you specify the --bidirectional
-    or -b command line option.""",
+    or -b command line option.
+
+    When manually merging changes, svnmerge can be used to to record
+    memory of merges via the --memory or -m command line option.  This
+    differs from 'block' operations in that a change will be reported
+    as merged into the target branch.""",
     [
-        "-b", "-f", "-r", "-S", # import common opts
+        "-b", "-f", "-r", "-S", "-M", # import common opts
     ]),
 
     "block": (action_block,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : /pipermail/svnmerge/attachments/20060324/33167412/attachment.pgp 


More information about the Svnmerge mailing list