view unixSoft/bin/svn-hgmerge.py @ 377:117e3c11d953

zprofile: introduce zprofile use El Capitan (OS X 10.11) introduces a system-level /etc/zprofile which uses a path_helper thing to mangle $PATH. Unfortunately, the way path_helper works, it forces /usr/local/bin and /usr/bin to the *start* of the PATH variable, which means that any PATH mutations I want have to run after /etc/zprofile calls path_helper. As such, move my path insertions into .zprofile{,-machine} rather than .zshenv{,-machine} so that I can still ensure my path entries are at the start of PATH rather than the end. This works because: > Commands are then read from $ZDOTDIR/.zshenv. If the shell is a > login shell, commands are read from /etc/zprofile and then > $ZDOTDIR/.zprofile. Then, if the shell is interactive, commands > are read from /etc/zshrc and then $ZDOTDIR/.zshrc. Finally, if the > shell is a login shell, /etc/zlogin and $ZDOTDIR/.zlogin are read. This means that non-login shells no longer pick up my custom PATH entries, but as I only use OS X as a desktop OS that seems like a workable tradeoff for now.
author Augie Fackler <raf@durin42.com>
date Sun, 31 Jan 2016 20:46:29 -0500
parents c30d68fbd368
children
line wrap: on
line source

#!/usr/bin/env python
# ====================================================================
# Copyright (c) 2007 CollabNet.  All rights reserved.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution.  The terms
# are also available at http://subversion.tigris.org/license-1.html.
# If newer versions of this license are posted there, you may use a
# newer version instead, at your option.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://subversion.tigris.org/.
# ====================================================================
HGMERGE_BINARY='hgmerge'

'''This script allows using Mercurial's hgmerge script with Subversion.
'''

import os
import sys
import shutil
import tempfile

def do_hgmerge(base, repo, local, merged):
  '''Runs an interactive three-way merge using Mercurial's hgmerge script.
  
  This function is designed to convert Subversion's four-file interactive merges
  into Mercurial's three-file interactive merges so that hgmerge can be used for
  interactive merging in subversion.
  '''
  # We have to use a temporary directory because FileMerge on OS X fails to save
  # the file if it has to write to a file in the CWD. As of now, there's no
  # obvious reason for why that is, but this fixes it.
  temp_dir = tempfile.mkdtemp(prefix='svn_hgmerge')
  local_name = local.split('/')[-1]
  temp_file = temp_dir+'/'+local_name
  shutil.copyfile(local, temp_file)
  args = [HGMERGE_BINARY, temp_file, base, repo]
  status = os.spawnvp(os.P_WAIT, HGMERGE_BINARY, args)
  print status
  if status == 0:
    os.unlink(merged)
    shutil.copyfile(temp_file, merged)
  os.unlink(temp_file)
  os.rmdir(temp_dir)
  return status

if __name__ == '__main__':
  status = do_hgmerge(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4])
  sys.exit(status)