comparison hgext/shelve.py @ 19943:4de116871044 stable

shelve: make unshelve work even if it don't run in repository root revertfiles are relative to the repository root. not paths relative to the cwd.
author Takumi IINO <trot.thunder@gmail.com>
date Tue, 22 Oct 2013 12:41:05 +0900
parents 1c58e368fbfd
children d51c4d85ec23
comparison
equal deleted inserted replaced
19942:2c886dedd902 19943:4de116871044
356 """check parent while resuming an unshelve""" 356 """check parent while resuming an unshelve"""
357 if state.parents != repo.dirstate.parents(): 357 if state.parents != repo.dirstate.parents():
358 raise util.Abort(_('working directory parents do not match unshelve ' 358 raise util.Abort(_('working directory parents do not match unshelve '
359 'state')) 359 'state'))
360 360
361 def pathtofiles(repo, files):
362 cwd = repo.getcwd()
363 return [repo.pathto(f, cwd) for f in files]
364
361 def unshelveabort(ui, repo, state, opts): 365 def unshelveabort(ui, repo, state, opts):
362 """subcommand that abort an in-progress unshelve""" 366 """subcommand that abort an in-progress unshelve"""
363 wlock = repo.wlock() 367 wlock = repo.wlock()
364 lock = None 368 lock = None
365 try: 369 try:
370 repo.setparents(repo.dirstate.parents()[0]) 374 repo.setparents(repo.dirstate.parents()[0])
371 else: 375 else:
372 revertfiles = readshelvedfiles(repo, state.name) 376 revertfiles = readshelvedfiles(repo, state.name)
373 wctx = repo.parents()[0] 377 wctx = repo.parents()[0]
374 cmdutil.revert(ui, repo, wctx, [wctx.node(), nullid], 378 cmdutil.revert(ui, repo, wctx, [wctx.node(), nullid],
375 *revertfiles, **{'no_backup': True}) 379 *pathtofiles(repo, revertfiles),
380 **{'no_backup': True})
376 # fix up the weird dirstate states the merge left behind 381 # fix up the weird dirstate states the merge left behind
377 mf = wctx.manifest() 382 mf = wctx.manifest()
378 dirstate = repo.dirstate 383 dirstate = repo.dirstate
379 for f in revertfiles: 384 for f in revertfiles:
380 if f in mf: 385 if f in mf:
530 # with unresolved conflicts. 535 # with unresolved conflicts.
531 parents = repo.parents() 536 parents = repo.parents()
532 revertfiles = set(parents[1].files()).difference(ms) 537 revertfiles = set(parents[1].files()).difference(ms)
533 cmdutil.revert(ui, repo, parents[1], 538 cmdutil.revert(ui, repo, parents[1],
534 (parents[0].node(), nullid), 539 (parents[0].node(), nullid),
535 *revertfiles, **{'no_backup': True}) 540 *pathtofiles(repo, revertfiles),
541 **{'no_backup': True})
536 raise error.InterventionRequired( 542 raise error.InterventionRequired(
537 _("unresolved conflicts (see 'hg resolve', then " 543 _("unresolved conflicts (see 'hg resolve', then "
538 "'hg unshelve --continue')")) 544 "'hg unshelve --continue')"))
539 finishmerge(ui, repo, ms, stripnodes, basename, opts) 545 finishmerge(ui, repo, ms, stripnodes, basename, opts)
540 else: 546 else:
541 parent = tip.parents()[0] 547 parent = tip.parents()[0]
542 hg.update(repo, parent.node()) 548 hg.update(repo, parent.node())
543 cmdutil.revert(ui, repo, tip, repo.dirstate.parents(), *tip.files(), 549 cmdutil.revert(ui, repo, tip, repo.dirstate.parents(),
550 *pathtofiles(repo, tip.files()),
544 **{'no_backup': True}) 551 **{'no_backup': True})
545 552
546 prevquiet = ui.quiet 553 prevquiet = ui.quiet
547 ui.quiet = True 554 ui.quiet = True
548 try: 555 try: