comparison hgext/shelve.py @ 42013:50d5e64ec561

shelve: do not update when keeping changes, just move the dirstate This is to leave the working directory unchanged. We reuse the match object as an optimisation.
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Fri, 22 Mar 2019 11:26:47 -0400
parents 9b78bbb76111
children 00c1ee0f746a
comparison
equal deleted inserted replaced
42012:9b78bbb76111 42013:50d5e64ec561
497 if not node: 497 if not node:
498 _nothingtoshelvemessaging(ui, repo, pats, opts) 498 _nothingtoshelvemessaging(ui, repo, pats, opts)
499 return 1 499 return 1
500 500
501 # Create a matcher so that prefetch doesn't attempt to fetch 501 # Create a matcher so that prefetch doesn't attempt to fetch
502 # the entire repository pointlessly 502 # the entire repository pointlessly, and as an optimisation
503 # for movedirstate, if needed.
503 match = scmutil.matchfiles(repo, repo[node].files()) 504 match = scmutil.matchfiles(repo, repo[node].files())
504 _shelvecreatedcommit(repo, node, name, match) 505 _shelvecreatedcommit(repo, node, name, match)
505 506
506 if ui.formatted(): 507 if ui.formatted():
507 desc = stringutil.ellipsis(desc, ui.termwidth()) 508 desc = stringutil.ellipsis(desc, ui.termwidth())
508 ui.status(_('shelved as %s\n') % name) 509 ui.status(_('shelved as %s\n') % name)
509 hg.update(repo, parent.node()) 510 if opts['keep']:
511 with repo.dirstate.parentchange():
512 scmutil.movedirstate(repo, parent, match)
513 else:
514 hg.update(repo, parent.node())
510 if origbranch != repo['.'].branch() and not _isbareshelve(pats, opts): 515 if origbranch != repo['.'].branch() and not _isbareshelve(pats, opts):
511 repo.dirstate.setbranch(origbranch) 516 repo.dirstate.setbranch(origbranch)
512 517
513 _finishshelve(repo, tr) 518 _finishshelve(repo, tr)
514 finally: 519 finally: