##// END OF EJS Templates
cleanup: fix docstring formatting...
Matt Harbison -
r44187:c190f271 default draft
parent child Browse files
Show More
@@ -303,18 +303,18 b' def isenabled():'
303 303
304 304
305 305 def enable():
306 "enable global demand-loading of modules"
306 """enable global demand-loading of modules"""
307 307 builtins.__import__ = _demandimport
308 308
309 309
310 310 def disable():
311 "disable global demand-loading of modules"
311 """disable global demand-loading of modules"""
312 312 builtins.__import__ = _origimport
313 313
314 314
315 315 @contextmanager
316 316 def deactivated():
317 "context manager for disabling demandimport in 'with' blocks"
317 """context manager for disabling demandimport in 'with' blocks"""
318 318 demandenabled = isenabled()
319 319 if demandenabled:
320 320 disable()
@@ -110,7 +110,7 b' def createlog(ui, directory=None, root=b'
110 110 _scache = {}
111 111
112 112 def scache(s):
113 b"return a shared version of a string"
113 """return a shared version of a string"""
114 114 return _scache.setdefault(s, s)
115 115
116 116 ui.status(_(b'collecting CVS rlog\n'))
@@ -711,7 +711,7 b' def createchangeset(ui, log, fuzz=60, me'
711 711 # Sort files in each changeset
712 712
713 713 def entitycompare(l, r):
714 b'Mimic cvsps sorting order'
714 """Mimic cvsps sorting order"""
715 715 l = l.file.split(b'/')
716 716 r = r.file.split(b'/')
717 717 nl = len(l)
@@ -24,7 +24,7 b' from . import common'
24 24
25 25
26 26 def loaditer(f):
27 b"Yield the dictionary objects generated by p4"
27 """Yield the dictionary objects generated by p4"""
28 28 try:
29 29 while True:
30 30 d = marshal.load(f)
@@ -105,7 +105,7 b' class p4_source(common.converter_source)'
105 105 self.revmap = revmap
106 106
107 107 def _parse_view(self, path):
108 b"Read changes affecting the path"
108 """Read changes affecting the path"""
109 109 cmd = b'p4 -G changes -s submitted %s' % procutil.shellquote(path)
110 110 stdout = procutil.popen(cmd, mode=b'rb')
111 111 p4changes = {}
@@ -116,7 +116,7 b' class p4_source(common.converter_source)'
116 116 return p4changes
117 117
118 118 def _parse(self, ui, path):
119 b"Prepare list of P4 filenames and revisions to import"
119 """Prepare list of P4 filenames and revisions to import"""
120 120 p4changes = {}
121 121 changeset = {}
122 122 files_map = {}
@@ -373,7 +373,7 b' def revlist(ui, repo, *revs, **opts):'
373 373 helpcategory=command.CATEGORY_CHANGE_NAVIGATION,
374 374 )
375 375 def view(ui, repo, *etc, **opts):
376 b"start interactive history viewer"
376 """start interactive history viewer"""
377 377 opts = pycompat.byteskwargs(opts)
378 378 os.chdir(repo.root)
379 379 optstr = b' '.join(
@@ -1497,7 +1497,7 b' def commitnode(repo, p1, p2, editor, ext'
1497 1497
1498 1498
1499 1499 def rebasenode(repo, rev, p1, base, collapse, dest, wctx):
1500 b'Rebase a single revision rev on top of p1 using base as merge ancestor'
1500 """Rebase a single revision rev on top of p1 using base as merge ancestor"""
1501 1501 # Merge phase
1502 1502 # Update to destination and merge it with local
1503 1503 if wctx.isinmemory():
@@ -1853,7 +1853,7 b' def defineparents(repo, rev, destmap, st'
1853 1853
1854 1854
1855 1855 def isagitpatch(repo, patchname):
1856 b'Return true if the given patch is in git format'
1856 """Return true if the given patch is in git format"""
1857 1857 mqpatch = os.path.join(repo.mq.path, patchname)
1858 1858 for line in patch.linereader(open(mqpatch, b'rb')):
1859 1859 if line.startswith(b'diff --git'):
@@ -1862,7 +1862,7 b' def isagitpatch(repo, patchname):'
1862 1862
1863 1863
1864 1864 def updatemq(repo, state, skipped, **opts):
1865 b'Update rebased mq patches - finalize and then import them'
1865 """Update rebased mq patches - finalize and then import them"""
1866 1866 mqrebase = {}
1867 1867 mq = repo.mq
1868 1868 original_series = mq.fullseries[:]
@@ -1916,7 +1916,7 b' def updatemq(repo, state, skipped, **opt'
1916 1916
1917 1917
1918 1918 def storecollapsemsg(repo, collapsemsg):
1919 b'Store the collapse message to allow recovery'
1919 """Store the collapse message to allow recovery"""
1920 1920 collapsemsg = collapsemsg or b''
1921 1921 f = repo.vfs(b"last-message.txt", b"w")
1922 1922 f.write(b"%s\n" % collapsemsg)
@@ -1924,12 +1924,12 b' def storecollapsemsg(repo, collapsemsg):'
1924 1924
1925 1925
1926 1926 def clearcollapsemsg(repo):
1927 b'Remove collapse message file'
1927 """Remove collapse message file"""
1928 1928 repo.vfs.unlinkpath(b"last-message.txt", ignoremissing=True)
1929 1929
1930 1930
1931 1931 def restorecollapsemsg(repo, isabort):
1932 b'Restore previously stored collapse message'
1932 """Restore previously stored collapse message"""
1933 1933 try:
1934 1934 f = repo.vfs(b"last-message.txt")
1935 1935 collapsemsg = f.readline().strip()
@@ -1946,7 +1946,7 b' def restorecollapsemsg(repo, isabort):'
1946 1946
1947 1947
1948 1948 def clearstatus(repo):
1949 b'Remove the status files'
1949 """Remove the status files"""
1950 1950 # Make sure the active transaction won't write the state file
1951 1951 tr = repo.currenttransaction()
1952 1952 if tr:
@@ -2127,7 +2127,7 b' def clearrebased('
2127 2127
2128 2128
2129 2129 def pullrebase(orig, ui, repo, *args, **opts):
2130 b'Call rebase after pull if the latter has been invoked with --rebase'
2130 """Call rebase after pull if the latter has been invoked with --rebase"""
2131 2131 if opts.get('rebase'):
2132 2132 if ui.configbool(b'commands', b'rebase.requiredest'):
2133 2133 msg = _(b'rebase destination required by configuration')
@@ -405,7 +405,7 b' class changelog(revlog.revlog):'
405 405 self._copiesstorage = opener.options.get(b'copies-storage')
406 406
407 407 def delayupdate(self, tr):
408 b"delay visibility of index updates to other readers"
408 """delay visibility of index updates to other readers"""
409 409
410 410 if not self._delayed:
411 411 if len(self) == 0:
@@ -423,7 +423,7 b' class changelog(revlog.revlog):'
423 423 tr.addfinalize(b'cl-%i' % id(self), self._finalize)
424 424
425 425 def _finalize(self, tr):
426 b"finalize index updates"
426 """finalize index updates"""
427 427 self._delayed = False
428 428 self.opener = self._realopener
429 429 # move redirected index data back into place
@@ -443,7 +443,8 b' class changelog(revlog.revlog):'
443 443 self._enforceinlinesize(tr)
444 444
445 445 def _writepending(self, tr):
446 b"create a file containing the unfinalized state for pretxnchangegroup"
446 """create a file containing the unfinalized state for
447 pretxnchangegroup"""
447 448 if self._delaybuf:
448 449 # make a temporary copy of the index
449 450 fp1 = self._realopener(self.indexfile)
@@ -330,7 +330,7 b' def _activeeffects(ui):'
330 330
331 331
332 332 def valideffect(ui, effect):
333 b'Determine if the effect is valid or not.'
333 """Determine if the effect is valid or not."""
334 334 return (not ui._terminfoparams and effect in _activeeffects(ui)) or (
335 335 effect in ui._terminfoparams or effect[:-11] in ui._terminfoparams
336 336 )
@@ -377,7 +377,7 b' def _mergeeffects(text, start, stop):'
377 377
378 378
379 379 def _render_effects(ui, text, effects):
380 b'Wrap text in commands to turn on each effect.'
380 """Wrap text in commands to turn on each effect."""
381 381 if not text:
382 382 return text
383 383 if ui._terminfoparams:
@@ -1587,7 +1587,7 b' class workingctx(committablectx):'
1587 1587 )
1588 1588
1589 1589 def dirty(self, missing=False, merge=True, branch=True):
1590 b"check whether a working directory is modified"
1590 """check whether a working directory is modified"""
1591 1591 # check subrepos first
1592 1592 for s in sorted(self.substate):
1593 1593 if self.sub(s).dirty(missing=missing):
@@ -102,7 +102,7 b' class patchnode(object):'
102 102 raise NotImplementedError(b"method must be implemented by subclass")
103 103
104 104 def allchildren(self):
105 b"Return a list of all of the direct children of this node"
105 """Return a list of all of the direct children of this node"""
106 106 raise NotImplementedError(b"method must be implemented by subclass")
107 107
108 108 def nextsibling(self):
@@ -264,21 +264,23 b' class uiheader(patchnode):'
264 264 return None
265 265
266 266 def firstchild(self):
267 b"return the first child of this item, if one exists. otherwise None."
267 """return the first child of this item, if one exists. otherwise
268 None."""
268 269 if len(self.hunks) > 0:
269 270 return self.hunks[0]
270 271 else:
271 272 return None
272 273
273 274 def lastchild(self):
274 b"return the last child of this item, if one exists. otherwise None."
275 """return the last child of this item, if one exists. otherwise
276 None."""
275 277 if len(self.hunks) > 0:
276 278 return self.hunks[-1]
277 279 else:
278 280 return None
279 281
280 282 def allchildren(self):
281 b"return a list of all of the direct children of this node"
283 """return a list of all of the direct children of this node"""
282 284 return self.hunks
283 285
284 286 def __getattr__(self, name):
@@ -286,7 +288,7 b' class uiheader(patchnode):'
286 288
287 289
288 290 class uihunkline(patchnode):
289 b"represents a changed line in a hunk"
291 """represents a changed line in a hunk"""
290 292
291 293 def __init__(self, linetext, hunk):
292 294 self.linetext = linetext
@@ -319,16 +321,18 b' class uihunkline(patchnode):'
319 321 return None
320 322
321 323 def parentitem(self):
322 b"return the parent to the current item"
324 """return the parent to the current item"""
323 325 return self.hunk
324 326
325 327 def firstchild(self):
326 b"return the first child of this item, if one exists. otherwise None."
328 """return the first child of this item, if one exists. otherwise
329 None."""
327 330 # hunk-lines don't have children
328 331 return None
329 332
330 333 def lastchild(self):
331 b"return the last child of this item, if one exists. otherwise None."
334 """return the last child of this item, if one exists. otherwise
335 None."""
332 336 # hunk-lines don't have children
333 337 return None
334 338
@@ -372,25 +376,27 b' class uihunk(patchnode):'
372 376 return None
373 377
374 378 def parentitem(self):
375 b"return the parent to the current item"
379 """return the parent to the current item"""
376 380 return self.header
377 381
378 382 def firstchild(self):
379 b"return the first child of this item, if one exists. otherwise None."
383 """return the first child of this item, if one exists. otherwise
384 None."""
380 385 if len(self.changedlines) > 0:
381 386 return self.changedlines[0]
382 387 else:
383 388 return None
384 389
385 390 def lastchild(self):
386 b"return the last child of this item, if one exists. otherwise None."
391 """return the last child of this item, if one exists. otherwise
392 None."""
387 393 if len(self.changedlines) > 0:
388 394 return self.changedlines[-1]
389 395 else:
390 396 return None
391 397
392 398 def allchildren(self):
393 b"return a list of all of the direct children of this node"
399 """return a list of all of the direct children of this node"""
394 400 return self.changedlines
395 401
396 402 def countchanges(self):
@@ -853,7 +859,7 b' class curseschunkselector(object):'
853 859 self.currentselecteditem = currentitem
854 860
855 861 def updatescroll(self):
856 b"scroll the screen to fully show the currently-selected"
862 """scroll the screen to fully show the currently-selected"""
857 863 selstart = self.selecteditemstartline
858 864 selend = self.selecteditemendline
859 865
@@ -871,7 +877,7 b' class curseschunkselector(object):'
871 877 self.scrolllines(selstart - padstartbuffered)
872 878
873 879 def scrolllines(self, numlines):
874 b"scroll the screen up (down) by numlines when numlines >0 (<0)."
880 """scroll the screen up (down) by numlines when numlines >0 (<0)."""
875 881 self.firstlineofpadtoprint += numlines
876 882 if self.firstlineofpadtoprint < 0:
877 883 self.firstlineofpadtoprint = 0
@@ -973,7 +979,7 b' class curseschunkselector(object):'
973 979 )
974 980
975 981 def toggleall(self):
976 b"toggle the applied flag of all items."
982 """toggle the applied flag of all items."""
977 983 if self.waslasttoggleallapplied: # then unapply them this time
978 984 for item in self.headerlist:
979 985 if item.applied:
@@ -985,7 +991,8 b' class curseschunkselector(object):'
985 991 self.waslasttoggleallapplied = not self.waslasttoggleallapplied
986 992
987 993 def toggleallbetween(self):
988 b"toggle applied on or off for all items in range [lastapplied,current]."
994 """toggle applied on or off for all items in range [lastapplied,
995 current]. """
989 996 if (
990 997 not self.lastapplieditem
991 998 or self.currentselecteditem == self.lastapplieditem
@@ -1026,7 +1033,8 b' class curseschunkselector(object):'
1026 1033 nextitem = nextitem.nextitem()
1027 1034
1028 1035 def togglefolded(self, item=None, foldparent=False):
1029 b"toggle folded flag of specified item (defaults to currently selected)"
1036 """toggle folded flag of specified item (defaults to currently
1037 selected)"""
1030 1038 if item is None:
1031 1039 item = self.currentselecteditem
1032 1040 if foldparent or (isinstance(item, uiheader) and item.neverunfolded):
@@ -1320,7 +1328,7 b' class curseschunkselector(object):'
1320 1328 def printhunklinesbefore(
1321 1329 self, hunk, selected=False, towin=True, ignorefolding=False
1322 1330 ):
1323 b"includes start/end line indicator"
1331 """includes start/end line indicator"""
1324 1332 outstr = b""
1325 1333 # where hunk is in list of siblings
1326 1334 hunkindex = hunk.header.hunks.index(hunk)
@@ -1529,7 +1537,7 b' class curseschunkselector(object):'
1529 1537 return numlines
1530 1538
1531 1539 def sigwinchhandler(self, n, frame):
1532 b"handle window resizing"
1540 """handle window resizing"""
1533 1541 try:
1534 1542 curses.endwin()
1535 1543 self.xscreensize, self.yscreensize = scmutil.termsize(self.ui)
@@ -1599,11 +1607,11 b' class curseschunkselector(object):'
1599 1607 return colorpair
1600 1608
1601 1609 def initcolorpair(self, *args, **kwargs):
1602 b"same as getcolorpair."
1610 """same as getcolorpair."""
1603 1611 self.getcolorpair(*args, **kwargs)
1604 1612
1605 1613 def helpwindow(self):
1606 b"print a help window to the screen. exit after any keypress."
1614 """print a help window to the screen. exit after any keypress."""
1607 1615 helptext = _(
1608 1616 """ [press any key to return to the patch-display]
1609 1617
@@ -1654,7 +1662,7 b' the following are valid keystrokes:'
1654 1662 pass
1655 1663
1656 1664 def commitMessageWindow(self):
1657 b"Create a temporary commit message editing window on the screen."
1665 """Create a temporary commit message editing window on the screen."""
1658 1666
1659 1667 curses.raw()
1660 1668 curses.def_prog_mode()
@@ -1704,7 +1712,8 b' the following are valid keystrokes:'
1704 1712 self.recenterdisplayedarea()
1705 1713
1706 1714 def confirmationwindow(self, windowtext):
1707 b"display an informational window, then wait for and return a keypress."
1715 """display an informational window, then wait for and return a
1716 keypress."""
1708 1717
1709 1718 confirmwin = curses.newwin(self.yscreensize, 0, 0, 0)
1710 1719 try:
@@ -102,7 +102,7 b' class request(object):'
102 102
103 103
104 104 def run():
105 b"run the command in sys.argv"
105 """run the command in sys.argv"""
106 106 initstdio()
107 107 with tracing.log('parse args into request'):
108 108 req = request(pycompat.sysargv[1:])
@@ -312,13 +312,13 b' else:'
312 312
313 313 def colwidth(s):
314 314 # type: (bytes) -> int
315 b"Find the column width of a string for display in the local encoding"
315 """Find the column width of a string for display in the local encoding"""
316 316 return ucolwidth(s.decode(_sysstr(encoding), 'replace'))
317 317
318 318
319 319 def ucolwidth(d):
320 320 # type: (Text) -> int
321 b"Find the column width of a Unicode string for display"
321 """Find the column width of a Unicode string for display"""
322 322 eaw = getattr(unicodedata, 'east_asian_width', None)
323 323 if eaw is not None:
324 324 return sum([eaw(c) in _wide and 2 or 1 for c in d])
@@ -436,7 +436,7 b" def trim(s, width, ellipsis=b'', leftsid"
436 436
437 437 def lower(s):
438 438 # type: (bytes) -> bytes
439 b"best-effort encoding-aware case-folding of local string s"
439 """best-effort encoding-aware case-folding of local string s"""
440 440 try:
441 441 return asciilower(s)
442 442 except UnicodeDecodeError:
@@ -459,7 +459,7 b' def lower(s):'
459 459
460 460 def upper(s):
461 461 # type: (bytes) -> bytes
462 b"best-effort encoding-aware case-folding of local string s"
462 """best-effort encoding-aware case-folding of local string s"""
463 463 try:
464 464 return asciiupper(s)
465 465 except UnicodeDecodeError:
@@ -279,7 +279,7 b' def _picktool(repo, ui, path, binary, sy'
279 279
280 280
281 281 def _eoltype(data):
282 b"Guess the EOL type of a file"
282 """Guess the EOL type of a file"""
283 283 if b'\0' in data: # binary
284 284 return None
285 285 if b'\r\n' in data: # Windows
@@ -292,7 +292,7 b' def _eoltype(data):'
292 292
293 293
294 294 def _matcheol(file, back):
295 b"Convert EOL markers in a file to match origfile"
295 """Convert EOL markers in a file to match origfile"""
296 296 tostyle = _eoltype(back.data()) # No repo.wread filters?
297 297 if tostyle:
298 298 data = util.readfile(file)
@@ -1345,7 +1345,7 b' def verify(repo, level=None):'
1345 1345
1346 1346
1347 1347 def remoteui(src, opts):
1348 b'build a remote ui from ui or repo and opts'
1348 """build a remote ui from ui or repo and opts"""
1349 1349 if util.safehasattr(src, b'baseui'): # looks like a repository
1350 1350 dst = src.baseui.copy() # drop repo-specific config
1351 1351 src = src.ui # copy target options from repo
@@ -24,7 +24,7 b' class idirstate(interfaceutil.Interface)'
24 24 """Return a list of files containing patterns to ignore."""
25 25
26 26 def _ignorefileandline(f):
27 b"Given a file `f`, return the ignore file and line that ignores it."
27 """Given a file `f`, return the ignore file and line that ignores it."""
28 28
29 29 _checklink = interfaceutil.Attribute("""Callable for checking symlinks.""")
30 30 _checkexec = interfaceutil.Attribute("""Callable for checking exec bits.""")
@@ -2093,7 +2093,7 b' def applyupdates('
2093 2093
2094 2094
2095 2095 def recordupdates(repo, actions, branchmerge, getfiledata):
2096 b"record merge actions to the dirstate"
2096 """record merge actions to the dirstate"""
2097 2097 # remove (must come first)
2098 2098 for f, args, msg in actions.get(ACTION_REMOVE, []):
2099 2099 if branchmerge:
@@ -34,17 +34,17 b' class parser(object):'
34 34 self.current = None
35 35
36 36 def _advance(self):
37 b'advance the tokenizer'
37 """advance the tokenizer"""
38 38 t = self.current
39 39 self.current = next(self._iter, None)
40 40 return t
41 41
42 42 def _hasnewterm(self):
43 b'True if next token may start new term'
43 """True if next token may start new term"""
44 44 return any(self._elements[self.current[0]][1:3])
45 45
46 46 def _match(self, m):
47 b'make sure the tokenizer matches an end condition'
47 """make sure the tokenizer matches an end condition"""
48 48 if self.current[0] != m:
49 49 raise error.ParseError(
50 50 _(b"unexpected token: %s") % self.current[0], self.current[2]
@@ -52,7 +52,8 b' class parser(object):'
52 52 self._advance()
53 53
54 54 def _parseoperand(self, bind, m=None):
55 b'gather right-hand-side operand until an end condition or binding met'
55 """gather right-hand-side operand until an end condition or binding
56 met"""
56 57 if m and self.current[0] == m:
57 58 expr = None
58 59 else:
@@ -85,7 +86,7 b' class parser(object):'
85 86 return expr
86 87
87 88 def parse(self, tokeniter):
88 b'generate a parse tree from tokens'
89 """generate a parse tree from tokens"""
89 90 self._iter = tokeniter
90 91 self._advance()
91 92 res = self._parse()
@@ -93,13 +94,13 b' class parser(object):'
93 94 return res, pos
94 95
95 96 def eval(self, tree):
96 b'recursively evaluate a parse tree using node methods'
97 """recursively evaluate a parse tree using node methods"""
97 98 if not isinstance(tree, tuple):
98 99 return tree
99 100 return self._methods[tree[0]](*[self.eval(t) for t in tree[1:]])
100 101
101 102 def __call__(self, tokeniter):
102 b'parse tokens into a parse tree and evaluate if methods given'
103 """parse tokens into a parse tree and evaluate if methods given"""
103 104 t = self.parse(tokeniter)
104 105 if self._methods:
105 106 return self.eval(t)
@@ -1570,7 +1570,7 b' class hunk(object):'
1570 1570
1571 1571
1572 1572 class binhunk(object):
1573 b'A binary patch file.'
1573 """A binary patch file."""
1574 1574
1575 1575 def __init__(self, lr, fname):
1576 1576 self.text = None
@@ -1528,7 +1528,7 b' class gitsubrepo(abstractsubrepo):'
1528 1528 return branch2rev, rev2branch
1529 1529
1530 1530 def _gittracking(self, branches):
1531 b'return map of remote branch to local tracking branch'
1531 """return map of remote branch to local tracking branch"""
1532 1532 # assumes no more than one local tracking branch for each remote
1533 1533 tracking = {}
1534 1534 for b in branches:
@@ -653,7 +653,8 b' class ui(object):'
653 653 return main, sub
654 654
655 655 def configpath(self, section, name, default=_unset, untrusted=False):
656 b'get a path config item, expanded relative to repo root or config file'
656 """get a path config item, expanded relative to repo root or config
657 file"""
657 658 v = self.config(section, name, default, untrusted)
658 659 if v is None:
659 660 return None
@@ -249,7 +249,8 b' def tempfilter(s, cmd):'
249 249
250 250
251 251 def filter(s, cmd):
252 b"filter a string through a command that transforms its input to its output"
252 """filter a string through a command that transforms its input to its
253 output"""
253 254 for name, fn in pycompat.iteritems(_filtertable):
254 255 if cmd.startswith(name):
255 256 return fn(s, cmd[len(name) :].lstrip())
@@ -347,7 +348,7 b' def shellenviron(environ=None):'
347 348 """return environ with optional override, useful for shelling out"""
348 349
349 350 def py2shell(val):
350 b'convert python object into string that is useful to shell'
351 """convert python object into string that is useful to shell"""
351 352 if val is None or val is False:
352 353 return b'0'
353 354 if val is True:
@@ -507,7 +507,7 b' def findexe(command):'
507 507 pathexts = [b'']
508 508
509 509 def findexisting(pathcommand):
510 b'Will append extension (if needed) and return existing file'
510 """Will append extension (if needed) and return existing file"""
511 511 for ext in pathexts:
512 512 executable = pathcommand + ext
513 513 if os.path.exists(executable):
General Comments 0
You need to be logged in to leave comments. Login now