Megatest

Diff
Login

Differences From Artifact [c87edf48f4]:

To Artifact [14b0c3cc25]:


1
2
3
4
5
6
7
8
9
10
11
12
13


14
15
16
17
18
19
20



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36


37
38
39
40



41
42
43
44

45
#!/bin/bash

wikiname=$1
FOSSILBIN=fossil

if [ x"$wikiname" == "x" ];then
  echo "Usage: viwiki wikipagename"
  exit
fi

$FOSSILBIN sync

wikitmpfile=`mktemp /tmp/${USER}_wikiedit.XXXXXXX`


if ! $FOSSILBIN wiki export "$wikiname" 2> /dev/null  1> $wikitmpfile ;then
    cat /dev/null > $wikitmpfile
    wikipagestate='new'
else
    wikipagestate='existing'
fi




if [ x"$EDITOR" == "x" ];then
	EDITOR="gvim -f"
fi

echo $EDITOR | grep -q -e gvim
isGvim=$?

echo $EDITOR | grep -q -e 'gvim.*-f'
hasF=$?

if [[ $isGvim == 0 && $hasF != 0 ]]; then
	EDITOR="$EDITOR -f"
fi

$EDITOR $wikitmpfile



if [ $wikipagestate == 'new' ];then
  $FOSSILBIN wiki create "$wikiname" $wikitmpfile
else
  $FOSSILBIN wiki commit "$wikiname" $wikitmpfile



fi

$FOSSILBIN sync


rm -f $wikitmpfile












|
>
>







>
>
>
|
|














>
>
|
|
|
|
>
>
>




>
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash

wikiname=$1
FOSSILBIN=fossil

if [ x"$wikiname" == "x" ];then
  echo "Usage: viwiki wikipagename"
  exit
fi

$FOSSILBIN sync

# wikitmpfile=`mktemp /tmp/${USER}_wikiedit.XXXXXXX`
wikitmpfile=${wikiname}.in

if ! $FOSSILBIN wiki export "$wikiname" 2> /dev/null  1> $wikitmpfile ;then
    cat /dev/null > $wikitmpfile
    wikipagestate='new'
else
    wikipagestate='existing'
fi

# make a backup copy of the extracted file to diff detect if changed
cp $wikitmpfile ${wikitmpfile}.orig

if [[ x"$EDITOR" == "x" ]];then #  || [[ x"$VISUAL" == "x" ]];then
    EDITOR="gvim -f"
fi

echo $EDITOR | grep -q -e gvim
isGvim=$?

echo $EDITOR | grep -q -e 'gvim.*-f'
hasF=$?

if [[ $isGvim == 0 && $hasF != 0 ]]; then
	EDITOR="$EDITOR -f"
fi

$EDITOR $wikitmpfile

if ! diff -q $wikitmpfile ${wikitmpfile}.orig;then
    echo "Saving changes to $wikitmpfile to wiki"
    if [ $wikipagestate == 'new' ];then
        $FOSSILBIN wiki create "$wikiname" $wikitmpfile
    else
        $FOSSILBIN wiki commit "$wikiname" $wikitmpfile
    fi
else
    echo "Not saving, no changes to $wikitmpfile."
fi

$FOSSILBIN sync

# NOTE// We *keep* the wikitmpfile but remove the orig copy
rm -f ${wikitmpfile}.orig