# HG changeset patch # User Thomas Arendsen Hein # Date 1163105625 -3600 # Node ID 63e173a4ffbc07b28da4294eca59dd0453d26e37 # Parent cabe628001204cf4bd96e1bc679104b317390d3f issue228: Fix repositories at the filesystem root (/ or C:\) Thanks to Robert Shaw and other people on the list for the suggestions. diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -32,7 +32,11 @@ class dirstate(object): def getcwd(self): cwd = os.getcwd() if cwd == self.root: return '' - return cwd[len(self.root) + 1:] + # self.root ends with a path separator if self.root is '/' or 'C:\' + common_prefix_len = len(self.root) + if not self.root.endswith(os.sep): + common_prefix_len += 1 + return cwd[common_prefix_len:] def hgignore(self): '''return the contents of .hgignore files as a list of patterns.