comparison mercurial/debugcommands.py @ 39818:24e493ec2229

py3: rename pycompat.getcwd() to encoding.getcwd() (API) We need to avoid os.getcwdb() on Windows to avoid DeprecationWarnings, and we need encoding.strtolocal() to encode the result of os.getcwd().
author Matt Harbison <matt_harbison@yahoo.com>
date Fri, 21 Sep 2018 19:48:23 -0400
parents 7e99b02768ef
children c31ce080eb75
comparison
equal deleted inserted replaced
39817:94c25f694ec3 39818:24e493ec2229
97 @command('debugancestor', [], _('[INDEX] REV1 REV2'), optionalrepo=True) 97 @command('debugancestor', [], _('[INDEX] REV1 REV2'), optionalrepo=True)
98 def debugancestor(ui, repo, *args): 98 def debugancestor(ui, repo, *args):
99 """find the ancestor revision of two revisions in a given index""" 99 """find the ancestor revision of two revisions in a given index"""
100 if len(args) == 3: 100 if len(args) == 3:
101 index, rev1, rev2 = args 101 index, rev1, rev2 = args
102 r = revlog.revlog(vfsmod.vfs(pycompat.getcwd(), audit=False), index) 102 r = revlog.revlog(vfsmod.vfs(encoding.getcwd(), audit=False), index)
103 lookup = r.lookup 103 lookup = r.lookup
104 elif len(args) == 2: 104 elif len(args) == 2:
105 if not repo: 105 if not repo:
106 raise error.Abort(_('there is no Mercurial repository here ' 106 raise error.Abort(_('there is no Mercurial repository here '
107 '(.hg not found)')) 107 '(.hg not found)'))
501 Otherwise, the changelog DAG of the current repo is emitted. 501 Otherwise, the changelog DAG of the current repo is emitted.
502 """ 502 """
503 spaces = opts.get(r'spaces') 503 spaces = opts.get(r'spaces')
504 dots = opts.get(r'dots') 504 dots = opts.get(r'dots')
505 if file_: 505 if file_:
506 rlog = revlog.revlog(vfsmod.vfs(pycompat.getcwd(), audit=False), 506 rlog = revlog.revlog(vfsmod.vfs(encoding.getcwd(), audit=False),
507 file_) 507 file_)
508 revs = set((int(r) for r in revs)) 508 revs = set((int(r) for r in revs))
509 def events(): 509 def events():
510 for r in rlog: 510 for r in rlog:
511 yield 'n', (r, list(p for p in rlog.parentrevs(r) 511 yield 'n', (r, list(p for p in rlog.parentrevs(r)
1752 Completion extends only to the next path segment unless 1752 Completion extends only to the next path segment unless
1753 --full is specified, in which case entire paths are used.''' 1753 --full is specified, in which case entire paths are used.'''
1754 1754
1755 def complete(path, acceptable): 1755 def complete(path, acceptable):
1756 dirstate = repo.dirstate 1756 dirstate = repo.dirstate
1757 spec = os.path.normpath(os.path.join(pycompat.getcwd(), path)) 1757 spec = os.path.normpath(os.path.join(encoding.getcwd(), path))
1758 rootdir = repo.root + pycompat.ossep 1758 rootdir = repo.root + pycompat.ossep
1759 if spec != repo.root and not spec.startswith(rootdir): 1759 if spec != repo.root and not spec.startswith(rootdir):
1760 return [], [] 1760 return [], []
1761 if os.path.isdir(spec): 1761 if os.path.isdir(spec):
1762 spec += '/' 1762 spec += '/'