Show More
@@ -0,0 +1,79 b'' | |||||
|
1 | #!/bin/sh | |||
|
2 | ||||
|
3 | # Test the plumbing of mq.git option | |||
|
4 | # Automatic upgrade itself is tested elsewhere. | |||
|
5 | ||||
|
6 | echo "[extensions]" >> $HGRCPATH | |||
|
7 | echo "mq=" >> $HGRCPATH | |||
|
8 | echo "[diff]" >> $HGRCPATH | |||
|
9 | echo "nodates=1" >> $HGRCPATH | |||
|
10 | ||||
|
11 | hg init repo-auto | |||
|
12 | cd repo-auto | |||
|
13 | echo '% git=auto: regular patch creation' | |||
|
14 | echo a > a | |||
|
15 | hg add a | |||
|
16 | hg qnew -d '0 0' -f adda | |||
|
17 | cat .hg/patches/adda | |||
|
18 | echo '% git=auto: git patch creation with copy' | |||
|
19 | hg cp a b | |||
|
20 | hg qnew -d '0 0' -f copy | |||
|
21 | cat .hg/patches/copy | |||
|
22 | echo '% git=auto: git patch when using --git' | |||
|
23 | echo regular > regular | |||
|
24 | hg add regular | |||
|
25 | hg qnew -d '0 0' --git -f git | |||
|
26 | cat .hg/patches/git | |||
|
27 | echo '% git=auto: regular patch after qrefresh without --git' | |||
|
28 | hg qrefresh -d '0 0' | |||
|
29 | cat .hg/patches/git | |||
|
30 | cd .. | |||
|
31 | ||||
|
32 | hg init repo-keep | |||
|
33 | cd repo-keep | |||
|
34 | echo '[mq]' > .hg/hgrc | |||
|
35 | echo 'git = KEEP' >> .hg/hgrc | |||
|
36 | echo '% git=keep: git patch with --git' | |||
|
37 | echo a > a | |||
|
38 | hg add a | |||
|
39 | hg qnew -d '0 0' -f --git git | |||
|
40 | cat .hg/patches/git | |||
|
41 | echo '% git=keep: git patch after qrefresh without --git' | |||
|
42 | echo a >> a | |||
|
43 | hg qrefresh -d '0 0' | |||
|
44 | cat .hg/patches/git | |||
|
45 | cd .. | |||
|
46 | ||||
|
47 | hg init repo-yes | |||
|
48 | cd repo-yes | |||
|
49 | echo '[mq]' > .hg/hgrc | |||
|
50 | echo 'git = yes' >> .hg/hgrc | |||
|
51 | echo '% git=yes: git patch' | |||
|
52 | echo a > a | |||
|
53 | hg add a | |||
|
54 | hg qnew -d '0 0' -f git | |||
|
55 | cat .hg/patches/git | |||
|
56 | echo '% git=yes: git patch after qrefresh' | |||
|
57 | echo a >> a | |||
|
58 | hg qrefresh -d '0 0' | |||
|
59 | cat .hg/patches/git | |||
|
60 | cd .. | |||
|
61 | ||||
|
62 | hg init repo-no | |||
|
63 | cd repo-no | |||
|
64 | echo '[diff]' > .hg/hgrc | |||
|
65 | echo 'git = True' >> .hg/hgrc | |||
|
66 | echo '[mq]' > .hg/hgrc | |||
|
67 | echo 'git = False' >> .hg/hgrc | |||
|
68 | echo '% git=no: regular patch with copy' | |||
|
69 | echo a > a | |||
|
70 | hg add a | |||
|
71 | hg qnew -d '0 0' -f adda | |||
|
72 | hg cp a b | |||
|
73 | hg qnew -d '0 0' -f regular | |||
|
74 | cat .hg/patches/regular | |||
|
75 | echo '% git=no: regular patch after qrefresh with copy' | |||
|
76 | hg cp a c | |||
|
77 | hg qrefresh -d '0 0' | |||
|
78 | cat .hg/patches/regular | |||
|
79 | cd .. No newline at end of file |
@@ -0,0 +1,100 b'' | |||||
|
1 | % git=auto: regular patch creation | |||
|
2 | # HG changeset patch | |||
|
3 | # Date 0 0 | |||
|
4 | ||||
|
5 | diff -r 000000000000 -r ef8dafc9fa4c a | |||
|
6 | --- /dev/null | |||
|
7 | +++ b/a | |||
|
8 | @@ -0,0 +1,1 @@ | |||
|
9 | +a | |||
|
10 | % git=auto: git patch creation with copy | |||
|
11 | # HG changeset patch | |||
|
12 | # Date 0 0 | |||
|
13 | ||||
|
14 | diff --git a/a b/b | |||
|
15 | copy from a | |||
|
16 | copy to b | |||
|
17 | % git=auto: git patch when using --git | |||
|
18 | # HG changeset patch | |||
|
19 | # Date 0 0 | |||
|
20 | ||||
|
21 | diff --git a/regular b/regular | |||
|
22 | new file mode 100644 | |||
|
23 | --- /dev/null | |||
|
24 | +++ b/regular | |||
|
25 | @@ -0,0 +1,1 @@ | |||
|
26 | +regular | |||
|
27 | % git=auto: regular patch after qrefresh without --git | |||
|
28 | # HG changeset patch | |||
|
29 | # Date 0 0 | |||
|
30 | ||||
|
31 | diff -r 2962f232b49d regular | |||
|
32 | --- /dev/null | |||
|
33 | +++ b/regular | |||
|
34 | @@ -0,0 +1,1 @@ | |||
|
35 | +regular | |||
|
36 | % git=keep: git patch with --git | |||
|
37 | # HG changeset patch | |||
|
38 | # Date 0 0 | |||
|
39 | ||||
|
40 | diff --git a/a b/a | |||
|
41 | new file mode 100644 | |||
|
42 | --- /dev/null | |||
|
43 | +++ b/a | |||
|
44 | @@ -0,0 +1,1 @@ | |||
|
45 | +a | |||
|
46 | % git=keep: git patch after qrefresh without --git | |||
|
47 | # HG changeset patch | |||
|
48 | # Date 0 0 | |||
|
49 | ||||
|
50 | diff --git a/a b/a | |||
|
51 | new file mode 100644 | |||
|
52 | --- /dev/null | |||
|
53 | +++ b/a | |||
|
54 | @@ -0,0 +1,2 @@ | |||
|
55 | +a | |||
|
56 | +a | |||
|
57 | % git=yes: git patch | |||
|
58 | # HG changeset patch | |||
|
59 | # Date 0 0 | |||
|
60 | ||||
|
61 | diff --git a/a b/a | |||
|
62 | new file mode 100644 | |||
|
63 | --- /dev/null | |||
|
64 | +++ b/a | |||
|
65 | @@ -0,0 +1,1 @@ | |||
|
66 | +a | |||
|
67 | % git=yes: git patch after qrefresh | |||
|
68 | # HG changeset patch | |||
|
69 | # Date 0 0 | |||
|
70 | ||||
|
71 | diff --git a/a b/a | |||
|
72 | new file mode 100644 | |||
|
73 | --- /dev/null | |||
|
74 | +++ b/a | |||
|
75 | @@ -0,0 +1,2 @@ | |||
|
76 | +a | |||
|
77 | +a | |||
|
78 | % git=no: regular patch with copy | |||
|
79 | # HG changeset patch | |||
|
80 | # Date 0 0 | |||
|
81 | ||||
|
82 | diff -r ef8dafc9fa4c -r 110cde11d262 b | |||
|
83 | --- /dev/null | |||
|
84 | +++ b/b | |||
|
85 | @@ -0,0 +1,1 @@ | |||
|
86 | +a | |||
|
87 | % git=no: regular patch after qrefresh with copy | |||
|
88 | # HG changeset patch | |||
|
89 | # Date 0 0 | |||
|
90 | ||||
|
91 | diff -r ef8dafc9fa4c b | |||
|
92 | --- /dev/null | |||
|
93 | +++ b/b | |||
|
94 | @@ -0,0 +1,1 @@ | |||
|
95 | +a | |||
|
96 | diff -r ef8dafc9fa4c c | |||
|
97 | --- /dev/null | |||
|
98 | +++ b/c | |||
|
99 | @@ -0,0 +1,1 @@ | |||
|
100 | +a |
@@ -26,6 +26,18 b' Common tasks (use "hg help command" for ' | |||||
26 | add known patch to applied stack qpush |
|
26 | add known patch to applied stack qpush | |
27 | remove patch from applied stack qpop |
|
27 | remove patch from applied stack qpop | |
28 | refresh contents of top applied patch qrefresh |
|
28 | refresh contents of top applied patch qrefresh | |
|
29 | ||||
|
30 | By default, mq will automatically use git patches when required to | |||
|
31 | avoid losing file mode changes, copy records, binary files or empty | |||
|
32 | files creations or deletions. This behaviour can be configured with:: | |||
|
33 | ||||
|
34 | [mq] | |||
|
35 | git = auto/keep/yes/no | |||
|
36 | ||||
|
37 | If set to 'keep', mq will obey the [diff] section configuration while | |||
|
38 | preserving existing git patches upon qrefresh. If set to 'yes' or | |||
|
39 | 'no', mq will override the [diff] section and always generate git or | |||
|
40 | regular patches, possibly losing data in the second case. | |||
29 | ''' |
|
41 | ''' | |
30 |
|
42 | |||
31 | from mercurial.i18n import _ |
|
43 | from mercurial.i18n import _ | |
@@ -225,6 +237,14 b' class queue(object):' | |||||
225 | self.guards_path = "guards" |
|
237 | self.guards_path = "guards" | |
226 | self.active_guards = None |
|
238 | self.active_guards = None | |
227 | self.guards_dirty = False |
|
239 | self.guards_dirty = False | |
|
240 | # Handle mq.git as a bool with extended values | |||
|
241 | try: | |||
|
242 | gitmode = ui.configbool('mq', 'git', None) | |||
|
243 | if gitmode is None: | |||
|
244 | raise error.ConfigError() | |||
|
245 | self.gitmode = gitmode and 'yes' or 'no' | |||
|
246 | except error.ConfigError: | |||
|
247 | self.gitmode = ui.config('mq', 'git', 'auto').lower() | |||
228 |
|
248 | |||
229 | @util.propertycache |
|
249 | @util.propertycache | |
230 | def applied(self): |
|
250 | def applied(self): | |
@@ -260,23 +280,33 b' class queue(object):' | |||||
260 |
|
280 | |||
261 | def diffopts(self, opts={}, patchfn=None): |
|
281 | def diffopts(self, opts={}, patchfn=None): | |
262 | diffopts = patch.diffopts(self.ui, opts) |
|
282 | diffopts = patch.diffopts(self.ui, opts) | |
|
283 | if self.gitmode == 'auto': | |||
|
284 | diffopts.upgrade = True | |||
|
285 | elif self.gitmode == 'keep': | |||
|
286 | pass | |||
|
287 | elif self.gitmode in ('yes', 'no'): | |||
|
288 | diffopts.git = self.gitmode == 'yes' | |||
|
289 | else: | |||
|
290 | raise util.Abort(_('mq.git option can be auto/keep/yes/no' | |||
|
291 | ' got %s') % self.gitmode) | |||
263 | if patchfn: |
|
292 | if patchfn: | |
264 | diffopts = self.patchopts(diffopts, patchfn) |
|
293 | diffopts = self.patchopts(diffopts, patchfn) | |
265 | return diffopts |
|
294 | return diffopts | |
266 |
|
295 | |||
267 | def patchopts(self, diffopts, *patches): |
|
296 | def patchopts(self, diffopts, *patches): | |
268 | """Return a copy of input diff options with git set to true if |
|
297 | """Return a copy of input diff options with git set to true if | |
269 | referenced patch is a git patch. |
|
298 | referenced patch is a git patch and should be preserved as such. | |
270 | """ |
|
299 | """ | |
271 | diffopts = diffopts.copy() |
|
300 | diffopts = diffopts.copy() | |
272 | for patchfn in patches: |
|
301 | if not diffopts.git and self.gitmode == 'keep': | |
273 | patchf = self.opener(patchfn, 'r') |
|
302 | for patchfn in patches: | |
274 | # if the patch was a git patch, refresh it as a git patch |
|
303 | patchf = self.opener(patchfn, 'r') | |
275 | for line in patchf: |
|
304 | # if the patch was a git patch, refresh it as a git patch | |
276 |
|
|
305 | for line in patchf: | |
277 | diffopts.git = True |
|
306 | if line.startswith('diff --git'): | |
278 |
|
|
307 | diffopts.git = True | |
279 | patchf.close() |
|
308 | break | |
|
309 | patchf.close() | |||
280 | return diffopts |
|
310 | return diffopts | |
281 |
|
311 | |||
282 | def join(self, *p): |
|
312 | def join(self, *p): | |
@@ -1260,7 +1290,7 b' class queue(object):' | |||||
1260 | patchf.write(chunk) |
|
1290 | patchf.write(chunk) | |
1261 |
|
1291 | |||
1262 | try: |
|
1292 | try: | |
1263 | if diffopts.git: |
|
1293 | if diffopts.git or diffopts.upgrade: | |
1264 | copies = {} |
|
1294 | copies = {} | |
1265 | for dst in a: |
|
1295 | for dst in a: | |
1266 | src = repo.dirstate.copied(dst) |
|
1296 | src = repo.dirstate.copied(dst) |
@@ -4,6 +4,8 b'' | |||||
4 |
|
4 | |||
5 | echo "[extensions]" >> $HGRCPATH |
|
5 | echo "[extensions]" >> $HGRCPATH | |
6 | echo "mq=" >> $HGRCPATH |
|
6 | echo "mq=" >> $HGRCPATH | |
|
7 | echo "[diff]" >> $HGRCPATH | |||
|
8 | echo "nodates=1" >> $HGRCPATH | |||
7 |
|
9 | |||
8 | cat > makepatch.py <<EOF |
|
10 | cat > makepatch.py <<EOF | |
9 | f = file('eol.diff', 'wb') |
|
11 | f = file('eol.diff', 'wb') |
@@ -23,7 +23,7 b' applying eol.diff' | |||||
23 | now at: eol.diff |
|
23 | now at: eol.diff | |
24 | test message<LF> |
|
24 | test message<LF> | |
25 | <LF> |
|
25 | <LF> | |
26 |
diff - |
|
26 | diff -r 0d0bf99a8b7a a<LF> | |
27 | --- a/a<LF> |
|
27 | --- a/a<LF> | |
28 | +++ b/a<LF> |
|
28 | +++ b/a<LF> | |
29 | @@ -1,5 +1,5 @@<LF> |
|
29 | @@ -1,5 +1,5 @@<LF> |
@@ -16,6 +16,8 b' checkundo()' | |||||
16 |
|
16 | |||
17 | echo "[extensions]" >> $HGRCPATH |
|
17 | echo "[extensions]" >> $HGRCPATH | |
18 | echo "mq =" >> $HGRCPATH |
|
18 | echo "mq =" >> $HGRCPATH | |
|
19 | echo "[mq]" >> $HGRCPATH | |||
|
20 | echo "git = keep" >> $HGRCPATH | |||
19 |
|
21 | |||
20 | # Commit two dummy files in "init" changeset |
|
22 | # Commit two dummy files in "init" changeset | |
21 | hg init t |
|
23 | hg init t |
@@ -2,6 +2,8 b'' | |||||
2 |
|
2 | |||
3 | echo "[extensions]" >> $HGRCPATH |
|
3 | echo "[extensions]" >> $HGRCPATH | |
4 | echo "mq=" >> $HGRCPATH |
|
4 | echo "mq=" >> $HGRCPATH | |
|
5 | echo "[mq]" >> $HGRCPATH | |||
|
6 | echo "git=keep" >> $HGRCPATH | |||
5 |
|
7 | |||
6 | filterdiff() |
|
8 | filterdiff() | |
7 | { |
|
9 | { |
@@ -21,6 +21,18 b' Common tasks (use "hg help command" for ' | |||||
21 | remove patch from applied stack qpop |
|
21 | remove patch from applied stack qpop | |
22 | refresh contents of top applied patch qrefresh |
|
22 | refresh contents of top applied patch qrefresh | |
23 |
|
23 | |||
|
24 | By default, mq will automatically use git patches when required to avoid | |||
|
25 | losing file mode changes, copy records, binary files or empty files creations | |||
|
26 | or deletions. This behaviour can be configured with: | |||
|
27 | ||||
|
28 | [mq] | |||
|
29 | git = auto/keep/yes/no | |||
|
30 | ||||
|
31 | If set to 'keep', mq will obey the [diff] section configuration while | |||
|
32 | preserving existing git patches upon qrefresh. If set to 'yes' or 'no', mq | |||
|
33 | will override the [diff] section and always generate git or regular patches, | |||
|
34 | possibly losing data in the second case. | |||
|
35 | ||||
24 | list of commands: |
|
36 | list of commands: | |
25 |
|
37 | |||
26 | qapplied print the patches already applied |
|
38 | qapplied print the patches already applied |
General Comments 0
You need to be logged in to leave comments.
Login now