contrib/editmerge
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Thu, 17 Apr 2014 09:36:09 +0900
changeset 21124 a65714215377
parent 20831 864c56cb8945
child 26421 4b0fc75f9403
permissions -rwxr-xr-x
hgweb: align entries in "changelog" and "revisions" pages of "spartan" style Before this patch, each log entries in "changelog" and "revisions" pages of "spartan" style are not aligned by column, because: - each log entries are separated "<table>" entries, and - there are no fixed "width" information for each "<th>"/"<td>" entries This patch aligns entries in "changelog" and "revisions" pages of "spartan" style by: - adding 'label' class to '<th>' for 'age' information, and - setting 'width' of '<th class="label">' with fixed size 'class="age"' is not used for this purpose, because it is also used to set "bold" font-weight "16em" seems to be wide enough to show date information fully, when web browser disables (or doesn't support) javascript.

#!/usr/bin/env bash
# A simple script for opening merge conflicts in the editor.
# Use the following Mercurial settings to enable it.
#
# [ui]
# merge = editmerge
#
# [merge-tools]
# editmerge.args=$output
# editmerge.check=changed
# editmerge.premerge=keep

FILE=$1

getlines() {
  grep -n "<<<<<<" $FILE | cut -f1 -d:
}

# editor preference loosely based on http://mercurial.selenic.com/wiki/editor
# hg showconfig is at the bottom though, since it's slow to run (0.15 seconds)
ED=$HGEDITOR
if [ "$ED" = "" ] ; then
  ED=$VISUAL
fi
if [ "$ED" = "" ] ; then
  ED=$EDITOR
fi
if [ "$ED" = "" ] ; then
  ED=$(hg showconfig ui.editor)
fi
if [ "$ED" = "" ] ; then
  echo "merge failed - unable to find editor"
  exit 1
fi

if [ "$ED" = "emacs" ] || [ "$ED" = "nano" ] || [ "$ED" = "vim" ] ; then
  FIRSTLINE=$(getlines | head -n 1)
  PREVIOUSLINE=""

  # open the editor to the first conflict until there are no more
  # or the user stops editing the file
  while [ ! "$FIRSTLINE" = "" ] && [ ! "$FIRSTLINE" = "$PREVIOUSLINE" ] ; do
    $ED +$FIRSTLINE $FILE
    PREVIOUSLINE=$FIRSTLINE
    FIRSTLINE=$(getlines | head -n 1)
  done
else
  $ED $FILE
fi

# get the line numbers of the remaining conflicts
CONFLICTS=$(getlines | sed ':a;N;$!ba;s/\n/, /g')
if [ ! "$CONFLICTS" = "" ] ; then
  echo "merge failed - resolve the conflicts (line $CONFLICTS) then use 'hg resolve --mark'"
  exit 1
fi

exit 0