Show More
@@ -0,0 +1,108 b'' | |||||
|
1 | #!/bin/sh | |||
|
2 | ||||
|
3 | echo "[extensions]" >> $HGRCPATH | |||
|
4 | echo "mq=" >> $HGRCPATH | |||
|
5 | echo "[diff]" >> $HGRCPATH | |||
|
6 | echo "nodates=true" >> $HGRCPATH | |||
|
7 | ||||
|
8 | ||||
|
9 | catlog() { | |||
|
10 | cat .hg/patches/$1.patch | sed -e "s/^diff \-r [0-9a-f]* /diff -r ... /" | |||
|
11 | hg log --template "{rev}: {desc} - {author}\n" | |||
|
12 | } | |||
|
13 | ||||
|
14 | ||||
|
15 | echo ==== init | |||
|
16 | hg init a | |||
|
17 | cd a | |||
|
18 | hg qinit | |||
|
19 | ||||
|
20 | ||||
|
21 | echo ==== qnew -U | |||
|
22 | hg qnew -U 1.patch | |||
|
23 | catlog 1 | |||
|
24 | ||||
|
25 | echo ==== qref | |||
|
26 | echo "1" >1 | |||
|
27 | hg add | |||
|
28 | hg qref | |||
|
29 | catlog 1 | |||
|
30 | ||||
|
31 | echo ==== qref -u | |||
|
32 | hg qref -u mary | |||
|
33 | catlog 1 | |||
|
34 | ||||
|
35 | echo ==== qnew | |||
|
36 | hg qnew 2.patch | |||
|
37 | echo "2" >2 | |||
|
38 | hg add | |||
|
39 | hg qref | |||
|
40 | catlog 2 | |||
|
41 | ||||
|
42 | echo ==== qref -u | |||
|
43 | hg qref -u jane | |||
|
44 | catlog 2 | |||
|
45 | ||||
|
46 | ||||
|
47 | echo ==== qnew -U -m | |||
|
48 | hg qnew -U -m "Three" 3.patch | |||
|
49 | catlog 3 | |||
|
50 | ||||
|
51 | echo ==== qref | |||
|
52 | echo "3" >3 | |||
|
53 | hg add | |||
|
54 | hg qref | |||
|
55 | catlog 3 | |||
|
56 | ||||
|
57 | echo ==== qref -m | |||
|
58 | hg qref -m "Drei" | |||
|
59 | catlog 3 | |||
|
60 | ||||
|
61 | echo ==== qref -u | |||
|
62 | hg qref -u mary | |||
|
63 | catlog 3 | |||
|
64 | ||||
|
65 | echo ==== qref -u -m | |||
|
66 | hg qref -u maria -m "Three (again)" | |||
|
67 | catlog 3 | |||
|
68 | ||||
|
69 | echo ==== qnew -m | |||
|
70 | hg qnew -m "Four" 4.patch | |||
|
71 | echo "4" >4 | |||
|
72 | hg add | |||
|
73 | hg qref | |||
|
74 | catlog 4 | |||
|
75 | ||||
|
76 | echo ==== qref -u | |||
|
77 | hg qref -u jane | |||
|
78 | catlog 4 | |||
|
79 | ||||
|
80 | ||||
|
81 | echo ==== qnew with HG header | |||
|
82 | hg qnew 5.patch | |||
|
83 | hg qpop | |||
|
84 | echo "# HG changeset patch" >>.hg/patches/5.patch | |||
|
85 | echo "# User johndoe" >>.hg/patches/5.patch | |||
|
86 | # Drop patch specific error line | |||
|
87 | hg qpush 2>&1 | grep -v garbage | |||
|
88 | catlog 5 | |||
|
89 | ||||
|
90 | echo ==== hg qref | |||
|
91 | echo "5" >5 | |||
|
92 | hg add | |||
|
93 | hg qref | |||
|
94 | catlog 5 | |||
|
95 | ||||
|
96 | echo ==== hg qref -U | |||
|
97 | hg qref -U | |||
|
98 | catlog 5 | |||
|
99 | ||||
|
100 | echo ==== hg qref -u | |||
|
101 | hg qref -u johndeere | |||
|
102 | catlog 5 | |||
|
103 | ||||
|
104 | ||||
|
105 | echo ==== "qpop -a / qpush -a" | |||
|
106 | hg qpop -a | |||
|
107 | hg qpush -a | |||
|
108 | hg log --template "{rev}: {desc} - {author}\n" |
@@ -0,0 +1,200 b'' | |||||
|
1 | ==== init | |||
|
2 | ==== qnew -U | |||
|
3 | From: test | |||
|
4 | ||||
|
5 | 0: [mq]: 1.patch - test | |||
|
6 | ==== qref | |||
|
7 | adding 1 | |||
|
8 | From: test | |||
|
9 | ||||
|
10 | diff -r ... 1 | |||
|
11 | --- /dev/null | |||
|
12 | +++ b/1 | |||
|
13 | @@ -0,0 +1,1 @@ | |||
|
14 | +1 | |||
|
15 | 0: [mq]: 1.patch - test | |||
|
16 | ==== qref -u | |||
|
17 | From: mary | |||
|
18 | ||||
|
19 | diff -r ... 1 | |||
|
20 | --- /dev/null | |||
|
21 | +++ b/1 | |||
|
22 | @@ -0,0 +1,1 @@ | |||
|
23 | +1 | |||
|
24 | 0: [mq]: 1.patch - mary | |||
|
25 | ==== qnew | |||
|
26 | adding 2 | |||
|
27 | diff -r ... 2 | |||
|
28 | --- /dev/null | |||
|
29 | +++ b/2 | |||
|
30 | @@ -0,0 +1,1 @@ | |||
|
31 | +2 | |||
|
32 | 1: [mq]: 2.patch - test | |||
|
33 | 0: [mq]: 1.patch - mary | |||
|
34 | ==== qref -u | |||
|
35 | From: jane | |||
|
36 | ||||
|
37 | ||||
|
38 | diff -r ... 2 | |||
|
39 | --- /dev/null | |||
|
40 | +++ b/2 | |||
|
41 | @@ -0,0 +1,1 @@ | |||
|
42 | +2 | |||
|
43 | 1: [mq]: 2.patch - jane | |||
|
44 | 0: [mq]: 1.patch - mary | |||
|
45 | ==== qnew -U -m | |||
|
46 | From: test | |||
|
47 | ||||
|
48 | Three | |||
|
49 | 2: Three - test | |||
|
50 | 1: [mq]: 2.patch - jane | |||
|
51 | 0: [mq]: 1.patch - mary | |||
|
52 | ==== qref | |||
|
53 | adding 3 | |||
|
54 | From: test | |||
|
55 | ||||
|
56 | Three | |||
|
57 | ||||
|
58 | diff -r ... 3 | |||
|
59 | --- /dev/null | |||
|
60 | +++ b/3 | |||
|
61 | @@ -0,0 +1,1 @@ | |||
|
62 | +3 | |||
|
63 | 2: Three - test | |||
|
64 | 1: [mq]: 2.patch - jane | |||
|
65 | 0: [mq]: 1.patch - mary | |||
|
66 | ==== qref -m | |||
|
67 | From: test | |||
|
68 | ||||
|
69 | Drei | |||
|
70 | ||||
|
71 | diff -r ... 3 | |||
|
72 | --- /dev/null | |||
|
73 | +++ b/3 | |||
|
74 | @@ -0,0 +1,1 @@ | |||
|
75 | +3 | |||
|
76 | 2: Drei - test | |||
|
77 | 1: [mq]: 2.patch - jane | |||
|
78 | 0: [mq]: 1.patch - mary | |||
|
79 | ==== qref -u | |||
|
80 | From: mary | |||
|
81 | ||||
|
82 | Drei | |||
|
83 | ||||
|
84 | diff -r ... 3 | |||
|
85 | --- /dev/null | |||
|
86 | +++ b/3 | |||
|
87 | @@ -0,0 +1,1 @@ | |||
|
88 | +3 | |||
|
89 | 2: Drei - mary | |||
|
90 | 1: [mq]: 2.patch - jane | |||
|
91 | 0: [mq]: 1.patch - mary | |||
|
92 | ==== qref -u -m | |||
|
93 | From: maria | |||
|
94 | ||||
|
95 | Three (again) | |||
|
96 | ||||
|
97 | diff -r ... 3 | |||
|
98 | --- /dev/null | |||
|
99 | +++ b/3 | |||
|
100 | @@ -0,0 +1,1 @@ | |||
|
101 | +3 | |||
|
102 | 2: Three (again) - maria | |||
|
103 | 1: [mq]: 2.patch - jane | |||
|
104 | 0: [mq]: 1.patch - mary | |||
|
105 | ==== qnew -m | |||
|
106 | adding 4 | |||
|
107 | Four | |||
|
108 | ||||
|
109 | diff -r ... 4 | |||
|
110 | --- /dev/null | |||
|
111 | +++ b/4 | |||
|
112 | @@ -0,0 +1,1 @@ | |||
|
113 | +4 | |||
|
114 | 3: Four - test | |||
|
115 | 2: Three (again) - maria | |||
|
116 | 1: [mq]: 2.patch - jane | |||
|
117 | 0: [mq]: 1.patch - mary | |||
|
118 | ==== qref -u | |||
|
119 | From: jane | |||
|
120 | ||||
|
121 | Four | |||
|
122 | ||||
|
123 | diff -r ... 4 | |||
|
124 | --- /dev/null | |||
|
125 | +++ b/4 | |||
|
126 | @@ -0,0 +1,1 @@ | |||
|
127 | +4 | |||
|
128 | 3: Four - jane | |||
|
129 | 2: Three (again) - maria | |||
|
130 | 1: [mq]: 2.patch - jane | |||
|
131 | 0: [mq]: 1.patch - mary | |||
|
132 | ==== qnew with HG header | |||
|
133 | Now at: 4.patch | |||
|
134 | applying 5.patch | |||
|
135 | patch failed, unable to continue (try -v) | |||
|
136 | patch 5.patch is empty | |||
|
137 | Now at: 5.patch | |||
|
138 | # HG changeset patch | |||
|
139 | # User johndoe | |||
|
140 | 4: imported patch 5.patch - johndoe | |||
|
141 | 3: Four - jane | |||
|
142 | 2: Three (again) - maria | |||
|
143 | 1: [mq]: 2.patch - jane | |||
|
144 | 0: [mq]: 1.patch - mary | |||
|
145 | ==== hg qref | |||
|
146 | adding 5 | |||
|
147 | # HG changeset patch | |||
|
148 | # User johndoe | |||
|
149 | ||||
|
150 | diff -r ... 5 | |||
|
151 | --- /dev/null | |||
|
152 | +++ b/5 | |||
|
153 | @@ -0,0 +1,1 @@ | |||
|
154 | +5 | |||
|
155 | 4: [mq]: 5.patch - johndoe | |||
|
156 | 3: Four - jane | |||
|
157 | 2: Three (again) - maria | |||
|
158 | 1: [mq]: 2.patch - jane | |||
|
159 | 0: [mq]: 1.patch - mary | |||
|
160 | ==== hg qref -U | |||
|
161 | # HG changeset patch | |||
|
162 | # User test | |||
|
163 | ||||
|
164 | diff -r ... 5 | |||
|
165 | --- /dev/null | |||
|
166 | +++ b/5 | |||
|
167 | @@ -0,0 +1,1 @@ | |||
|
168 | +5 | |||
|
169 | 4: [mq]: 5.patch - test | |||
|
170 | 3: Four - jane | |||
|
171 | 2: Three (again) - maria | |||
|
172 | 1: [mq]: 2.patch - jane | |||
|
173 | 0: [mq]: 1.patch - mary | |||
|
174 | ==== hg qref -u | |||
|
175 | # HG changeset patch | |||
|
176 | # User johndeere | |||
|
177 | ||||
|
178 | diff -r ... 5 | |||
|
179 | --- /dev/null | |||
|
180 | +++ b/5 | |||
|
181 | @@ -0,0 +1,1 @@ | |||
|
182 | +5 | |||
|
183 | 4: [mq]: 5.patch - johndeere | |||
|
184 | 3: Four - jane | |||
|
185 | 2: Three (again) - maria | |||
|
186 | 1: [mq]: 2.patch - jane | |||
|
187 | 0: [mq]: 1.patch - mary | |||
|
188 | ==== qpop -a / qpush -a | |||
|
189 | Patch queue now empty | |||
|
190 | applying 1.patch | |||
|
191 | applying 2.patch | |||
|
192 | applying 3.patch | |||
|
193 | applying 4.patch | |||
|
194 | applying 5.patch | |||
|
195 | Now at: 5.patch | |||
|
196 | 4: imported patch 5.patch - johndeere | |||
|
197 | 3: Four - jane | |||
|
198 | 2: Three (again) - maria | |||
|
199 | 1: imported patch 2.patch - jane | |||
|
200 | 0: imported patch 1.patch - mary |
@@ -603,6 +603,7 b' class queue:' | |||||
603 | def new(self, repo, patch, *pats, **opts): |
|
603 | def new(self, repo, patch, *pats, **opts): | |
604 | msg = opts.get('msg') |
|
604 | msg = opts.get('msg') | |
605 | force = opts.get('force') |
|
605 | force = opts.get('force') | |
|
606 | user = opts.get('user') | |||
606 | if os.path.exists(self.join(patch)): |
|
607 | if os.path.exists(self.join(patch)): | |
607 | raise util.Abort(_('patch "%s" already exists') % patch) |
|
608 | raise util.Abort(_('patch "%s" already exists') % patch) | |
608 | if opts.get('include') or opts.get('exclude') or pats: |
|
609 | if opts.get('include') or opts.get('exclude') or pats: | |
@@ -617,7 +618,7 b' class queue:' | |||||
617 | try: |
|
618 | try: | |
618 | insert = self.full_series_end() |
|
619 | insert = self.full_series_end() | |
619 | commitmsg = msg and msg or ("[mq]: %s" % patch) |
|
620 | commitmsg = msg and msg or ("[mq]: %s" % patch) | |
620 | n = repo.commit(commitfiles, commitmsg, match=match, force=True) |
|
621 | n = repo.commit(commitfiles, commitmsg, user, match=match, force=True) | |
621 | if n == None: |
|
622 | if n == None: | |
622 | raise util.Abort(_("repo commit failed")) |
|
623 | raise util.Abort(_("repo commit failed")) | |
623 | self.full_series[insert:insert] = [patch] |
|
624 | self.full_series[insert:insert] = [patch] | |
@@ -626,6 +627,8 b' class queue:' | |||||
626 | self.series_dirty = 1 |
|
627 | self.series_dirty = 1 | |
627 | self.applied_dirty = 1 |
|
628 | self.applied_dirty = 1 | |
628 | p = self.opener(patch, "w") |
|
629 | p = self.opener(patch, "w") | |
|
630 | if user: | |||
|
631 | p.write("From: " + user + "\n\n") | |||
629 | if msg: |
|
632 | if msg: | |
630 | msg = msg + "\n" |
|
633 | msg = msg + "\n" | |
631 | p.write(msg) |
|
634 | p.write(msg) | |
@@ -945,6 +948,22 b' class queue:' | |||||
945 | while message[mi] != comments[ci]: |
|
948 | while message[mi] != comments[ci]: | |
946 | ci += 1 |
|
949 | ci += 1 | |
947 | del comments[ci] |
|
950 | del comments[ci] | |
|
951 | ||||
|
952 | newuser = opts.get('user') | |||
|
953 | if newuser: | |||
|
954 | # Update all references to a user in the patch header. | |||
|
955 | # If none found, add "From: " header. | |||
|
956 | needfrom = True | |||
|
957 | for prefix in ['# User ', 'From: ']: | |||
|
958 | for i in xrange(len(comments)): | |||
|
959 | if comments[i].startswith(prefix): | |||
|
960 | comments[i] = prefix + newuser | |||
|
961 | needfrom = False | |||
|
962 | break | |||
|
963 | if needfrom: | |||
|
964 | comments = ['From: ' + newuser, ''] + comments | |||
|
965 | user = newuser | |||
|
966 | ||||
948 | if msg: |
|
967 | if msg: | |
949 | comments.append(msg) |
|
968 | comments.append(msg) | |
950 |
|
969 | |||
@@ -1070,9 +1089,12 b' class queue:' | |||||
1070 | else: |
|
1089 | else: | |
1071 | message = msg |
|
1090 | message = msg | |
1072 |
|
1091 | |||
|
1092 | if not user: | |||
|
1093 | user = changes[1] | |||
|
1094 | ||||
1073 | self.strip(repo, top, update=False, |
|
1095 | self.strip(repo, top, update=False, | |
1074 | backup='strip') |
|
1096 | backup='strip') | |
1075 |
n = repo.commit(filelist, message, |
|
1097 | n = repo.commit(filelist, message, user, match=matchfn, | |
1076 | force=1) |
|
1098 | force=1) | |
1077 | self.applied[-1] = statusentry(revlog.hex(n), patchfn) |
|
1099 | self.applied[-1] = statusentry(revlog.hex(n), patchfn) | |
1078 | self.applied_dirty = 1 |
|
1100 | self.applied_dirty = 1 | |
@@ -1605,6 +1627,12 b' def prev(ui, repo, **opts):' | |||||
1605 | return q.qseries(repo, start=l-2, length=1, status='A', |
|
1627 | return q.qseries(repo, start=l-2, length=1, status='A', | |
1606 | summary=opts.get('summary')) |
|
1628 | summary=opts.get('summary')) | |
1607 |
|
1629 | |||
|
1630 | def setupheaderopts(ui, opts): | |||
|
1631 | def do(opt,val): | |||
|
1632 | if not opts[opt] and opts['current' + opt]: | |||
|
1633 | opts[opt] = val | |||
|
1634 | do('user', ui.username()) | |||
|
1635 | ||||
1608 | def new(ui, repo, patch, *args, **opts): |
|
1636 | def new(ui, repo, patch, *args, **opts): | |
1609 | """create a new patch |
|
1637 | """create a new patch | |
1610 |
|
1638 | |||
@@ -1623,6 +1651,7 b' def new(ui, repo, patch, *args, **opts):' | |||||
1623 | if opts['edit']: |
|
1651 | if opts['edit']: | |
1624 | message = ui.edit(message, ui.username()) |
|
1652 | message = ui.edit(message, ui.username()) | |
1625 | opts['msg'] = message |
|
1653 | opts['msg'] = message | |
|
1654 | setupheaderopts(ui, opts) | |||
1626 | q.new(repo, patch, *args, **opts) |
|
1655 | q.new(repo, patch, *args, **opts) | |
1627 | q.save_dirty() |
|
1656 | q.save_dirty() | |
1628 | return 0 |
|
1657 | return 0 | |
@@ -1648,6 +1677,7 b' def refresh(ui, repo, *pats, **opts):' | |||||
1648 | patch = q.applied[-1].name |
|
1677 | patch = q.applied[-1].name | |
1649 | (message, comment, user, date, hasdiff) = q.readheaders(patch) |
|
1678 | (message, comment, user, date, hasdiff) = q.readheaders(patch) | |
1650 | message = ui.edit('\n'.join(message), user or ui.username()) |
|
1679 | message = ui.edit('\n'.join(message), user or ui.username()) | |
|
1680 | setupheaderopts(ui, opts) | |||
1651 | ret = q.refresh(repo, pats, msg=message, **opts) |
|
1681 | ret = q.refresh(repo, pats, msg=message, **opts) | |
1652 | q.save_dirty() |
|
1682 | q.save_dirty() | |
1653 | return ret |
|
1683 | return ret | |
@@ -2138,6 +2168,10 b' def reposetup(ui, repo):' | |||||
2138 |
|
2168 | |||
2139 | seriesopts = [('s', 'summary', None, _('print first line of patch header'))] |
|
2169 | seriesopts = [('s', 'summary', None, _('print first line of patch header'))] | |
2140 |
|
2170 | |||
|
2171 | headeropts = [ | |||
|
2172 | ('U', 'currentuser', None, _('add "From: <current user>" to patch')), | |||
|
2173 | ('u', 'user', '', _('add "From: <given user>" to patch'))] | |||
|
2174 | ||||
2141 | cmdtable = { |
|
2175 | cmdtable = { | |
2142 | "qapplied": (applied, [] + seriesopts, _('hg qapplied [-s] [PATCH]')), |
|
2176 | "qapplied": (applied, [] + seriesopts, _('hg qapplied [-s] [PATCH]')), | |
2143 | "qclone": |
|
2177 | "qclone": | |
@@ -2196,7 +2230,7 b' cmdtable = {' | |||||
2196 | [('e', 'edit', None, _('edit commit message')), |
|
2230 | [('e', 'edit', None, _('edit commit message')), | |
2197 | ('f', 'force', None, _('import uncommitted changes into patch')), |
|
2231 | ('f', 'force', None, _('import uncommitted changes into patch')), | |
2198 | ('g', 'git', None, _('use git extended diff format')), |
|
2232 | ('g', 'git', None, _('use git extended diff format')), | |
2199 | ] + commands.walkopts + commands.commitopts, |
|
2233 | ] + commands.walkopts + commands.commitopts + headeropts, | |
2200 | _('hg qnew [-e] [-m TEXT] [-l FILE] [-f] PATCH [FILE]...')), |
|
2234 | _('hg qnew [-e] [-m TEXT] [-l FILE] [-f] PATCH [FILE]...')), | |
2201 | "qnext": (next, [] + seriesopts, _('hg qnext [-s]')), |
|
2235 | "qnext": (next, [] + seriesopts, _('hg qnext [-s]')), | |
2202 | "qprev": (prev, [] + seriesopts, _('hg qprev [-s]')), |
|
2236 | "qprev": (prev, [] + seriesopts, _('hg qprev [-s]')), | |
@@ -2219,7 +2253,7 b' cmdtable = {' | |||||
2219 | [('e', 'edit', None, _('edit commit message')), |
|
2253 | [('e', 'edit', None, _('edit commit message')), | |
2220 | ('g', 'git', None, _('use git extended diff format')), |
|
2254 | ('g', 'git', None, _('use git extended diff format')), | |
2221 | ('s', 'short', None, _('refresh only files already in the patch')), |
|
2255 | ('s', 'short', None, _('refresh only files already in the patch')), | |
2222 | ] + commands.walkopts + commands.commitopts, |
|
2256 | ] + commands.walkopts + commands.commitopts + headeropts, | |
2223 | _('hg qrefresh [-I] [-X] [-e] [-m TEXT] [-l FILE] [-s] [FILE]...')), |
|
2257 | _('hg qrefresh [-I] [-X] [-e] [-m TEXT] [-l FILE] [-s] [FILE]...')), | |
2224 | 'qrename|qmv': |
|
2258 | 'qrename|qmv': | |
2225 | (rename, [], _('hg qrename PATCH1 [PATCH2]')), |
|
2259 | (rename, [], _('hg qrename PATCH1 [PATCH2]')), |
General Comments 0
You need to be logged in to leave comments.
Login now