Show More
@@ -14,7 +14,7 b' http://www.selenic.com/mercurial/wiki/in' | |||||
14 | ''' |
|
14 | ''' | |
15 |
|
15 | |||
16 | from mercurial import util, repair, merge, cmdutil, commands, error |
|
16 | from mercurial import util, repair, merge, cmdutil, commands, error | |
17 | from mercurial import extensions, ancestor, copies |
|
17 | from mercurial import extensions, ancestor, copies, patch | |
18 | from mercurial.commands import templateopts |
|
18 | from mercurial.commands import templateopts | |
19 | from mercurial.node import nullrev |
|
19 | from mercurial.node import nullrev | |
20 | from mercurial.i18n import _ |
|
20 | from mercurial.i18n import _ | |
@@ -264,6 +264,14 b' def defineparents(repo, rev, target, sta' | |||||
264 | p2 = P2n |
|
264 | p2 = P2n | |
265 | return p1, p2 |
|
265 | return p1, p2 | |
266 |
|
266 | |||
|
267 | def isagitpatch(repo, patchname): | |||
|
268 | 'Return true if the given patch is in git format' | |||
|
269 | mqpatch = os.path.join(repo.mq.path, patchname) | |||
|
270 | for line in patch.linereader(file(mqpatch, 'rb')): | |||
|
271 | if line.startswith('diff --git'): | |||
|
272 | return True | |||
|
273 | return False | |||
|
274 | ||||
267 | def updatemq(repo, state, skipped, **opts): |
|
275 | def updatemq(repo, state, skipped, **opts): | |
268 | 'Update rebased mq patches - finalize and then import them' |
|
276 | 'Update rebased mq patches - finalize and then import them' | |
269 | mqrebase = {} |
|
277 | mqrebase = {} | |
@@ -271,7 +279,7 b' def updatemq(repo, state, skipped, **opt' | |||||
271 | if repo[p.rev].rev() in state: |
|
279 | if repo[p.rev].rev() in state: | |
272 | repo.ui.debug(_('revision %d is an mq patch (%s), finalize it.\n') % |
|
280 | repo.ui.debug(_('revision %d is an mq patch (%s), finalize it.\n') % | |
273 | (repo[p.rev].rev(), p.name)) |
|
281 | (repo[p.rev].rev(), p.name)) | |
274 | mqrebase[repo[p.rev].rev()] = p.name |
|
282 | mqrebase[repo[p.rev].rev()] = (p.name, isagitpatch(repo, p.name)) | |
275 |
|
283 | |||
276 | if mqrebase: |
|
284 | if mqrebase: | |
277 | repo.mq.finish(repo, mqrebase.keys()) |
|
285 | repo.mq.finish(repo, mqrebase.keys()) | |
@@ -283,9 +291,9 b' def updatemq(repo, state, skipped, **opt' | |||||
283 | for rev in mq: |
|
291 | for rev in mq: | |
284 | if rev not in skipped: |
|
292 | if rev not in skipped: | |
285 | repo.ui.debug(_('import mq patch %d (%s)\n') |
|
293 | repo.ui.debug(_('import mq patch %d (%s)\n') | |
286 | % (state[rev], mqrebase[rev])) |
|
294 | % (state[rev], mqrebase[rev][0])) | |
287 | repo.mq.qimport(repo, (), patchname=mqrebase[rev], |
|
295 | repo.mq.qimport(repo, (), patchname=mqrebase[rev][0], | |
288 |
git= |
|
296 | git=mqrebase[rev][1],rev=[str(state[rev])]) | |
289 | repo.mq.save_dirty() |
|
297 | repo.mq.save_dirty() | |
290 |
|
298 | |||
291 | def storestatus(repo, originalwd, target, state, collapse, keep, keepbranches, |
|
299 | def storestatus(repo, originalwd, target, state, collapse, keep, keepbranches, |
@@ -11,6 +11,7 b' filterpatch()' | |||||
11 | -e "s/^\(# Node ID\).*/\1/" \ |
|
11 | -e "s/^\(# Node ID\).*/\1/" \ | |
12 | -e "s/^\(# Parent\).*/\1/" \ |
|
12 | -e "s/^\(# Parent\).*/\1/" \ | |
13 | -e "s/^\(diff -r \)\([a-f0-9]* \)\(-r \)\([a-f0-9]* \)/\1x \3y /" \ |
|
13 | -e "s/^\(diff -r \)\([a-f0-9]* \)\(-r \)\([a-f0-9]* \)/\1x \3y /" \ | |
|
14 | -e "s/^\(diff -r \)\([a-f0-9]* \)/\1x /" \ | |||
14 | -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/" \ |
|
15 | -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/" \ | |
15 | -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" |
|
16 | -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" | |
16 | } |
|
17 | } | |
@@ -74,3 +75,38 b' cat f' | |||||
74 | echo '% And the patch is correct' |
|
75 | echo '% And the patch is correct' | |
75 | cat .hg/patches/f2.patch | filterpatch |
|
76 | cat .hg/patches/f2.patch | filterpatch | |
76 |
|
77 | |||
|
78 | echo | |||
|
79 | echo '% Adding one git-style patch and one normal' | |||
|
80 | hg qpop -a | |||
|
81 | rm -fr .hg/patches | |||
|
82 | hg qinit -c | |||
|
83 | ||||
|
84 | hg up 0 | |||
|
85 | hg qnew --git f_git.patch | |||
|
86 | echo 'mq1' > p | |||
|
87 | hg add p | |||
|
88 | hg qref --git -m 'P0 (git)' | |||
|
89 | ||||
|
90 | hg qnew f.patch | |||
|
91 | echo 'mq2' > p | |||
|
92 | hg qref -m 'P1' | |||
|
93 | ||||
|
94 | echo '% Git patch' | |||
|
95 | cat .hg/patches/f_git.patch | filterpatch | |||
|
96 | ||||
|
97 | echo | |||
|
98 | echo '% Normal patch' | |||
|
99 | cat .hg/patches/f.patch | filterpatch | |||
|
100 | ||||
|
101 | echo | |||
|
102 | echo '% Rebase the applied mq patches' | |||
|
103 | hg rebase -s 2 -d 1 --quiet 2>&1 | sed -e 's/\(saving bundle to \).*/\1/' | |||
|
104 | ||||
|
105 | echo '% And the patches are correct' | |||
|
106 | echo '% Git patch' | |||
|
107 | cat .hg/patches/f_git.patch | filterpatch | |||
|
108 | ||||
|
109 | echo | |||
|
110 | echo '% Normal patch' | |||
|
111 | cat .hg/patches/f.patch | filterpatch | |||
|
112 |
@@ -77,3 +77,58 b' diff -r x -r y f' | |||||
77 | @@ -1,1 +1,1 @@ |
|
77 | @@ -1,1 +1,1 @@ | |
78 | -mq1r1 |
|
78 | -mq1r1 | |
79 | +mq1r1mq2 |
|
79 | +mq1r1mq2 | |
|
80 | ||||
|
81 | % Adding one git-style patch and one normal | |||
|
82 | patch queue now empty | |||
|
83 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
84 | % Git patch | |||
|
85 | P0 (git) | |||
|
86 | ||||
|
87 | diff --git a/p b/p | |||
|
88 | new file mode 100644 | |||
|
89 | --- /dev/null | |||
|
90 | +++ b/p | |||
|
91 | @@ -0,0 +1,1 @@ | |||
|
92 | +mq1 | |||
|
93 | ||||
|
94 | % Normal patch | |||
|
95 | P1 | |||
|
96 | ||||
|
97 | diff -r x p | |||
|
98 | --- a/p | |||
|
99 | +++ b/p | |||
|
100 | @@ -1,1 +1,1 @@ | |||
|
101 | -mq1 | |||
|
102 | +mq2 | |||
|
103 | ||||
|
104 | % Rebase the applied mq patches | |||
|
105 | saving bundle to | |||
|
106 | % And the patches are correct | |||
|
107 | % Git patch | |||
|
108 | # HG changeset patch | |||
|
109 | # User test | |||
|
110 | # Date | |||
|
111 | # Node ID | |||
|
112 | # Parent | |||
|
113 | P0 (git) | |||
|
114 | ||||
|
115 | diff --git a/p b/p | |||
|
116 | new file mode 100644 | |||
|
117 | --- /dev/null | |||
|
118 | +++ b/p | |||
|
119 | @@ -0,0 +1,1 @@ | |||
|
120 | +mq1 | |||
|
121 | ||||
|
122 | % Normal patch | |||
|
123 | # HG changeset patch | |||
|
124 | # User test | |||
|
125 | # Date | |||
|
126 | # Node ID | |||
|
127 | # Parent | |||
|
128 | P1 | |||
|
129 | ||||
|
130 | --- a/p | |||
|
131 | +++ b/p | |||
|
132 | @@ -1,1 +1,1 @@ | |||
|
133 | -mq1 | |||
|
134 | +mq2 |
General Comments 0
You need to be logged in to leave comments.
Login now