[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Merge info display

From: Paul Burba <ptburba_at_gmail.com>
Date: Fri, 30 Sep 2011 12:46:03 -0400

On Fri, Sep 30, 2011 at 7:24 AM, Julian Foad <julian.foad_at_wandisco.com> wrote:
> I've been thinking about a bunch of issues related to merging and how to
> help users to avoid some of the common pitfalls.  One subset of my
> thoughts is on how we can present information about merges in a more
> user-friendly high-level way so that each time a user runs "svn merge"
> or "svn mergeinfo" they get feedback that relates to their high-level
> idea of what should be happening, and thus helps them to see at a glance
> whether they issued the right command for what they wanted to achieve.
> So I'm mocking up stuff like this (some data faked):
>  $ cd 1.6.x
>  $ svn mergeinfo $BRANCHES_URL/1.6.x-r878590
>  Source branch: ^/subversion/branches/1.6.x-r878590 (r1177182)
>  Target branch: ^/subversion/branches/1.6.x (wc)
>  Source and target are marked as branches of the same project.
>  Merged revision ranges:
>    START-1104299,1104304,1104333-END
>  Merged operative revisions:
>    1104267,1104304,1104336,1104339,1104346
> and this:
>  $ svn mergeinfo $BRANCHES_URL/1.6.x
>  Source branch: ^/subversion/branches/1.6.x (r1177182)
>  Target branch: ^/subversion/branches/1.6.x (wc)
>  svn: E195016: Source and target are the same branch
> and this:
>  $ svn mergeinfo
>  Assuming source branch is copied-from source of target branch.
>  Source branch: ^/subversion/trunk (r875961)
>  Target branch: ^/subversion/branches/1.6.x (wc)
>  [...]
> I'm making a branch to try out ideas like these.
> I'm writing down my thoughts in this public document
> <https://docs.google.com/a/wandisco.com/document/d/1nrU3IkP8Q1NbFgH1ou0w3N6QkghbJv6AnK8wlnPAgC0/edit?hl=en_GB>; see especially under the "Reporting ..." section headings.

Hi Julian,

So as to keep my thoughts on the medium of record, I'm pasting my
comments on your doc here, rather than as comments in google docs :

(Which raises a question, why aren't we keeping these notes in our own

> Guiding Users into Simple and Safe Merging
> Aim
> Make it much harder to merge the “Wrong Way” by accident.
> Identify the typical merging tasks, which may vary depending on the
> requirements of the user’s team. Make the typical merging tasks easy
> to perform; look at TortoiseSVN and other existing GUIs for examples.
> Clearly distinguish tasks that have different meanings but may
> currently have similar or identical syntax, to reduce the risk of a
> user performing a merge that produces the desired output now but will
> adversely affect future merges. Make it harder to accidentally
> specify merges that are unusual and not well supported.
> Implement these measures by building onto Subversion’s existing
> library API, command-line UI, client-server interface and/or any other
> suitable level. If this requires knowledge of the user’s branching
> model and rules, provide a simple way to configure this and provide
> one or more typical configurations.
> A pre-requisite for designing and implementing such guidance is a
> clear statement of what merging scenarios Subversion supports. See
> the document Supported Merge Scenarios.
> Pitfalls & Quick Fixes
> The aim here is to list things that users might do in Subversion that
> are not Right — that is, things that will not lead to consistent and
> useful results in merging later on — that could be avoided by some
> high-level checks or by better informing the user.
> Using branch naming terminology from the ‘Terminology’ section below.
> On a dev

You need to define a 'dev' branch in your terminology section.
Assuming you mean "feature" branch.

> branch, attempting to merge to parent without
> “--reintegrate” is wrong, (except perhaps for a cherry-pick, and that
> would be unusual). Catch this case. Possibly with hook script? Need
> awareness of what kind of branch ‘this’ is.

Awareness of "branch-roots" might be as, or more, useful or at least a
first step to identifying branch type.

> Catch other cases from the ‘Branching and Merging Policy’ section below.
> On any branch, a reverse-merge of a merge in this branch’s own
> history will not do what we expect, I think. The correct (better?) way
> to roll back a merge is to reverse-merge the original changes from the
> source branch.

A couple advantages to simply reverse merging from the branch's own history:

1) Avoidance of any conflicts the original merge caused.

2) If the merge we want to reverse was a reintegrate merge from a
backport branch, the exact merge to perform is non-obvious. Take for
example r1176459 on 1.7.x:

  Reintergrate the 1.7.x-r1173425 branch:

   * r1173425, r1173639, r1174797

