File: amend.sh

package info (click to toggle)
darcs 2.18.5-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 6,008 kB
  • sloc: haskell: 47,748; sh: 13,466; ansic: 447; perl: 134; makefile: 6
file content (145 lines) | stat: -rw-r--r-- 3,445 bytes parent folder | download | duplicates (2)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/usr/bin/env bash

# Testing amend

. lib

rm -rf temp1
# set up the repository
mkdir temp1
cd temp1
darcs init
cd ..

# do some work here
cd temp1
# Plain amend
touch foo
darcs add foo
darcs record -a -m add_foo
echo 'another line' > foo
echo y | darcs amend -a foo | grep -i 'amending changes'
darcs changes -v | grep 'another line'
# amend of removed file
touch bar1
touch bar2
cat > bar1 << FOO
a line
b line
FOO
darcs add bar1 bar2
darcs record -a -m add_bars
rm -f bar2
echo y | darcs amend -a | grep -i 'finished amending'
# Special case: patch is empty after amend
cp foo foo.old
echo 'another line' >> foo
darcs record -a -m add_line foo | grep -i 'finished recording'
mv foo.old foo
echo y | darcs amend -a foo | grep -i 'amending changes'
# Amend --author, -m, etc
echo "another line" >> foo
echo y | darcs amend -a -m new_name foo | grep -i 'amending changes'
darcs changes --last=1 | grep new_name
echo "another line" >> foo
echo y | darcs amend -a -m new_name -A new_author foo | grep -i 'amending changes'
darcs changes --last=1 | grep new_author

# check that normally the date changes when we amend
echo "another line" >> foo
darcs changes --last=1 | head -n 1 > old_date
echo y | darcs amend -a foo -A new_author | grep -i 'amending changes'
darcs changes --last=1 | head -n 1 > new_date
not cmp old_date new_date

# check that --keep-date works
echo "another line" >> foo
darcs changes --last=1 | head -n 3 | grep Date > old_date
sleep 1
echo y | darcs amend -a foo -A new_author --keep-date | grep -i 'amending changes'
darcs changes --last=1 | head -n 3 | grep Date > new_date
cmp old_date new_date

cd ..

# check that the identity changes with --keep-date
darcs get temp1 temp2
cd temp2

echo "another line" >> foo
darcs changes --last=1 | head -n 1 > old_date
echo y | darcs amend -a foo -A new_author --keep-date | grep -i 'amending changes'
darcs pull ../temp1 -a --skip-conflicts | grep -i "Skipping some"

cd ..

rm -rf temp1 temp2


# This checks for a possible bug in patch selection where the no available
# patches case is hit.

darcs init temp1
cd temp1
touch A
darcs record -lam A
echo 'l1' >> A
darcs record -am l1
darcs amend -a --patch 'A'

cd ..
rm -rf temp1

## Copyright (C) 2011 Ganesh Sittampalam <ganesh@earth.li>

darcs init temp1
cd temp1

echo 'file1' > file1
darcs record -lam 'file1'

echo 'file2' > file2
darcs record -lam 'file2'

echo 'file2:amended' > file2
echo 'nkya' | darcs amend

darcs log -p 'file2' -v | grep amended
cd ..
rm -rf temp1

## Test for amend --unrecord
## Copyright (C) 2012  Ganesh Sittampalam

darcs init temp1
cd temp1

echo -e "x\ny" > foo
darcs rec -lam "add foo"

echo -e "1\nx\ny\n2" > foo
darcs rec -am "insert 1 and 2"

echo yyny | darcs amend --unrecord
echo -e "x\ny\n2" > foo.expected
darcs show contents foo | diff -q foo.expected -

echo yenyy | DARCS_EDITOR="sed -i -e s/2/2j/" darcs amend --unrecord
echo -e "x\ny\n2j" > foo.expected
darcs show contents foo | diff -q foo.expected -

echo 'ugh' > bar
darcs add bar
# use amend to check it's still a short form for amend-record
# if we make amend-unrecord visible rather than hidden that would change
echo y | darcs amend -a
darcs show contents bar | diff -q bar -

# test that amend --unrecord --all and specifying files works
echo y | darcs amend --unrecord -a foo
echo -e "x\ny" > foo.expected
darcs show contents foo | diff -q foo.expected -
darcs show contents bar | diff -q bar -

cd ..
rm -rf temp1