Besides the JSON encoding issue (which can be solved by using "mercurial.encoding.jsonescape"), I think it's better to add a config option for the feature which is off by default. It's unnecessary to add the overhead for people who don't need the information. It's unsafe to assume writing a file is cheap - people do run hg on network filesystems.
Excerpts from Phil Cohen's message of 2017-03-20 00:49:07 -0700: [snip] > l = lockmod.lock(vfs, lockname, 0, releasefn=releasefn, > acquirefn=acquirefn, desc=desc, > inheritchecker=inheritchecker, > - parentlock=parentlock) > + parentlock=parentlock, > + metadata=metadata) I'd rename "metadata" to "info", to be consistent with the file extension ".info". [snip] > + $ cat << EOT > lockinfo.py > + > from contextlib import nested "nested" is not used. > + > from mercurial import (cmdutil, extensions) "extensions" is not used. > + > cmdtable = {} > + > command = cmdutil.command(cmdtable) > + > @command('locktest') > + > def locktest(ui, repo, *args, **opts): > + > def readf(path): > + > try: > + > with open(path, "r") as f: > + > return f.read() > + > except IOError as e: > + > return "<not found>" > + > def status(str): > + > print(str, readf(".hg/wlock.info"), readf(".hg/store/lock.info")) > + > status("No lock, shouldn't have either file:") > + > with repo.wlock(): > + > status("Have the write lock:") Inconsistent indentation. Try to use 4 spaces for the code above. > + > with repo.lock(): > + > status("Also have the store lock:") > + > status("Just the write lock:") > + > status("Neither:") > + > EOT > +Test store and write lock > + $ hg locktest -v --config extensions.x=lockinfo.py > + ("No lock, shouldn't have either file:", '<not found>', '<not found>') > + ('Have the write lock:', '{"cmd": "locktest", "args": ["locktest", > "-v"]}', '<not found>') > + ('Also have the store lock:', '{"cmd": "locktest", "args": ["locktest", > "-v"]}', '{"cmd": "locktest", "args": ["locktest", "-v"]}') > + ('Just the write lock:', '{"cmd": "locktest", "args": ["locktest", > "-v"]}', '<not found>') > + ('Neither:', '<not found>', '<not found>') _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel