##// END OF EJS Templates
some modernization cleanups, forward compatibility
Dirkjan Ochtman -
r8366:0bf00450 default
parent child Browse files
Show More
@@ -741,7 +741,7 b' class queue:'
741 741 elif user:
742 742 p.write("From: " + user + "\n\n")
743 743
744 if callable(msg):
744 if hasattr(msg, '__call__'):
745 745 msg = msg()
746 746 commitmsg = msg and msg or ("[mq]: %s" % patchfn)
747 747 n = repo.commit(commitfiles, commitmsg, user, date, match=match, force=True)
@@ -23,7 +23,7 b' import os'
23 23 import stat
24 24 import urllib
25 25 import urllib2
26 import rfc822
26 import email.utils
27 27
28 28 try:
29 29 from cStringIO import StringIO
@@ -214,7 +214,7 b' class FileRangeHandler(urllib2.FileHandl'
214 214 localfile = urllib.url2pathname(file)
215 215 stats = os.stat(localfile)
216 216 size = stats[stat.ST_SIZE]
217 modified = rfc822.formatdate(stats[stat.ST_MTIME])
217 modified = email.utils.formatdate(stats[stat.ST_MTIME])
218 218 mtype = mimetypes.guess_type(file)[0]
219 219 if host:
220 220 host, port = urllib.splitport(host)
@@ -1464,7 +1464,7 b' def help_(ui, name=None, with_version=Fa'
1464 1464 # description
1465 1465 if not doc:
1466 1466 doc = _("(no help text available)")
1467 if callable(doc):
1467 if hasattr(doc, '__call__'):
1468 1468 doc = doc()
1469 1469
1470 1470 ui.write("%s\n" % header)
@@ -70,7 +70,7 b' def fancyopts(args, options, state, gnu='
70 70 # copy defaults to state
71 71 if isinstance(default, list):
72 72 state[name] = default[:]
73 elif callable(default):
73 elif hasattr(default, '__call__'):
74 74 state[name] = None
75 75 else:
76 76 state[name] = default
@@ -21,7 +21,7 b' def _pythonhook(ui, repo, name, hname, f'
21 21
22 22 ui.note(_("calling hook %s: %s\n") % (hname, funcname))
23 23 obj = funcname
24 if not callable(obj):
24 if not hasattr(obj, '__call__'):
25 25 d = funcname.rfind('.')
26 26 if d == -1:
27 27 raise util.Abort(_('%s hook is invalid ("%s" not in '
@@ -44,7 +44,7 b' def _pythonhook(ui, repo, name, hname, f'
44 44 raise util.Abort(_('%s hook is invalid '
45 45 '("%s" is not defined)') %
46 46 (hname, funcname))
47 if not callable(obj):
47 if not hasattr(obj, '__call__'):
48 48 raise util.Abort(_('%s hook is invalid '
49 49 '("%s" is not callable)') %
50 50 (hname, funcname))
@@ -74,7 +74,7 b' def _exthook(ui, repo, name, cmd, args, '
74 74
75 75 env = {}
76 76 for k, v in args.iteritems():
77 if callable(v):
77 if hasattr(v, '__call__'):
78 78 v = v()
79 79 env['HG_' + k.upper()] = v
80 80
@@ -107,7 +107,7 b' def hook(ui, repo, name, throw=False, **'
107 107 for hname, cmd in ui.configitems('hooks'):
108 108 if hname.split('.')[0] != name or not cmd:
109 109 continue
110 if callable(cmd):
110 if hasattr(cmd, '__call__'):
111 111 r = _pythonhook(ui, repo, name, hname, cmd, args, throw) or r
112 112 elif cmd.startswith('python:'):
113 113 if cmd.count(':') == 2:
@@ -263,16 +263,8 b' def manifestmerge(repo, p1, p2, pa, over'
263 263
264 264 return action
265 265
266 def actioncmp(a1, a2):
267 m1 = a1[1]
268 m2 = a2[1]
269 if m1 == m2:
270 return cmp(a1, a2)
271 if m1 == 'r':
272 return -1
273 if m2 == 'r':
274 return 1
275 return cmp(a1, a2)
266 def actionkey(a):
267 return a[1] == 'r' and -1 or 0, a
276 268
277 269 def applyupdates(repo, action, wctx, mctx):
278 270 "apply the merge action list to the working directory"
@@ -281,7 +273,7 b' def applyupdates(repo, action, wctx, mct'
281 273 ms = mergestate(repo)
282 274 ms.reset(wctx.parents()[0].node())
283 275 moves = []
284 action.sort(actioncmp)
276 action.sort(key=actionkey)
285 277
286 278 # prescan for merges
287 279 for a in action:
@@ -89,7 +89,7 b' class engine(object):'
89 89 v = map[key]
90 90 else:
91 91 v = self.defaults.get(key, "")
92 if callable(v):
92 if hasattr(v, '__call__'):
93 93 v = v(**map)
94 94 if format:
95 95 if not hasattr(v, '__iter__'):
General Comments 0
You need to be logged in to leave comments. Login now