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

Re: Unsure about how to use javahl merge functions

From: Mark Phippard <markphip_at_gmail.com>
Date: Wed, 4 Nov 2009 11:17:59 -0500

On Wed, Nov 4, 2009 at 11:02 AM, Daniel Pötzl
<e0625249_at_student.tuwien.ac.at> wrote:

> I'm writing a tool using the javahl API. What I need it to do is merge
> a branch into a working copy that is equal to the latest trunk.
> Basically, it should
> behave like the svn cli client with the invocation 'svn merge <Branch-URL>',
> the current directory being the working copy.
>
> However, my attempts on using the merge functions of the javahl API for
> this have
> so far been unsuccessful. The changes in the trunk always get
> overwritten by the
> changes in the branch (they are on the same line of the file). But I
> want it to
> generate a conflict and create *.working, etc. files and put conflict markers
> into the files.
>
> How would one go about this? Is this even possible using the javahl-API?

You would use this method:

    /**
     * Merge changes from two paths into a new local path.
     *
     * @param path1 first path or url
     * @param revision1 first revision
     * @param path2 second path or url
     * @param revision2 second revision
     * @param localPath target local path
     * @param force overwrite local changes
     * @param depth how deep to traverse into subdirectories
     * @param ignoreAncestry ignore if files are not related
     * @param dryRun do not change anything
     * @param recordOnly record mergeinfo but do not run merge
     * @throws ClientException
     * @since 1.5
     */
    void merge(String path1, Revision revision1, String path2,
               Revision revision2, String localPath, boolean force, int depth,
               boolean ignoreAncestry, boolean dryRun, boolean recordOnly)
            throws ClientException;

In your case both path1 and path2 will be the URL of the branch you
are merging. Since you want Subversion's merge tracking to figure out
what to merge, you pass NULL for revision1 and revision2. localPath
is your the working copy that you are merging into and the rest of
options are just based on what you want to do. Typically it would be:

force = false
depth = Depth.unknown
ignoreAncestry = false
dryRun = false
recordOnly = false

There would also be cases you would want to use this API:

    /**
     * Perform a reintegration merge of path into localPath.
     * localPath must be a single-revision, infinite depth,
     * pristine, unswitched working copy -- in other words, it must
     * reflect a single revision tree, the "target". The mergeinfo on
     * path must reflect that all of the target has been merged into it.
     * Then this behaves like a merge from the target's URL to the
     * localPath.
     *
     * The depth of the merge is always infinity.
     * @param path path or url
     * @param pegRevision revision to interpret path
     * @param localPath target local path
     * @param dryRun do not change anything
     * @throws ClientException
     * @since 1.5
     */
    void mergeReintegrate(String path, Revision pegRevision,
                          String localPath, boolean dryRun)
             throws ClientException;

All of these are used in the CollabNet Merge Client for Eclipse.

http://desktop-eclipse.open.collab.net/cn-project-pages/Getting%20started/Merge%20Client/

-- 
Thanks
Mark Phippard
http://markphip.blogspot.com/
------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=2414445
To unsubscribe from this discussion, e-mail: [users-unsubscribe_at_subversion.tigris.org].
Received on 2009-11-04 17:19:03 CET

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

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