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