To "reverse-merge the original changes from the source branch" we'd
need this 2-URL merge:

  C:\SVN\src-branch-1.7.x>svn merge
^/subversion/branches/1.7.x_at_1173428 .

(Where r1176447 is the last change to the 1.7.x-r1173425 branch before
it was deleted and r1173428 is the rev for 1.7.x that the
1.7.x-r1173425 branch was copied from)

While we can get the same result from simply doing this:

  C:\SVN\src-branch-1.7.x>svn merge ^/subversion/branches/1.7.x . -c-1176459

> At least that gives the corresponding mergeinfo update.
> If you cherry-pick from a dev branch to its trunk, that’s valid
> for an original change but not if the change that you’re picking is
> itself a merge (at least if it’s a merge from trunk). We can detect
> this by seeing whether that change includes a mergeinfo diff.
> Common misconceptions
> That merging from A to B will make B look like A.
> A client said “I merged A to B, then modified B, and now need
> to revert the change on B; maybe I could do that by merging A to B
> again”.

Is 'A' a revision, a branch or both? “I merged A to B" makes it sound
like a revision (or revisions), but then it clearly is referring to a

> In that case, I think the merge from A to B was a
> “reintegrate” which does indeed pretty much make B look like A.
> (Source: WD support ticket #3013.)

Probably pointless nitpick, but is this really a "common" misconception?

> To help avoid this, ‘merge’ should display messages about what
> it’s doing, using terminology that makes clear that changes are being
> merged rather than state.
> Reporting -- What “svn merge” Should Say
> “svn merge” should first of all give a summary of what it is about to
> do, using words that make sense to the user. Consider stopping to ask
> for confirmation (unless --no-interactive). Some of the output should
> be a summary of what is calculated as needing to be merged. That is
> not only a chance to check the user’s expectation, but in a merge that
> involves significant calculating of source revisions, it is also a
> chance for the user to see that Subversion has been doing something
> useful up to this point

A hearty (and somewhat self-serving) +1

> and is about to move on to the next stage of
> actually merging those revisions.
> So for example:
> $ svn co $URL/branches/dev1 wc1
> $ cd wc1
> $ svn merge --reintegrate ^/branches/feature2
> Reintegrating ‘^/branches/feature2’ into working copy of ‘^/branches/dev1’
> and then a summary of the current merging status:

If a user is unaware of what working copy they are operating on, then
this notification is unlikely to help them. I don't see much harm in
it alone, but as we pile on more notifications (below) I think we run
the risk of overloading the merge output (more than it is already!) to
the point where users reflexively ignore it.

> Previous merges from ‘^/branches/feature2’ into ‘^/branches/dev1’:
> 4 source changes (latest: r144) in 2 merges (latest: r145)

I think we are crossing into "too much information" territory if 'svn
merge' starts telling what merges have *previously* been committed.
Isn't that the domain of 'svn mergeinfo'? See my above concern about
notification overload.

If I'm in the minority on this view, I'd suggest that these
notifications either appear after the merge is complete or be repeated
again at the end; so as to be more noticeable.

> and any warnings:
> warning: working copy contains modifications (all in ‘docs/’)
> warning: working copy is not up to date
> warning: ‘^/branches/feature2’ is not up to date with ‘^/branches/dev1’:

Doh, can't believe we've never thought of this before, but recall how
'svn switch' now disallows switching to an unrelated branch:

C:\SVN\src-branch-1.7.x>svn sw
https://svn.apache.org/repos/asf/subversion/site .
..\..\..\subversion\svn\switch-cmd.c:168: (apr_err=195012)
svn: E195012: Path '.' does not share common version control ancestry
with the requested switch location. Use --ignore-ancestry to disable
this check.
..\..\..\subversion\libsvn_client\switch.c:214: (apr_err=195012)
svn: E195012: 'https://svn.apache.org/repos/asf/subversion/site'
shares no common ancestry with 'C:/SVN/src-branch-1.7.x'

We probably want something analogous for 'svn merge', which happily
allows me to do something nonsensical like this:

C:\SVN\src-branch-1.7.x>svn merge
https://svn.apache.org/repos/asf/subversion/site . -c1177291
--- Merging r1177291 into '.':
   C publish
--- Recording mergeinfo for merge of r1177291 into '.':
 U .
Summary of conflicts:
  Tree conflicts: 1

> 2 changes (latest: r166) have not yet been merged
> Run ‘svn mergeinfo’ for details.
> Reporting -- What “svn mergeinfo” Should Say
> In order for a user to understand what merges they have done and need
> to do, it would be most helpful if Subversion could tell them the
> current state of a branch with regard to merges. The existing “svn
> mergeinfo” command is near useless for such understanding: it just
> outputs a list of revnums without saying what that means in terms of
> whether the target is fully caught up or not; it doesn’t report
> anything meaningful about subtree merges and doesn’t even notice them
> by default; it doesn’t check that you specified a sensible source
> branch and simply says nothing if you accidentally specified the
> target branch.
> In a WC of feature branch “B”, which has had catch-ups through
> trunk_at_1234 except trunk_at_1215:
> Mergeinfo summary:
> $ svn mergeinfo ^/trunk
> Origin: ^/branches/B_at_1200 (from ^/trunk_at_1190)
> Merged from ^/trunk:
> Origin-1214, 1216-1234

Keep in mind that for long-lived release branches this information is
never going to be very tidy -- the desire for tidy (i.e. human
readable) output for svn mergeinfo being a common theme elsewhere in
this thread. Consider our 1.6.x branch, how would we show this:

  svn mergeinfo --show-revs=merged ^/subversion/trunk

Here's the mergeinfo representation of what has been merged from from
trunk to 1.6.x, it's not much more concise than the output of the
above command because there are so few spanning ranges:


> Automatic identification of the parent branch:
> $ svn mergeinfo
> Parent branch is ^/trunk.
> [... continue as for “svn mergeinfo ^/trunk” …]
> Failed to identify a parent branch:
> $ svn mergeinfo
> svn: No parent branch configured for ^/branches/B
> When no relationship is configured between this and the specified branch:
> $ svn mergeinfo ^/branches/B2
> No declared relationship between ^/branches/B and ^/branches/B2.
> Merged from ^/branches/B2:
> 905,970-977
> Mergeinfo should be “recursive” by default, reporting any sub-tree
> differences, where presently it does not.

One possible point in favor of keeping 'svn mergeinfo' non-recursive
by default: That recursion takes time, possibly a lot of time if you
have 1000's of subtrees with explicit mergeinfo. But that's pretty
minor since 'svn merge' operates at depth=infinity by default, so 'svn
mergeinfo' probably should too...so I think that means I agree!

> How should the output look in the presence of subtree merges?
> $ svn mergeinfo
> Mergeinfo Diff (bug)
> Diff, when displaying an added mergeinfo property on a sub-tree,
> should diff against the previously inherited mergeinfo, not say that
> all this new mergeinfo represents merges that have just been done.
> Similarly for a deleted prop.

Might be worth putting a link to the already lengthy discussion on
this topic: http://svn.haxx.se/dev/archive-2011-09/0201.shtml

> Terminology - A Typical Branching and Merging Policy
> A simple and useful branching policy. This is presented here just in
> order to give a framework of terminology for describing guidance
> measures for merging, not as a restriction on what is to be supported.
> Assume a partial ordering among branches, such that any given branch
> has (0 or more) Feature Branches that are less stable than it, and
> Release Branches that are more stable than it, and it is considered
> the parent of each of those. A merge may be performed between a
> parent branch and one of its immediate Feature or Release branches,
> and nowhere else.
> A merge to a Feature Branch from its parent is normally a catch-up.

The term 'sync' merge is (more?) frequently used to describe this type
of merge too.

> A merge from a Feature Branch to its parent is normally a reintegrate.
> A merge to a Release Branch from its parent is normally a cherry-pick.

The term 'Cherry-pick' has typically referred to a merge where an
explicitly defined set of revisions is merged (rather than taking all
eligible revisions). See

Of course this doesn't contradict what you said, most merges to a
release branch *are* cherry picks, but we should define 'cherry-pick'.

> A merge from a Release Branch to its parent could be a catch-up or
> a cherry-pick. (### Does a catch-up work properly if you’ve done
> cherry-picks in the other direction? Might not.)

I'm not sure I see the use case where we'd want to do a sync/catch-up
merge from a release branch (as you've defined it) back to the parent.
 Does it work properly? I'm not sure what you'd even be trying to
accomplish here, so I can't say. Think of this:

  svn merge ^/subversion/branches/1.7.x trunk-WC --accept=postpone

This is going to merge all the changes on 1.7.x since it was copied
from trunk and HEAD back to trunk.

> A merge to or from a Release Branch may be forbidden in one direction,
> according to local policy.

Are you getting at the fact that we may want to discourage merges from
release branches back to the parent? Or something else?

> This is very much in flux with a mixture of simple and more radical
> thoughts, but the direction I'm looking at is adding some relatively
> simple but high level "intelligence" on top of the existing merge
> subsystem to guide users better into understanding what they're doing.
> Thoughts welcome.
> - Julian
Received on 2011-09-30 18:46:35 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.