comparison mercurial/commands.py @ 42419:69883775b27d

root: add template variables pointing to repository directories These paths are useful for GUI applications to detect changes. A GUI process typically monitors .hg and .hg/store directories so that it will be notified on lock/wlock deletion. Alternatively, maybe we can add debugpaths command if we don't want to extend the root command. I'm not sure which will be nicer.
author Yuya Nishihara <yuya@tcha.org>
date Tue, 04 Jun 2019 21:13:35 +0900
parents 9803323048b6
children 1314c0bb6b24
comparison
equal deleted inserted replaced
42418:9803323048b6 42419:69883775b27d
5230 def root(ui, repo, **opts): 5230 def root(ui, repo, **opts):
5231 """print the root (top) of the current working directory 5231 """print the root (top) of the current working directory
5232 5232
5233 Print the root directory of the current repository. 5233 Print the root directory of the current repository.
5234 5234
5235 .. container:: verbose
5236
5237 Template:
5238
5239 The following keywords are supported in addition to the common template
5240 keywords and functions. See also :hg:`help templates`.
5241
5242 :hgpath: String. Path to the .hg directory.
5243 :storepath: String. Path to the directory holding versioned data.
5244
5235 Returns 0 on success. 5245 Returns 0 on success.
5236 """ 5246 """
5237 opts = pycompat.byteskwargs(opts) 5247 opts = pycompat.byteskwargs(opts)
5238 with ui.formatter('root', opts) as fm: 5248 with ui.formatter('root', opts) as fm:
5239 fm.startitem() 5249 fm.startitem()
5240 fm.write('reporoot', '%s\n', repo.root) 5250 fm.write('reporoot', '%s\n', repo.root)
5251 fm.data(hgpath=repo.path, storepath=repo.spath)
5241 5252
5242 @command('serve', 5253 @command('serve',
5243 [('A', 'accesslog', '', _('name of access log file to write to'), 5254 [('A', 'accesslog', '', _('name of access log file to write to'),
5244 _('FILE')), 5255 _('FILE')),
5245 ('d', 'daemon', None, _('run server in background')), 5256 ('d', 'daemon', None, _('run server in background')),