Show More
@@ -64,6 +64,10 b" backupdir = 'shelve-backup'" | |||||
64 | shelvedir = 'shelved' |
|
64 | shelvedir = 'shelved' | |
65 | shelvefileextensions = ['hg', 'patch'] |
|
65 | shelvefileextensions = ['hg', 'patch'] | |
66 |
|
66 | |||
|
67 | # we never need the user, so we use a | |||
|
68 | # generic user for all shelve operations | |||
|
69 | shelveuser = 'shelve@localhost' | |||
|
70 | ||||
67 | class shelvedfile(object): |
|
71 | class shelvedfile(object): | |
68 | """Helper for the file storing a single shelve |
|
72 | """Helper for the file storing a single shelve | |
69 |
|
73 | |||
@@ -290,6 +294,32 b' def mutableancestors(ctx):' | |||||
290 | if parent.mutable(): |
|
294 | if parent.mutable(): | |
291 | visit.append(parent) |
|
295 | visit.append(parent) | |
292 |
|
296 | |||
|
297 | def getcommitfunc(extra, interactive, editor=False): | |||
|
298 | def commitfunc(ui, repo, message, match, opts): | |||
|
299 | hasmq = util.safehasattr(repo, 'mq') | |||
|
300 | if hasmq: | |||
|
301 | saved, repo.mq.checkapplied = repo.mq.checkapplied, False | |||
|
302 | backup = repo.ui.backupconfig('phases', 'new-commit') | |||
|
303 | try: | |||
|
304 | repo.ui.setconfig('phases', 'new-commit', phases.secret) | |||
|
305 | editor_ = False | |||
|
306 | if editor: | |||
|
307 | editor_ = cmdutil.getcommiteditor(editform='shelve.shelve', | |||
|
308 | **opts) | |||
|
309 | return repo.commit(message, shelveuser, opts.get('date'), match, | |||
|
310 | editor=editor_, extra=extra) | |||
|
311 | finally: | |||
|
312 | repo.ui.restoreconfig(backup) | |||
|
313 | if hasmq: | |||
|
314 | repo.mq.checkapplied = saved | |||
|
315 | ||||
|
316 | def interactivecommitfunc(ui, repo, *pats, **opts): | |||
|
317 | match = scmutil.match(repo['.'], pats, {}) | |||
|
318 | message = opts['message'] | |||
|
319 | return commitfunc(ui, repo, message, match, opts) | |||
|
320 | ||||
|
321 | return interactivecommitfunc if interactive else commitfunc | |||
|
322 | ||||
293 | def _docreatecmd(ui, repo, pats, opts): |
|
323 | def _docreatecmd(ui, repo, pats, opts): | |
294 | wctx = repo[None] |
|
324 | wctx = repo[None] | |
295 | parents = wctx.parents() |
|
325 | parents = wctx.parents() | |
@@ -298,9 +328,6 b' def _docreatecmd(ui, repo, pats, opts):' | |||||
298 | parent = parents[0] |
|
328 | parent = parents[0] | |
299 | origbranch = wctx.branch() |
|
329 | origbranch = wctx.branch() | |
300 |
|
330 | |||
301 | # we never need the user, so we use a generic user for all shelve operations |
|
|||
302 | user = 'shelve@localhost' |
|
|||
303 |
|
||||
304 | if parent.node() != nodemod.nullid: |
|
331 | if parent.node() != nodemod.nullid: | |
305 | desc = "changes to: %s" % parent.description().split('\n', 1)[0] |
|
332 | desc = "changes to: %s" % parent.description().split('\n', 1)[0] | |
306 | else: |
|
333 | else: | |
@@ -335,30 +362,11 b' def _docreatecmd(ui, repo, pats, opts):' | |||||
335 | # at bundled commit |
|
362 | # at bundled commit | |
336 | repo.dirstate.setbranch(repo['.'].branch()) |
|
363 | repo.dirstate.setbranch(repo['.'].branch()) | |
337 |
|
364 | |||
338 | def commitfunc(ui, repo, message, match, opts): |
|
365 | commitfunc = getcommitfunc(extra, interactive, editor=True) | |
339 | hasmq = util.safehasattr(repo, 'mq') |
|
|||
340 | if hasmq: |
|
|||
341 | saved, repo.mq.checkapplied = repo.mq.checkapplied, False |
|
|||
342 | backup = repo.ui.backupconfig('phases', 'new-commit') |
|
|||
343 | try: |
|
|||
344 | repo.ui. setconfig('phases', 'new-commit', phases.secret) |
|
|||
345 | editor = cmdutil.getcommiteditor(editform='shelve.shelve', |
|
|||
346 | **opts) |
|
|||
347 | return repo.commit(message, user, opts.get('date'), match, |
|
|||
348 | editor=editor, extra=extra) |
|
|||
349 | finally: |
|
|||
350 | repo.ui.restoreconfig(backup) |
|
|||
351 | if hasmq: |
|
|||
352 | repo.mq.checkapplied = saved |
|
|||
353 |
|
||||
354 | def interactivecommitfunc(ui, repo, *pats, **opts): |
|
|||
355 | match = scmutil.match(repo['.'], pats, {}) |
|
|||
356 | message = opts['message'] |
|
|||
357 | return commitfunc(ui, repo, message, match, opts) |
|
|||
358 | if not interactive: |
|
366 | if not interactive: | |
359 | node = cmdutil.commit(ui, repo, commitfunc, pats, opts) |
|
367 | node = cmdutil.commit(ui, repo, commitfunc, pats, opts) | |
360 | else: |
|
368 | else: | |
361 |
node = cmdutil.dorecord(ui, repo, |
|
369 | node = cmdutil.dorecord(ui, repo, commitfunc, None, | |
362 | False, cmdutil.recordfilter, *pats, **opts) |
|
370 | False, cmdutil.recordfilter, *pats, **opts) | |
363 | if not node: |
|
371 | if not node: | |
364 | stat = repo.status(match=scmutil.match(repo[None], pats, opts)) |
|
372 | stat = repo.status(match=scmutil.match(repo[None], pats, opts)) | |
@@ -741,21 +749,8 b' def _dounshelve(ui, repo, *shelved, **op' | |||||
741 | if s.modified or s.added or s.removed or s.deleted: |
|
749 | if s.modified or s.added or s.removed or s.deleted: | |
742 | ui.status(_("temporarily committing pending changes " |
|
750 | ui.status(_("temporarily committing pending changes " | |
743 | "(restore with 'hg unshelve --abort')\n")) |
|
751 | "(restore with 'hg unshelve --abort')\n")) | |
744 | def commitfunc(ui, repo, message, match, opts): |
|
752 | commitfunc = getcommitfunc(extra=None, interactive=False, | |
745 | hasmq = util.safehasattr(repo, 'mq') |
|
753 | editor=False) | |
746 | if hasmq: |
|
|||
747 | saved, repo.mq.checkapplied = repo.mq.checkapplied, False |
|
|||
748 |
|
||||
749 | backup = repo.ui.backupconfig('phases', 'new-commit') |
|
|||
750 | try: |
|
|||
751 | repo.ui.setconfig('phases', 'new-commit', phases.secret) |
|
|||
752 | return repo.commit(message, 'shelve@localhost', |
|
|||
753 | opts.get('date'), match) |
|
|||
754 | finally: |
|
|||
755 | repo.ui.restoreconfig(backup) |
|
|||
756 | if hasmq: |
|
|||
757 | repo.mq.checkapplied = saved |
|
|||
758 |
|
||||
759 | tempopts = {} |
|
754 | tempopts = {} | |
760 | tempopts['message'] = "pending changes temporary commit" |
|
755 | tempopts['message'] = "pending changes temporary commit" | |
761 | tempopts['date'] = opts.get('date') |
|
756 | tempopts['date'] = opts.get('date') |
General Comments 0
You need to be logged in to leave comments.
Login now