##// END OF EJS Templates
contrib: don't hardcode path to bash interpreter...
Olle Lundberg -
r20831:864c56cb default
parent child Browse files
Show More
@@ -1,58 +1,58 b''
1 #!/bin/bash
1 #!/usr/bin/env bash
2 # A simple script for opening merge conflicts in the editor.
2 # A simple script for opening merge conflicts in the editor.
3 # Use the following Mercurial settings to enable it.
3 # Use the following Mercurial settings to enable it.
4 #
4 #
5 # [ui]
5 # [ui]
6 # merge = editmerge
6 # merge = editmerge
7 #
7 #
8 # [merge-tools]
8 # [merge-tools]
9 # editmerge.args=$output
9 # editmerge.args=$output
10 # editmerge.check=changed
10 # editmerge.check=changed
11 # editmerge.premerge=keep
11 # editmerge.premerge=keep
12
12
13 FILE=$1
13 FILE=$1
14
14
15 getlines() {
15 getlines() {
16 grep -n "<<<<<<" $FILE | cut -f1 -d:
16 grep -n "<<<<<<" $FILE | cut -f1 -d:
17 }
17 }
18
18
19 # editor preference loosely based on http://mercurial.selenic.com/wiki/editor
19 # editor preference loosely based on http://mercurial.selenic.com/wiki/editor
20 # hg showconfig is at the bottom though, since it's slow to run (0.15 seconds)
20 # hg showconfig is at the bottom though, since it's slow to run (0.15 seconds)
21 ED=$HGEDITOR
21 ED=$HGEDITOR
22 if [ "$ED" = "" ] ; then
22 if [ "$ED" = "" ] ; then
23 ED=$VISUAL
23 ED=$VISUAL
24 fi
24 fi
25 if [ "$ED" = "" ] ; then
25 if [ "$ED" = "" ] ; then
26 ED=$EDITOR
26 ED=$EDITOR
27 fi
27 fi
28 if [ "$ED" = "" ] ; then
28 if [ "$ED" = "" ] ; then
29 ED=$(hg showconfig ui.editor)
29 ED=$(hg showconfig ui.editor)
30 fi
30 fi
31 if [ "$ED" = "" ] ; then
31 if [ "$ED" = "" ] ; then
32 echo "merge failed - unable to find editor"
32 echo "merge failed - unable to find editor"
33 exit 1
33 exit 1
34 fi
34 fi
35
35
36 if [ "$ED" = "emacs" ] || [ "$ED" = "nano" ] || [ "$ED" = "vim" ] ; then
36 if [ "$ED" = "emacs" ] || [ "$ED" = "nano" ] || [ "$ED" = "vim" ] ; then
37 FIRSTLINE=$(getlines | head -n 1)
37 FIRSTLINE=$(getlines | head -n 1)
38 PREVIOUSLINE=""
38 PREVIOUSLINE=""
39
39
40 # open the editor to the first conflict until there are no more
40 # open the editor to the first conflict until there are no more
41 # or the user stops editing the file
41 # or the user stops editing the file
42 while [ ! "$FIRSTLINE" = "" ] && [ ! "$FIRSTLINE" = "$PREVIOUSLINE" ] ; do
42 while [ ! "$FIRSTLINE" = "" ] && [ ! "$FIRSTLINE" = "$PREVIOUSLINE" ] ; do
43 $ED +$FIRSTLINE $FILE
43 $ED +$FIRSTLINE $FILE
44 PREVIOUSLINE=$FIRSTLINE
44 PREVIOUSLINE=$FIRSTLINE
45 FIRSTLINE=$(getlines | head -n 1)
45 FIRSTLINE=$(getlines | head -n 1)
46 done
46 done
47 else
47 else
48 $ED $FILE
48 $ED $FILE
49 fi
49 fi
50
50
51 # get the line numbers of the remaining conflicts
51 # get the line numbers of the remaining conflicts
52 CONFLICTS=$(getlines | sed ':a;N;$!ba;s/\n/, /g')
52 CONFLICTS=$(getlines | sed ':a;N;$!ba;s/\n/, /g')
53 if [ ! "$CONFLICTS" = "" ] ; then
53 if [ ! "$CONFLICTS" = "" ] ; then
54 echo "merge failed - resolve the conflicts (line $CONFLICTS) then use 'hg resolve --mark'"
54 echo "merge failed - resolve the conflicts (line $CONFLICTS) then use 'hg resolve --mark'"
55 exit 1
55 exit 1
56 fi
56 fi
57
57
58 exit 0
58 exit 0
@@ -1,89 +1,89 b''
1 #!/bin/bash
1 #!/usr/bin/env bash
2
2
3 # Measure the performance of a list of revsets against multiple revisions
3 # Measure the performance of a list of revsets against multiple revisions
4 # defined by parameter. Checkout one by one and run perfrevset with every
4 # defined by parameter. Checkout one by one and run perfrevset with every
5 # revset in the list to benchmark its performance.
5 # revset in the list to benchmark its performance.
6 #
6 #
7 # - First argument is a revset of mercurial own repo to runs against.
7 # - First argument is a revset of mercurial own repo to runs against.
8 # - Second argument is the file from which the revset array will be taken
8 # - Second argument is the file from which the revset array will be taken
9 # If second argument is omitted read it from standard input
9 # If second argument is omitted read it from standard input
10 #
10 #
11 # You should run this from the root of your mercurial repository.
11 # You should run this from the root of your mercurial repository.
12 #
12 #
13 # This script also does one run of the current version of mercurial installed
13 # This script also does one run of the current version of mercurial installed
14 # to compare performance.
14 # to compare performance.
15
15
16 HG="hg update"
16 HG="hg update"
17 PERF="./hg --config extensions.perf=contrib/perf.py perfrevset"
17 PERF="./hg --config extensions.perf=contrib/perf.py perfrevset"
18 BASE_PERF="hg --config extensions.perf=contrib/perf.py perfrevset"
18 BASE_PERF="hg --config extensions.perf=contrib/perf.py perfrevset"
19
19
20 TARGETS=$1
20 TARGETS=$1
21 shift
21 shift
22 # read from a file or from standard output
22 # read from a file or from standard output
23 if [ $# -ne 0 ]; then
23 if [ $# -ne 0 ]; then
24 readarray REVSETS < $1
24 readarray REVSETS < $1
25 else
25 else
26 readarray REVSETS
26 readarray REVSETS
27 fi
27 fi
28
28
29 hg update --quiet
29 hg update --quiet
30
30
31 echo "Starting time benchmarking"
31 echo "Starting time benchmarking"
32 echo
32 echo
33
33
34 echo "Revsets to benchmark"
34 echo "Revsets to benchmark"
35 echo "----------------------------"
35 echo "----------------------------"
36
36
37 for (( j = 0; j < ${#REVSETS[@]}; j++ ));
37 for (( j = 0; j < ${#REVSETS[@]}; j++ ));
38 do
38 do
39 echo "${j}) ${REVSETS[$j]}"
39 echo "${j}) ${REVSETS[$j]}"
40 done
40 done
41
41
42 echo "----------------------------"
42 echo "----------------------------"
43 echo
43 echo
44
44
45 # Benchmark baseline
45 # Benchmark baseline
46 echo "Benchmarking baseline"
46 echo "Benchmarking baseline"
47
47
48 for (( j = 0; j < ${#REVSETS[@]}; j++ ));
48 for (( j = 0; j < ${#REVSETS[@]}; j++ ));
49 do
49 do
50 echo -n "${j}) "
50 echo -n "${j}) "
51 $BASE_PERF "${REVSETS[$j]}"
51 $BASE_PERF "${REVSETS[$j]}"
52 done
52 done
53
53
54 echo
54 echo
55 echo
55 echo
56
56
57 # Benchmark revisions
57 # Benchmark revisions
58 for i in $(hg log --template='{rev}\n' --rev $TARGETS);
58 for i in $(hg log --template='{rev}\n' --rev $TARGETS);
59 do
59 do
60 echo "----------------------------"
60 echo "----------------------------"
61 echo -n "Revision: "
61 echo -n "Revision: "
62 hg log -r $i --template "{desc|firstline}"
62 hg log -r $i --template "{desc|firstline}"
63
63
64 echo "----------------------------"
64 echo "----------------------------"
65 $HG $i
65 $HG $i
66 for (( j = 0; j < ${#REVSETS[@]}; j++ ));
66 for (( j = 0; j < ${#REVSETS[@]}; j++ ));
67 do
67 do
68 echo -n "${j}) "
68 echo -n "${j}) "
69 $PERF "${REVSETS[$j]}"
69 $PERF "${REVSETS[$j]}"
70 done
70 done
71 echo "----------------------------"
71 echo "----------------------------"
72 done
72 done
73
73
74 $HG
74 $HG
75
75
76 # Benchmark current code
76 # Benchmark current code
77 echo "Benchmarking current code"
77 echo "Benchmarking current code"
78
78
79 for (( j = 0; j < ${#REVSETS[@]}; j++ ));
79 for (( j = 0; j < ${#REVSETS[@]}; j++ ));
80 do
80 do
81 echo -n "${j}) "
81 echo -n "${j}) "
82 $PERF "${REVSETS[$j]}"
82 $PERF "${REVSETS[$j]}"
83 done
83 done
84
84
85
85
86 echo
86 echo
87 echo "Time benchmarking finished"
87 echo "Time benchmarking finished"
88
88
89
89
General Comments 0
You need to be logged in to leave comments. Login now