##// END OF EJS Templates
rebase: add dry-run functionality...
Sushil khanchi -
r38391:f4f1fb1c default
parent child Browse files
Show More
@@ -673,8 +673,7 b' class rebaseruntime(object):'
673 673 ('a', 'abort', False, _('abort an interrupted rebase')),
674 674 ('', 'auto-orphans', '', _('automatically rebase orphan revisions '
675 675 'in the specified revset (EXPERIMENTAL)')),
676 ] +
677 cmdutil.formatteropts,
676 ] + cmdutil.dryrunopts + cmdutil.formatteropts,
678 677 _('[-s REV | -b REV] [-d REV] [OPTION]'))
679 678 def rebase(ui, repo, **opts):
680 679 """move changeset (and descendants) to a different branch
@@ -798,6 +797,13 b' def rebase(ui, repo, **opts):'
798 797
799 798 """
800 799 inmemory = ui.configbool('rebase', 'experimental.inmemory')
800 dryrun = opts.get(r'dry_run')
801 if dryrun:
802 if opts.get(r'abort'):
803 raise error.Abort(_('cannot specify both --dry-run and --abort'))
804 if opts.get(r'continue'):
805 raise error.Abort(_('cannot specify both --dry-run and --continue'))
806
801 807 if (opts.get(r'continue') or opts.get(r'abort') or
802 808 repo.currenttransaction() is not None):
803 809 # in-memory rebase is not compatible with resuming rebases.
@@ -814,7 +820,19 b' def rebase(ui, repo, **opts):'
814 820 opts[r'rev'] = [revsetlang.formatspec('%ld and orphan()', userrevs)]
815 821 opts[r'dest'] = '_destautoorphanrebase(SRC)'
816 822
817 if inmemory:
823 if dryrun:
824 try:
825 overrides = {('rebase', 'singletransaction'): True}
826 with ui.configoverride(overrides, 'rebase'):
827 _origrebase(ui, repo, inmemory=True, leaveunfinished=True,
828 **opts)
829 except error.InMemoryMergeConflictsError:
830 ui.status(_('hit a merge conflict\n'))
831 else:
832 ui.status(_('there will be no conflict, you can rebase\n'))
833 finally:
834 _origrebase(ui, repo, abort=True)
835 elif inmemory:
818 836 try:
819 837 # in-memory merge doesn't support conflicts, so if we hit any, abort
820 838 # and re-run as an on-disk merge.
@@ -824,12 +842,12 b' def rebase(ui, repo, **opts):'
824 842 except error.InMemoryMergeConflictsError:
825 843 ui.warn(_('hit merge conflicts; re-running rebase without in-memory'
826 844 ' merge\n'))
827 _origrebase(ui, repo, **{r'abort': True})
845 _origrebase(ui, repo, abort=True)
828 846 return _origrebase(ui, repo, inmemory=False, **opts)
829 847 else:
830 848 return _origrebase(ui, repo, **opts)
831 849
832 def _origrebase(ui, repo, inmemory=False, **opts):
850 def _origrebase(ui, repo, inmemory=False, leaveunfinished=False, **opts):
833 851 opts = pycompat.byteskwargs(opts)
834 852 rbsrt = rebaseruntime(repo, ui, inmemory, opts)
835 853
@@ -902,7 +920,8 b' def _origrebase(ui, repo, inmemory=False'
902 920 dsguard = dirstateguard.dirstateguard(repo, 'rebase')
903 921 with util.acceptintervention(dsguard):
904 922 rbsrt._performrebase(tr)
905 rbsrt._finishrebase()
923 if not leaveunfinished:
924 rbsrt._finishrebase()
906 925
907 926 def _definedestmap(ui, repo, inmemory, destf=None, srcf=None, basef=None,
908 927 revf=None, destspace=None):
@@ -155,4 +155,170 b' Rebase the working copy parent'
155 155 |/
156 156 o 0: b173517d0057 'a'
157 157
158 Test dry-run rebasing
159 $ hg init skrepo
160 $ cd skrepo
161 $ echo a>a
162 $ hg ci -Aqma
163 $ echo b>b
164 $ hg ci -Aqmb
165 $ echo c>c
166 $ hg ci -Aqmc
167 $ echo d>d
168 $ hg ci -Aqmd
169 $ echo e>e
170 $ hg ci -Aqme
158 171
172 $ hg up 1 -q
173 $ echo f>f
174 $ hg ci -Amf
175 adding f
176 created new head
177 $ echo g>g
178 $ hg ci -Aqmg
179 $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n"
180 @ 6:baf10c5166d4 test
181 | g
182 |
183 o 5:6343ca3eff20 test
184 | f
185 |
186 | o 4:e860deea161a test
187 | | e
188 | |
189 | o 3:055a42cdd887 test
190 | | d
191 | |
192 | o 2:177f92b77385 test
193 |/ c
194 |
195 o 1:d2ae7f538514 test
196 | b
197 |
198 o 0:cb9a9f314b8b test
199 a
200
201 Make sure it throws error while passing --continue or --abort with --dry-run
202 $ hg rebase -s 2 -d 6 -n --continue
203 abort: cannot specify both --dry-run and --continue
204 [255]
205 $ hg rebase -s 2 -d 6 -n --abort
206 abort: cannot specify both --dry-run and --abort
207 [255]
208
209 Check dryrun gives correct results when there is no conflict in rebasing
210 $ hg rebase -s 2 -d 6 -n
211 rebasing 2:177f92b77385 "c"
212 rebasing 3:055a42cdd887 "d"
213 rebasing 4:e860deea161a "e"
214 there will be no conflict, you can rebase
215 saved backup bundle to $TESTTMP/repo1/repo2/skrepo/.hg/strip-backup/c83b1da5b1ae-f1e0beb9-backup.hg
216 rebase aborted
217
218 $ hg diff
219 $ hg status
220
221 $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n"
222 @ 6:baf10c5166d4 test
223 | g
224 |
225 o 5:6343ca3eff20 test
226 | f
227 |
228 | o 4:e860deea161a test
229 | | e
230 | |
231 | o 3:055a42cdd887 test
232 | | d
233 | |
234 | o 2:177f92b77385 test
235 |/ c
236 |
237 o 1:d2ae7f538514 test
238 | b
239 |
240 o 0:cb9a9f314b8b test
241 a
242
243 Check dryrun working with --collapse when there is no conflict
244 $ hg rebase -s 2 -d 6 -n --collapse
245 rebasing 2:177f92b77385 "c"
246 rebasing 3:055a42cdd887 "d"
247 rebasing 4:e860deea161a "e"
248 there will be no conflict, you can rebase
249 rebase aborted
250
251 Check dryrun gives correct results when there is conflict in rebasing
252 Make a conflict:
253 $ hg up 6 -q
254 $ echo conflict>e
255 $ hg ci -Aqm "conflict with e"
256 $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n"
257 @ 7:d2c195b28050 test
258 | conflict with e
259 |
260 o 6:baf10c5166d4 test
261 | g
262 |
263 o 5:6343ca3eff20 test
264 | f
265 |
266 | o 4:e860deea161a test
267 | | e
268 | |
269 | o 3:055a42cdd887 test
270 | | d
271 | |
272 | o 2:177f92b77385 test
273 |/ c
274 |
275 o 1:d2ae7f538514 test
276 | b
277 |
278 o 0:cb9a9f314b8b test
279 a
280
281 $ hg rebase -s 2 -d 7 -n
282 rebasing 2:177f92b77385 "c"
283 rebasing 3:055a42cdd887 "d"
284 rebasing 4:e860deea161a "e"
285 merging e
286 transaction abort!
287 rollback completed
288 hit a merge conflict
289 rebase aborted
290 $ hg diff
291 $ hg status
292 $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n"
293 @ 7:d2c195b28050 test
294 | conflict with e
295 |
296 o 6:baf10c5166d4 test
297 | g
298 |
299 o 5:6343ca3eff20 test
300 | f
301 |
302 | o 4:e860deea161a test
303 | | e
304 | |
305 | o 3:055a42cdd887 test
306 | | d
307 | |
308 | o 2:177f92b77385 test
309 |/ c
310 |
311 o 1:d2ae7f538514 test
312 | b
313 |
314 o 0:cb9a9f314b8b test
315 a
316
317 Check dryrun working with --collapse when there is conflicts
318 $ hg rebase -s 2 -d 7 -n --collapse
319 rebasing 2:177f92b77385 "c"
320 rebasing 3:055a42cdd887 "d"
321 rebasing 4:e860deea161a "e"
322 merging e
323 hit a merge conflict
324 rebase aborted
General Comments 0
You need to be logged in to leave comments. Login now