diff --git a/hgext/convert/cvs.py b/hgext/convert/cvs.py --- a/hgext/convert/cvs.py +++ b/hgext/convert/cvs.py @@ -15,6 +15,7 @@ from mercurial.i18n import _ from mercurial import ( encoding, error, + pycompat, util, ) @@ -69,7 +70,7 @@ class convert_cvs(converter_source): raise error.Abort(_('revision %s is not a patchset number') % self.revs[0]) - d = os.getcwd() + d = pycompat.getcwd() try: os.chdir(self.path) id = None diff --git a/hgext/convert/subversion.py b/hgext/convert/subversion.py --- a/hgext/convert/subversion.py +++ b/hgext/convert/subversion.py @@ -12,6 +12,7 @@ from mercurial.i18n import _ from mercurial import ( encoding, error, + pycompat, scmutil, strutil, util, @@ -1119,7 +1120,7 @@ class svn_sink(converter_sink, commandli self.delexec = [] self.copies = [] self.wc = None - self.cwd = os.getcwd() + self.cwd = pycompat.getcwd() created = False if os.path.isfile(os.path.join(path, '.svn', 'entries')): @@ -1139,7 +1140,8 @@ class svn_sink(converter_sink, commandli path = '/' + path path = 'file://' + path - wcpath = os.path.join(os.getcwd(), os.path.basename(path) + '-wc') + wcpath = os.path.join(pycompat.getcwd(), os.path.basename(path) + + '-wc') ui.status(_('initializing svn working copy %r\n') % os.path.basename(wcpath)) self.run0('checkout', path, wcpath) diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -87,6 +87,7 @@ from mercurial import ( lock as lockmod, patch as patchmod, phases, + pycompat, registrar, revset, scmutil, @@ -3523,7 +3524,7 @@ def mqinit(orig, ui, *args, **kwargs): raise error.Abort(_('only a local queue repository ' 'may be initialized')) else: - repopath = cmdutil.findrepo(os.getcwd()) + repopath = cmdutil.findrepo(pycompat.getcwd()) if not repopath: raise error.Abort(_('there is no Mercurial repository here ' '(.hg not found)')) diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py --- a/mercurial/bundlerepo.py +++ b/mercurial/bundlerepo.py @@ -35,6 +35,7 @@ from . import ( node as nodemod, pathutil, phases, + pycompat, revlog, scmutil, util, @@ -392,7 +393,7 @@ class bundlerepository(localrepo.localre return bundlepeer(self) def getcwd(self): - return os.getcwd() # always outside the repo + return pycompat.getcwd() # always outside the repo # Check if parents exist in localrepo before setting def setparents(self, p1, p2=nullid): @@ -412,13 +413,13 @@ def instance(ui, path, create): parentpath = ui.config("bundle", "mainreporoot", "") if not parentpath: # try to find the correct path to the working directory repo - parentpath = cmdutil.findrepo(os.getcwd()) + parentpath = cmdutil.findrepo(pycompat.getcwd()) if parentpath is None: parentpath = '' if parentpath: # Try to make the full path relative so we get a nice, short URL. # In particular, we don't want temp dir names in test outputs. - cwd = os.getcwd() + cwd = pycompat.getcwd() if parentpath == cwd: parentpath = '' else: diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -38,6 +38,7 @@ from . import ( patch, pathutil, phases, + pycompat, repair, revlog, revset, @@ -570,7 +571,7 @@ def openrevlog(repo, cmd, file_, opts): raise error.CommandError(cmd, _('invalid arguments')) if not os.path.isfile(file_): raise error.Abort(_("revlog '%s' not found") % file_) - r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), + r = revlog.revlog(scmutil.opener(pycompat.getcwd(), audit=False), file_[:-2] + ".i") return r @@ -2744,7 +2745,7 @@ def commitforceeditor(repo, ctx, subs, f committext = buildcommittext(repo, ctx, subs, extramsg) # run editor in the repository root - olddir = os.getcwd() + olddir = pycompat.getcwd() os.chdir(repo.root) # make in-memory changes visible to external process diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -2630,7 +2630,7 @@ def debugpathcomplete(ui, repo, *specs, def complete(path, acceptable): dirstate = repo.dirstate - spec = os.path.normpath(os.path.join(os.getcwd(), path)) + spec = os.path.normpath(os.path.join(pycompat.getcwd(), path)) rootdir = repo.root + os.sep if spec != repo.root and not spec.startswith(rootdir): return [], [] diff --git a/mercurial/commandserver.py b/mercurial/commandserver.py --- a/mercurial/commandserver.py +++ b/mercurial/commandserver.py @@ -21,6 +21,7 @@ from .i18n import _ from . import ( encoding, error, + pycompat, util, ) @@ -152,7 +153,7 @@ class server(object): based stream to fout. """ def __init__(self, ui, repo, fin, fout): - self.cwd = os.getcwd() + self.cwd = pycompat.getcwd() # developer config: cmdserver.log logpath = ui.config("cmdserver", "log", None) diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py --- a/mercurial/debugcommands.py +++ b/mercurial/debugcommands.py @@ -8,7 +8,6 @@ from __future__ import absolute_import import operator -import os import random from .i18n import _ @@ -30,6 +29,7 @@ from . import ( hg, localrepo, lock as lockmod, + pycompat, revlog, scmutil, setdiscovery, @@ -50,7 +50,7 @@ def debugancestor(ui, repo, *args): """find the ancestor revision of two revisions in a given index""" if len(args) == 3: index, rev1, rev2 = args - r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), index) + r = revlog.revlog(scmutil.opener(pycompat.getcwd(), audit=False), index) lookup = r.lookup elif len(args) == 2: if not repo: @@ -385,7 +385,8 @@ def debugdag(ui, repo, file_=None, *revs spaces = opts.get('spaces') dots = opts.get('dots') if file_: - rlog = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_) + rlog = revlog.revlog(scmutil.opener(pycompat.getcwd(), audit=False), + file_) revs = set((int(r) for r in revs)) def events(): for r in rlog: diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -271,7 +271,7 @@ class dirstate(object): @propertycache def _cwd(self): - return os.getcwd() + return pycompat.getcwd() def getcwd(self): '''Return the path from which a canonical path is calculated. diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py --- a/mercurial/dispatch.py +++ b/mercurial/dispatch.py @@ -880,7 +880,7 @@ def _dispatch(req): if not path: raise error.RepoError(_("no repository found in" " '%s' (.hg not found)") - % os.getcwd()) + % pycompat.getcwd()) raise if repo: ui = repo.ui diff --git a/mercurial/hook.py b/mercurial/hook.py --- a/mercurial/hook.py +++ b/mercurial/hook.py @@ -16,6 +16,7 @@ from . import ( demandimport, error, extensions, + pycompat, util, ) @@ -141,7 +142,7 @@ def _exthook(ui, repo, name, cmd, args, if repo: cwd = repo.root else: - cwd = os.getcwd() + cwd = pycompat.getcwd() r = ui.system(cmd, environ=env, cwd=cwd) duration = time.time() - starttime diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -28,6 +28,7 @@ from . import ( error, filemerge, obsolete, + pycompat, scmutil, subrepo, util, @@ -1040,7 +1041,7 @@ def batchremove(repo, actions): wjoin = repo.wjoin audit = repo.wvfs.audit try: - cwd = os.getcwd() + cwd = pycompat.getcwd() except OSError as err: if err.errno != errno.ENOENT: raise @@ -1066,7 +1067,7 @@ def batchremove(repo, actions): # cwd was present before we started to remove files # let's check if it is present after we removed them try: - os.getcwd() + pycompat.getcwd() except OSError as err: if err.errno != errno.ENOENT: raise diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -27,6 +27,7 @@ from . import ( error, formatter, progress, + pycompat, scmutil, util, ) @@ -227,7 +228,7 @@ class ui(object): if section in (None, 'paths'): # expand vars and ~ # translate paths relative to root (or home) into absolute paths - root = root or os.getcwd() + root = root or pycompat.getcwd() for c in self._tcfg, self._ucfg, self._ocfg: for n, p in c.items('paths'): # Ignore sub-options. diff --git a/mercurial/unionrepo.py b/mercurial/unionrepo.py --- a/mercurial/unionrepo.py +++ b/mercurial/unionrepo.py @@ -13,8 +13,6 @@ allowing operations like diff and log wi from __future__ import absolute_import -import os - from .i18n import _ from .node import nullid @@ -27,6 +25,7 @@ from . import ( manifest, mdiff, pathutil, + pycompat, revlog, scmutil, util, @@ -229,7 +228,7 @@ class unionrepository(localrepo.localrep return unionpeer(self) def getcwd(self): - return os.getcwd() # always outside the repo + return pycompat.getcwd() # always outside the repo def instance(ui, path, create): if create: @@ -237,13 +236,13 @@ def instance(ui, path, create): parentpath = ui.config("bundle", "mainreporoot", "") if not parentpath: # try to find the correct path to the working directory repo - parentpath = cmdutil.findrepo(os.getcwd()) + parentpath = cmdutil.findrepo(pycompat.getcwd()) if parentpath is None: parentpath = '' if parentpath: # Try to make the full path relative so we get a nice, short URL. # In particular, we don't want temp dir names in test outputs. - cwd = os.getcwd() + cwd = pycompat.getcwd() if parentpath == cwd: parentpath = '' else: