dot

packages and services management
Log | Files | Refs | README

commit c1967a3b795bf1b0763a130de43cbdf167f0807c
parent 60468de5d9102460e9f22fbacccfcd1af1d23a8e
Author: josuah <mail@josuah.net>
Date:   Mon,  2 Jan 2017 15:42:42 +0100

Non-tested probably finished version

Diffstat:
M.local/bin/version | 32++++++++++++++++++++++++--------
1 file changed, 24 insertions(+), 8 deletions(-)

diff --git a/.local/bin/version b/.local/bin/version @@ -99,13 +99,11 @@ difftree() } -# 1: tree to check version +# i: diff to apply as generated by makediff -revision() +applydiff() { - new - - difftree "$(tail -n 1 .version/history)" "$1" | while read -r f md5 path + while read -r f md5 path do case "$f" in ( + ) @@ -121,6 +119,15 @@ revision() } +# 1: tree to check version + +revision() +{ + new + difftree "$(tail -n 1 .version/history)" "$1" | applydiff +} + + # 1: root of foreign tree to import in local tree import() @@ -143,7 +150,7 @@ merge() do common="$(grep "$revision" "$2/.version/history")" && break done || die "no revision common to \"$1\" and \"$2\"" - lastf='' lastm='' lastp='' + lastf='' lastm='' lastp='' tmp="$(mktemp)" { (cd "$1" && difftree "$common" "$(tail -n 1 .version/history)") (cd "$2" && difftree "$common" "$(tail -n 1 .version/history)") @@ -151,7 +158,7 @@ merge() } | sed -r '/^.? *[^ ]*$/ d' | sort -t "$NL" -k 1.$((32 + 6)) -k 1,1r | while read -r f md5 path do - if [ "$path" = "$lastp" ] && [ "$f" = "$lastf" ] + if [ "$f" = "$lastf" ] && [ "$path" = "$lastp" ] then printf '%s! %s %s\n' "$f" "$md5" "$path" printf '%s! %s %s\n' "$lastf" "$lastm" "$lastp" @@ -162,7 +169,16 @@ merge() printf '%s %s %s\n' "$lastf" "$lastm" "$lastp" fi lastf="$f" lastm="$md5" lastp="$path" - done + done > "$tmp" + + "$EDITOR" "$tmp" + + grep '^.!' "$tmp" > /dev/null && die 'unsolved conflicts remains' + + (cd "$1" && applydiff < "$tmp") || die "patching \"$1\" failed" + (cd "$2" && applydiff < "$tmp") || die "patching \"$2\" failed" + + rm -f "$tmp" }