##// END OF EJS Templates
mq: preserve --git flag when merging patches...
Patrick Mezard -
r10185:7637fe4f stable
parent child Browse files
Show More
@@ -261,12 +261,21 b' class queue(object):'
261 def diffopts(self, opts={}, patchfn=None):
261 def diffopts(self, opts={}, patchfn=None):
262 diffopts = patch.diffopts(self.ui, opts)
262 diffopts = patch.diffopts(self.ui, opts)
263 if patchfn:
263 if patchfn:
264 # if the patch was a git patch, refresh it as a git patch
264 diffopts = self.patchopts(diffopts, patchfn)
265 patchf = self.opener(patchfn, 'r')
265 return diffopts
266 for line in patchf:
266
267 if line.startswith('diff --git'):
267 def patchopts(self, diffopts, patchfn):
268 diffopts.git = True
268 """Return a copy of input diff options with git set to true if
269 break
269 referenced patch is a git patch.
270 """
271 diffopts = diffopts.copy()
272 patchf = self.opener(patchfn, 'r')
273 # if the patch was a git patch, refresh it as a git patch
274 for line in patchf:
275 if line.startswith('diff --git'):
276 diffopts.git = True
277 break
278 patchf.close()
270 return diffopts
279 return diffopts
271
280
272 def join(self, *p):
281 def join(self, *p):
@@ -469,6 +478,7 b' class queue(object):'
469 except:
478 except:
470 raise util.Abort(_("unable to read %s") % patch)
479 raise util.Abort(_("unable to read %s") % patch)
471
480
481 diffopts = self.patchopts(diffopts, patch)
472 patchf = self.opener(patch, "w")
482 patchf = self.opener(patch, "w")
473 comments = str(ph)
483 comments = str(ph)
474 if comments:
484 if comments:
@@ -55,6 +55,11 b' class diffopts(object):'
55 raise util.Abort(_('diff context lines count must be '
55 raise util.Abort(_('diff context lines count must be '
56 'an integer, not %r') % self.context)
56 'an integer, not %r') % self.context)
57
57
58 def copy(self, **kwargs):
59 opts = dict((k, getattr(self, k)) for k in self.defaults)
60 opts.update(kwargs)
61 return diffopts(**opts)
62
58 defaultopts = diffopts()
63 defaultopts = diffopts()
59
64
60 def wsclean(opts, text, blank=True):
65 def wsclean(opts, text, blank=True):
@@ -56,18 +56,27 b' echo'
56 echo % init t2
56 echo % init t2
57 hg init t2
57 hg init t2
58 cd t2
58 cd t2
59 echo '[diff]' > .hg/hgrc
60 echo 'nodates = 1' >> .hg/hgrc
59 echo a > a
61 echo a > a
60 hg ci -Am init
62 hg ci -Am init
61 echo b >> a
63 echo b > a
62 hg ci -m changea
64 hg ci -m changea
63 hg up -C 0
65 hg up -C 0
66 hg cp a aa
64 echo c >> a
67 echo c >> a
65 hg qnew -f -e patcha
68 hg qnew --git -f -e patcha
69 echo d >> a
70 hg qnew -d '0 0' -f -e patcha2
66 echo % create the reference queue
71 echo % create the reference queue
67 hg qsave -c -e -n refqueue 2> /dev/null
72 hg qsave -c -e -n refqueue 2> /dev/null
68 hg up -C 1
73 hg up -C 1
69 echo % merge
74 echo % merge
70 hg qpush -m -n refqueue 2>&1 | \
75 HGMERGE=internal:other hg qpush -a -m -n refqueue 2>&1 | \
71 sed 's/merging with queue at.*refqueue/merging with queue at refqueue/'
76 sed 's/merging with queue at.*refqueue/merging with queue at refqueue/'
77 echo % check patcha is still a git patch
78 cat .hg/patches/patcha
79 echo % check patcha2 is still a regular patch
80 grep git .hg/patches/patcha2 && echo 'git patch found!'
72 cd ..
81 cd ..
73
82
@@ -18,8 +18,35 b' patch queue now empty'
18 adding a
18 adding a
19 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
19 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
20 % create the reference queue
20 % create the reference queue
21 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
21 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
22 % merge
22 % merge
23 merging with queue at refqueue
23 merging with queue at refqueue
24 applying patcha
24 applying patcha
25 now at: patcha
25 patching file a
26 Hunk #1 FAILED at 0
27 1 out of 1 hunks FAILED -- saving rejects to file a.rej
28 patch failed, unable to continue (try -v)
29 patch failed, rejects left in working dir
30 patch didn't work out, merging patcha
31 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
32 0 files updated, 2 files merged, 0 files removed, 0 files unresolved
33 (branch merge, don't forget to commit)
34 applying patcha2
35 now at: patcha2
36 % check patcha is still a git patch
37 diff --git a/a b/a
38 --- a/a
39 +++ b/a
40 @@ -1,1 +1,2 @@
41 -b
42 +a
43 +c
44 diff --git a/a b/aa
45 copy from a
46 copy to aa
47 --- a/a
48 +++ b/aa
49 @@ -1,1 +1,1 @@
50 -b
51 +a
52 % check patcha2 is still a regular patch
General Comments 0
You need to be logged in to leave comments. Login now