Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2013
    Posts
    1

    Default Using BC4 Mac with Tower (Git)

    If you're using Tower and want to compare and merge using BC4 use the following

    1. Close Tower and BC$


    2. Create the plist file ~/Library/Application Support/Tower/CompareToolts.plist

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <array>
    	<dict>
    		<key>ApplicationIdentifier</key>
    		<string>com.ScooterSoftware.BeyondCompare</string>
    		<key>ApplicationName</key>
    		<string>BeyondCompare</string>
    		<key>DisplayName</key>
    		<string>Beyond Compare</string>
    		<key>LaunchScript</key>
    		<string>beyondcompare.sh</string>
    		<key>Identifier</key>
    		<string>BeyondCompare</string>
    		<key>SupportsMergeTool</key>
    		<true/>
    	</dict>
    </array>
    </plist>
    3. Create the shell script file ~/Library/Application Support/Tower/CompareScripts/beyondcompare.sh and chmod +x it

    Code:
    #!/bin/sh
    
    /usr/local/bin/bcomp "$1" "$2" "$3" "$4"
    4. Select Beyond Compare as your merge/diff tool in Tower's preference.

    5. Done!

    P.S. I've also uploaded the config and script, just unzip into ~/Library/Application Support/Tower/ and CHMOD +x the shell script and you're all set!

  2. #2
    Join Date
    Sep 2011
    Posts
    3

    Default ...with merge support

    Here's a version of the launch script, based on Tower's script for Kaleidoscope. It should work as well as the simple version, just adds some additional options for making some of the windows read-only, setting more descriptive titles for the panes, etc. Follow the instructions above, but use the code below for the body of the beyondcompare.sh script.

    Code:
    #!/bin/sh
    
    LOCAL="$1"
    REMOTE="$2"
    
    # Sanitize LOCAL path
    if [[ ! "$LOCAL" =~ ^/ ]]; then
    	LOCAL=$(echo "$LOCAL" | sed -e 's/^\.\///')
    	LOCAL="$PWD/$LOCAL"
    fi
    
    # Sanitize REMOTE path
    if [[ ! "$REMOTE" =~ ^/ ]]; then
    	REMOTE=$(echo "$REMOTE" | sed -e 's/^\.\///')
    	REMOTE="$PWD/$REMOTE"
    fi
    
    MERGING="$4"
    BACKUP="/tmp/$(date +"%Y%d%m%H%M%S")"
    
    BCOMP=`which bcomp`
    BCOMPARE=`which bcompare`
    
    if [ ! $BCOMP > /dev/null ] ; then
      if [ -e '/usr/local/bin/bcomp' ] ; then
        BCOMP='/usr/local/bin/bcomp'
      fi
    fi
    
    if [ ! -x "$BCOMP" ]; then    
      echo "Beyond Compares's command line tool 'bcomp' could not be found. Please make sure it has been installed in /usr/local/bin/." >&2
      exit 128
    fi
    
    if [ -n "$MERGING" ]; then
      BASE="$3"
      MERGE="$4"
    
      # Sanitize BASE path
      if [[ ! "$BASE" =~ ^/ ]]; then
        BASE=$(echo "$BASE" | sed -e 's/^\.\///')
        BASE="$PWD/$BASE"
    
        if [ ! -f "$BASE" ]; then
          BASE=/dev/null
        fi
      fi
    
      # Sanitize MERGE path
      if [[ ! "$MERGE" =~ ^/ ]]; then
        MERGE=$(echo "$MERGE" | sed -e 's/^\.\///')
        MERGE="$PWD/$MERGE"
    
        if [ ! -f "$MERGE" ]; then
          # For conflict "Both Added", Git does not pass the merge param correctly in current versions
          MERGE=$(echo "$LOCAL" | sed -e 's/\.LOCAL\.[0-9]*//')
        fi
      fi
    
      sleep 1 # required to create different modification timestamp
      touch "$BACKUP"
      
      "$BCOMP" -ro1 -ro2 -title1="HEAD - $LOCAL" -title2="Merging in - $REMOTE" -title3="Base - $BASE" "$LOCAL" "$REMOTE" "$BASE" "$MERGE"
    else
      MERGE="$3"
    
      if [ -n "$MERGE" ]; then
          #"$BCOMP" -ro1 -ro2 -title1="Remote - $REMOTE" -title2 "Local - $LOCAL" -title3 "Base - $MERGE" "$REMOTE" "$LOCAL" "$MERGE"
          #"$BCOMP" -ro1 -ro2 "$REMOTE" "$LOCAL" "$MERGE"
          "$BCOMP" -vcs1="$MERGE" -ro1 -title1="Local - $LOCAL" -title2="Remote - $MERGE" "$LOCAL" "$REMOTE"
      else
          "$BCOMP" -ro1 -title1="Local - $LOCAL" -title2="Remote - $REMOTE" "$LOCAL" "$REMOTE"
      fi  
    fi
    
    if [ -n "$MERGING" ]; then
      # Check if the merged file has changed
      if [ "$MERGE" -ot "$BACKUP" ]; then
        exit 1
      fi
    fi
    
    exit 0

  3. #3
    Join Date
    Apr 2008
    Posts
    27

    Default Tower 2

    Tower 2.0 has been released, and some changes are needed in the instructions here to get it working with Beyond Compare. (I hadn't previously tried with Tower 1.)

    1. The path to the support files has changed.

    The files "CompareTools.plist" and "beyondcompare.sh" both need to be placed in ~/Library/Application Support/com.fournova.Tower2/

    (The CompareScripts subfolder is no longer used in Tower 2. There is some confusion in their online help which mixes up instructions for version 1 and 2.)

    2. I needed to make a change in the plist to get Tower to recognise that Beyond Compare was installed: the "ApplicationName" key must match the name of the application file (without the ".app" suffix) and is missing a space. Here is my revised version:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <array>
    	<dict>
    		<key>ApplicationIdentifier</key>
    		<string>com.ScooterSoftware.BeyondCompare</string>
    		<key>ApplicationName</key>
    		<string>Beyond Compare</string>
    		<key>DisplayName</key>
    		<string>Beyond Compare</string>
    		<key>LaunchScript</key>
    		<string>beyondcompare.sh</string>
    		<key>Identifier</key>
    		<string>BeyondCompare</string>
    		<key>SupportsMergeTool</key>
    		<true/>
    	</dict>
    </array>
    </plist>
    These changes are sufficient to let Tower 2 choose Beyond Compare as the diff/merge tool and launch it, but I still have an unresolved problem: when looking at the changes made in a commit, if comparing with the current (HEAD) version of a file, Tower or the script sets up a temporary directory containing a symbolic link to the actual file. (Older versions of files are extracted in full from the repository to a temporary directory under /var/folders. Beyond Compare has no problem if comparing two older versions of a file.)

    It appears that Beyond Compare 4 beta (I tried builds 18564 and 18510) doesn't correctly handle symbolic links: the link is shown as such in the folder comparison view and is treated as being unrelated to the other file. I've attached a partial screen shot.

    If I force comparison between the two files, the one on the right shows the content of the symbolic link, which is a single line containing the pathname of the real file, rather than following the symbolic link and opening the actual file.

  4. #4
    Join Date
    Oct 2007
    Location
    Madison, WI
    Posts
    4,676

    Default

    To resolve the symbolic link issue in the Folder Compare, select "Beyond Compare > Session Settings" or click on the Rules toolbar button. In the Handling tab, check "Follow symbolic links".

    If you want to follow symbolic links by default, change the dropdown at the bottom of the dialog from "Use for this view only" to "Also update session defaults" before clicking OK.
    Chris K Scooter Software

  5. #5
    Join Date
    Apr 2008
    Posts
    27

    Default

    Quote Originally Posted by Chris View Post
    To resolve the symbolic link issue in the Folder Compare, select "Beyond Compare > Session Settings" or click on the Rules toolbar button. In the Handling tab, check "Follow symbolic links".

    If you want to follow symbolic links by default, change the dropdown at the bottom of the dialog from "Use for this view only" to "Also update session defaults" before clicking OK.
    Thanks, that fixed it. I was expecting it to be a global preference for the application, but couldn't see anything relevant there. Session settings didn't occur to me.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •