我有兴趣看看这个提交:
[Sep-26 16:14]$ hg log --rev 4b47cc6d212d
changeset: 186413:4b47cc6d212d
parent: 186412:108068f9c1c6
parent: 185155:3452a331b240
summary: merge master to jakeFeatureBranch
正如您所看到的,这是一个合并。我想在我的3-way-diff工具中打开这个合并,看看如何解决冲突。我怎么能这样做?
我尝试运行hg bcompare -c 4b47cc6d212d
,但我的difftool刚刚启动了两个文件。
当我进行合并时,我的差异工具将以3种方式合并模式打开。
答案 0 :(得分:1)
稍微强大的版本:
#!/bin/bash
set -eu
MERGE_REV=$1
FILE_NAME=$2
echo "Replaying merge ${MERGE_REV} for file ${FILE_NAME}"
hg log --rev "${MERGE_REV}"
echo "Extracting key revisions"
PARENT_REV_1=$(HGPLAIN= hg log --rev "${MERGE_REV}"^1 --template '{node|short}')
PARENT_REV_2=$(HGPLAIN= hg log --rev "${MERGE_REV}"^2 --template '{node|short}')
if [ -z "${PARENT_REV_2}" ];
then
echo "Abort: ${MERGE_REV} is not a merge revision"
exit 1
fi
BASE_REV=$(HGPLAIN= hg log -r "max(ancestor("${PARENT_REV_1}", "${PARENT_REV_2}"))" --template '{node|short}\n')
echo "Merge Commit: ${MERGE_REV}"
echo "Parent 1: ${PARENT_REV_1}"
echo "Parent 2: ${PARENT_REV_2}"
echo "Base: ${BASE_REV}"
TMP_DIR=$(mktemp --directory --tmpdir replaymerge.XXXX)
echo "writing to ${TMP_DIR}"
MERGE_RESULT="${TMP_DIR}"/merge-result
PARENT_1="${TMP_DIR}"/parent-1
PARENT_2="${TMP_DIR}"/parent-2
BASE_FILE="${TMP_DIR}"/base-file
hg cat --rev "${MERGE_REV}" "${FILE_NAME}" > "${MERGE_RESULT}"
hg cat --rev "${PARENT_REV_1}" "${FILE_NAME}" > "${PARENT_1}"
hg cat --rev "${PARENT_REV_2}" "${FILE_NAME}" > "${PARENT_2}"
hg cat --rev "${BASE_REV}" "${FILE_NAME}" > "${BASE_FILE}"
echo "Retry the 3-way merge"
# Replace with your diff tool here.
# WARNING: some diff tools accept a different ordering for the file
# panes, and will not put the contents of your 4th file into their 4th
# window. They only use that for saving, not reading.
bcompare "${PARENT_1}" "${PARENT_2}" "${BASE_FILE}" "${MERGE_RESULT}" || true
rm -rf "${TMP_DIR}"
grep
/ sed
/ head
/ tail
的情况下提取修订版(使用原生的mercurial模板)答案 1 :(得分:0)
这很有效。
#!/bin/bash
set -e
mergeCommit=$1
file=$2
echo "Replaying this merge"
hg log --rev $mergeCommit
echo "Extracting key revisions and writting to /tmp"
parent1=$(hg log --rev $mergeCommit | grep 'parent' | head -n1 | sed 's_.*:__')
parent2=$(hg log --rev $mergeCommit | grep 'parent' | tail -n1 | sed 's_.*:__')
base=$(hg log -r "max(ancestor($parent1, $parent2))" | grep 'changeset' | tail -n1 | sed 's_.*:__')
echo "Merge Commit: $mergeCommit"
echo "Parent 1: $parent1"
echo "Parent 2: $parent2"
echo "Base: $base"
actualMergeResult=/tmp/actualMerge
correctMergeResult=/tmp/correctMerge
parent1File=/tmp/parent1
parent2File=/tmp/parent2
baseFile=/tmp/base
hg cat --rev "$mergeCommit" "$file" > "$actualMergeResult"
hg cat --rev "$parent1" "$file" > "$parent1File"
hg cat --rev "$parent2" "$file" > "$parent2File"
hg cat --rev "$base" "$file" > "$baseFile"
echo "Retry the 3-way merge"
# Replace with your diff tool here. WARNING: some diff tools will
# not put the contents of your 4th file into their 4th window. They
# only use that for saving, not reading.
bcompare $parent1File $parent2File $baseFile $correctMerge || true