def amend(ui, repo, *pats, **opts): """amend the working copy parent with all or specified outstanding changes Similar to :hg:`commit --amend`, but reuse the commit message without invoking editor, unless ``--edit`` was set. See :hg:`help commit` for more details. """ with repo.wlock(), repo.lock(): if not opts.get('logfile'): opts['message'] = opts.get('message') or repo['.'].description() opts['amend'] = True return commands._docommit(ui, repo, *pats, **opts)
def amend(ui, repo, *pats, **opts): """amend the working copy parent with all or specified outstanding changes Similar to :hg:`commit --amend`, but reuse the commit message without invoking editor, unless ``--edit`` was set. See :hg:`help commit` for more details. """ opts = pycompat.byteskwargs(opts) if len(opts['note']) > 255: raise error.Abort(_("cannot store a note of more than 255 bytes")) with repo.wlock(), repo.lock(): if not opts.get('logfile'): opts['message'] = opts.get('message') or repo['.'].description() opts['amend'] = True return commands._docommit(ui, repo, *pats, **pycompat.strkwargs(opts))
def amend(ui, repo, *pats, **opts): """amend the working copy parent with all or specified outstanding changes Similar to :hg:`commit --amend`, but reuse the commit message without invoking editor, unless ``--edit`` was set. See :hg:`help commit` for more details. """ opts = pycompat.byteskwargs(opts) cmdutil.checknotesize(ui, opts) with repo.wlock(), repo.lock(): if not opts.get(b'logfile'): opts[b'message'] = opts.get(b'message') or repo[b'.'].description() opts[b'amend'] = True return commands._docommit(ui, repo, *pats, **pycompat.strkwargs(opts))
def cmd_format_source(ui, repo, tool, *pats, **opts): """register a tool to format source files during merges and rebases Record a mapping from the given file pattern FILES to a source formatting tool TOOL. Mappings are stored in the version-controlled file (automatically committed when format-source is used) .hg-format-source in the root of the checkout. The mapping causes TOOL to be run on FILES during future merge and rebase operations. The actual command run for TOOL needs to be registered in the config. See :hg:`help -e format-source` for details. """ if repo.getcwd(): msg = _("format-source must be run from repository root") hint = _("cd %s") % repo.root raise error.Abort(msg, hint=hint) if not pats: raise error.Abort(_('no files specified')) # XXX We support glob pattern only for now, the recursive behavior of various others is a bit wonky. for pattern in pats: if not pattern.startswith('glob:'): msg = _("format-source only supports explicit 'glob' patterns " "for now ('%s')") msg %= pattern hint = _('maybe try with "glob:%s"') % pattern raise error.Abort(msg, hint=hint) # lock the repo to make sure no content is changed with repo.wlock(): # formatting tool if ' ' in tool: raise error.Abort(_("tool name cannot contain space: '%s'") % tool) # if tool was not specified in the cfg maybe we can use our mozilla firefox in tree clang-format tool if should_use_default(repo, tool): shell_tool, tool_config_files, file_ext = return_default_clang_format( repo) else: shell_tool = repo.ui.config('format-source', tool) tool_config_files = repo.ui.configlist('format-source', '%s:configpaths' % tool) file_ext = tuple( repo.ui.configlist('format-source', '%s:fileext' % tool)) if not shell_tool: msg = _("unknown format tool: %s (no 'format-source.%s' config)") raise error.Abort(msg.format(tool, tool)) if not file_ext: msg = _("no {}:fileext present".format(tool)) raise error.Abort(msg.format(tool, tool)) cmdutil.bailifchanged(repo) cmdutil.checkunfinished(repo, commit=True) wctx = repo[None] # files to be formatted matcher = scmutil.match(wctx, pats, opts) files = list(wctx.matches(matcher)) if util.versiontuple(n=2) >= (4, 7): # In 4.7 we have ui.makeprogress with ui.makeprogress(_('formatting'), unit=_('files'), total=len(files)) as progress: proc = worker.worker(ui, 0.1, batchformat, (repo, wctx, tool, shell_tool, file_ext), files) for filepath in proc: progress.increment(item=filepath) else: proc = worker.worker(ui, 0.1, batchformat, (repo, wctx, tool, shell_tool, file_ext), files) # Wait for everything to finish for filepath in proc: pass # update the storage to mark formatted file as formatted with repo.wvfs(file_storage_path, mode='ab') as storage: for pattern in pats: # XXX if pattern was relative, we need to reroot it from the # repository root. For now we constrained the command to run # at the root of the repository. data = { 'tool': encoding.unifromlocal(tool), 'pattern': encoding.unifromlocal(pattern) } if tool_config_files: data['configpaths'] = [ encoding.unifromlocal(path) for path in tool_config_files ] entry = json.dumps(data, sort_keys=True) assert '\n' not in entry storage.write('%s\n' % entry) if file_storage_path not in wctx: storage_matcher = scmutil.match(wctx, ['path:' + file_storage_path]) cmdutil.add(ui, repo, storage_matcher, '', True) # commit the whole with repo.lock(): commit_patterns = ['path:' + file_storage_path] commit_patterns.extend(pats) return commands._docommit(ui, repo, *commit_patterns, **opts)