Mercurial > hg
annotate contrib/debugshell.py @ 24188:5a7920c4d2ea
util: accept "now, today, yesterday" for dates even the locale is not english
Hi there!
Fixed date names are helpful for automated systems. So it is possible to
use english date parameter even if the underlying system uses another
locale.
We have here a jenkins with build jobs on different slaves that will do
some operations with "dates" parameter. Some systems uses English locale
and some systems uses German locale. So we needed to configure the job to
uses other date names.
As this is really annoying to keep the systems locale in mind for some
operations I looked into util.py. It would be helpful for automated systems
if the "default English" date names would even usable on other
locales.
I attached a simple patch for this.
Best regards
André Klitzing
author | André Klitzing <aklitzing@gmail.com> |
---|---|
date | Tue, 24 Feb 2015 14:12:13 +0100 |
parents | 8b5c039f2b4f |
children | e4b512bb6386 |
rev | line source |
---|---|
11633 | 1 # debugshell extension |
2 """a python shell with repo, changelog & manifest objects""" | |
3 | |
19773
51799a965446
debugshell: check ui.debugger for which debugger to use
Sean Farley <sean.michael.farley@gmail.com>
parents:
19772
diff
changeset
|
4 import sys |
11633 | 5 import mercurial |
6 import code | |
21243
8b5c039f2b4f
debugshell: declare command using decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
19794
diff
changeset
|
7 from mercurial import cmdutil |
8b5c039f2b4f
debugshell: declare command using decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
19794
diff
changeset
|
8 |
8b5c039f2b4f
debugshell: declare command using decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
19794
diff
changeset
|
9 cmdtable = {} |
8b5c039f2b4f
debugshell: declare command using decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
19794
diff
changeset
|
10 command = cmdutil.command(cmdtable) |
11633 | 11 |
19771
3bc675361206
debugshell: abstract out pdb code.interact
Sean Farley <sean.michael.farley@gmail.com>
parents:
11633
diff
changeset
|
12 def pdb(ui, repo, msg, **opts): |
11633 | 13 objects = { |
14 'mercurial': mercurial, | |
15 'repo': repo, | |
16 'cl': repo.changelog, | |
17 'mf': repo.manifest, | |
18 } | |
19771
3bc675361206
debugshell: abstract out pdb code.interact
Sean Farley <sean.michael.farley@gmail.com>
parents:
11633
diff
changeset
|
19 |
3bc675361206
debugshell: abstract out pdb code.interact
Sean Farley <sean.michael.farley@gmail.com>
parents:
11633
diff
changeset
|
20 code.interact(msg, local=objects) |
3bc675361206
debugshell: abstract out pdb code.interact
Sean Farley <sean.michael.farley@gmail.com>
parents:
11633
diff
changeset
|
21 |
19772
6ccec36a1fd9
debugshell: add function to embed ipython
Sean Farley <sean.michael.farley@gmail.com>
parents:
19771
diff
changeset
|
22 def ipdb(ui, repo, msg, **opts): |
6ccec36a1fd9
debugshell: add function to embed ipython
Sean Farley <sean.michael.farley@gmail.com>
parents:
19771
diff
changeset
|
23 import IPython |
6ccec36a1fd9
debugshell: add function to embed ipython
Sean Farley <sean.michael.farley@gmail.com>
parents:
19771
diff
changeset
|
24 |
6ccec36a1fd9
debugshell: add function to embed ipython
Sean Farley <sean.michael.farley@gmail.com>
parents:
19771
diff
changeset
|
25 cl = repo.changelog |
6ccec36a1fd9
debugshell: add function to embed ipython
Sean Farley <sean.michael.farley@gmail.com>
parents:
19771
diff
changeset
|
26 mf = repo.manifest |
19794
cccc44304b2c
debugshell: appease pyflakes
Matt Mackall <mpm@selenic.com>
parents:
19773
diff
changeset
|
27 cl, mf # use variables to appease pyflakes |
19772
6ccec36a1fd9
debugshell: add function to embed ipython
Sean Farley <sean.michael.farley@gmail.com>
parents:
19771
diff
changeset
|
28 |
6ccec36a1fd9
debugshell: add function to embed ipython
Sean Farley <sean.michael.farley@gmail.com>
parents:
19771
diff
changeset
|
29 IPython.embed() |
6ccec36a1fd9
debugshell: add function to embed ipython
Sean Farley <sean.michael.farley@gmail.com>
parents:
19771
diff
changeset
|
30 |
21243
8b5c039f2b4f
debugshell: declare command using decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
19794
diff
changeset
|
31 @command('debugshell|dbsh', []) |
19771
3bc675361206
debugshell: abstract out pdb code.interact
Sean Farley <sean.michael.farley@gmail.com>
parents:
11633
diff
changeset
|
32 def debugshell(ui, repo, **opts): |
11633 | 33 bannermsg = "loaded repo : %s\n" \ |
34 "using source: %s" % (repo.root, | |
35 mercurial.__path__[0]) | |
19771
3bc675361206
debugshell: abstract out pdb code.interact
Sean Farley <sean.michael.farley@gmail.com>
parents:
11633
diff
changeset
|
36 |
19773
51799a965446
debugshell: check ui.debugger for which debugger to use
Sean Farley <sean.michael.farley@gmail.com>
parents:
19772
diff
changeset
|
37 pdbmap = { |
51799a965446
debugshell: check ui.debugger for which debugger to use
Sean Farley <sean.michael.farley@gmail.com>
parents:
19772
diff
changeset
|
38 'pdb' : 'code', |
51799a965446
debugshell: check ui.debugger for which debugger to use
Sean Farley <sean.michael.farley@gmail.com>
parents:
19772
diff
changeset
|
39 'ipdb' : 'IPython' |
51799a965446
debugshell: check ui.debugger for which debugger to use
Sean Farley <sean.michael.farley@gmail.com>
parents:
19772
diff
changeset
|
40 } |
51799a965446
debugshell: check ui.debugger for which debugger to use
Sean Farley <sean.michael.farley@gmail.com>
parents:
19772
diff
changeset
|
41 |
51799a965446
debugshell: check ui.debugger for which debugger to use
Sean Farley <sean.michael.farley@gmail.com>
parents:
19772
diff
changeset
|
42 debugger = ui.config("ui", "debugger") |
51799a965446
debugshell: check ui.debugger for which debugger to use
Sean Farley <sean.michael.farley@gmail.com>
parents:
19772
diff
changeset
|
43 if not debugger: |
51799a965446
debugshell: check ui.debugger for which debugger to use
Sean Farley <sean.michael.farley@gmail.com>
parents:
19772
diff
changeset
|
44 debugger = 'pdb' |
51799a965446
debugshell: check ui.debugger for which debugger to use
Sean Farley <sean.michael.farley@gmail.com>
parents:
19772
diff
changeset
|
45 |
51799a965446
debugshell: check ui.debugger for which debugger to use
Sean Farley <sean.michael.farley@gmail.com>
parents:
19772
diff
changeset
|
46 # if IPython doesn't exist, fallback to code.interact |
51799a965446
debugshell: check ui.debugger for which debugger to use
Sean Farley <sean.michael.farley@gmail.com>
parents:
19772
diff
changeset
|
47 try: |
51799a965446
debugshell: check ui.debugger for which debugger to use
Sean Farley <sean.michael.farley@gmail.com>
parents:
19772
diff
changeset
|
48 __import__(pdbmap[debugger]) |
51799a965446
debugshell: check ui.debugger for which debugger to use
Sean Farley <sean.michael.farley@gmail.com>
parents:
19772
diff
changeset
|
49 except ImportError: |
51799a965446
debugshell: check ui.debugger for which debugger to use
Sean Farley <sean.michael.farley@gmail.com>
parents:
19772
diff
changeset
|
50 ui.warn("%s debugger specified but %s module was not found\n" |
51799a965446
debugshell: check ui.debugger for which debugger to use
Sean Farley <sean.michael.farley@gmail.com>
parents:
19772
diff
changeset
|
51 % (debugger, pdbmap[debugger])) |
51799a965446
debugshell: check ui.debugger for which debugger to use
Sean Farley <sean.michael.farley@gmail.com>
parents:
19772
diff
changeset
|
52 debugger = 'pdb' |
51799a965446
debugshell: check ui.debugger for which debugger to use
Sean Farley <sean.michael.farley@gmail.com>
parents:
19772
diff
changeset
|
53 |
51799a965446
debugshell: check ui.debugger for which debugger to use
Sean Farley <sean.michael.farley@gmail.com>
parents:
19772
diff
changeset
|
54 getattr(sys.modules[__name__], debugger)(ui, repo, bannermsg, **opts) |