dot

packages and services management
Log | Files | Refs | README

commit 1d9085c849b744f5e6bcc1d673b7e464fb57126d
parent d3a42d94cb94f7ab5af1715335f5ebb07f8bf868
Author: josuah <mail@josuah.net>
Date:   Mon,  2 Jan 2017 01:13:03 +0100

TODO: Implement it the clean way

Diffstat:
M.local/bin/version | 58++++++++++++++++++++++++++++++++++++++++++----------------
M.local/share/build/iomenu | 2+-
2 files changed, 43 insertions(+), 17 deletions(-)

diff --git a/.local/bin/version b/.local/bin/version @@ -127,39 +127,65 @@ revision() import() { - printf 'importing objects from "%s" to "%s"' "$1" "$PWD" + printf 'importing objects from "%s" to "%s"\n' "$1" "$PWD" find "$1/.version/obj" -type f | while IFS='' read -r path - do [ -f "${path#$1/}" ] || cp "$path" "${path#$1/}" + do [ -f "${path#$1/}" ] || { cp "$path" "${path#$1/}" || return 1; } done +} - for revision in $(tac "$1/.version/history") - do common="$(grep "$revision" "$2/.version/history")" && break - done - [ "$common" ] || die "no revision common to \"$1\" and \"$2\"" - # TODO: start editor to edit diff, so that user can choose what to apply - # cd "$2" || exit 1 - difftree "$common" "$(tail -n 1 "$1/.version/history")" | - cut -c $((32 + 6)) | uniq +# 1: revision from which list the file changes + +filechanges() +{ + difftree "$1" "$(tail -n 1 .version/history)" | + cut -c $((32 + 6)) | sed '/^ *$/ d' | sort -u } -# 1: 2: root of tree in which look for common revision +# 1: 2: root of trees to merge together merge() { - (cd "$1" && import "$2") - (cd "$2" && import "$1") + (cd "$2" && import "$1") || die "could not import \"$1\" to \"$2\"" + (cd "$1" && import "$2") || die "could not import \"$2\" to \"$1\"" + + for revision in $(tac "$1/.version/history") + do common="$(grep "$revision" "$2/.version/history")" && break + done + [ "$common" ] || die "no revision common to \"$1\" and \"$2\"" + + (cd "$1" && filechanges "$common") > "$1/.version/tmp" && + (cd "$2" && filechanges "$common") > "$2/.version/tmp" || + die "could not generate diff for \"$1\" and \"$2\"" + + clash="$(comm -12 "$1/.version/tmp" "$2/.version/tmp")" + if [ "$clash" ] + then + tmp="$(mktemp)" + printf 'Trees 1 and 2 conflicts\n\n1: %s\n2: %s\n\n' "$1" "$2" + printf 'Replace the '!' with number of files to keep.\n\n' + printf '%s\n' "$conflicts" | sed 's/^/! /')" > "$tmp" + ${EDITOR:-vi} "$tmp" + fi + # TODO FIXME: I'm getting tired. + while read -r f file + do + [ "$f" = ! ] && die "\"$1\" and \"$2\" have unsolved conflicts" + done < "$tmp" + + + rm -f tmp } main() { - case "$1" in ( n | new | d | diff | r | revision | m | merge ) + case "$1" in ( n | new | d | diff | r | revision) [ -d .version ] || die "no .version dir in \"$PWD\"" esac - case "$1" in ( d | diff | r | revision | m | merge ) + case "$1" in ( d | diff | r | revision) [ -f ".version/history" ] || die "no revision in \"$PWD\"" esac @@ -187,7 +213,7 @@ main() [ $# -lt 2 ] && [ $# -gt 3 ] && usage m [ -d "$2/.version" ] || die "no .version dir in \"$2\"" [ -f "$2/.version/history" ] || die "no revision in \"$2\"" - merge "$(cd "$1" || exit 1; pwd)" "$(cd "$2" || exit 1; pwd)" + merge "$(cd "$2" || exit 1; pwd)" "$(cd "$3" || exit 1; pwd)" ;; ( * | '' ) usage diff --git a/.local/share/build/iomenu b/.local/share/build/iomenu @@ -1,3 +1,3 @@ # Input/Output interactive menu and completion engine. -tar=http://repo.or.cz/iomenu.git/snapshot/c493398d788a42554885677e9fafcfc1bc45475e.tar.gz +tar=http://repo.or.cz/iomenu.git/snapshot/18566ed8b2e1020180c8b73e4bca1d5779cc4e54.tar.gz