81 try: |
81 try: |
82 os.rmdir(name) |
82 os.rmdir(name) |
83 except OSError, e: |
83 except OSError, e: |
84 self._error('"%s" cannot be removed' % name) |
84 self._error('"%s" cannot be removed' % name) |
85 |
85 |
86 def _relative_name(self, name): |
86 def _relative_name(self, path): |
87 splitted_path = self._split_path(name)[len(self._hg_root):] |
87 ''' |
|
88 Returns "path" but relative to the root directory of the |
|
89 repository and with '\\' replaced with '/'. |
|
90 This is needed because this is the format required by |
|
91 self._repo.dirstate.state(). |
|
92 ''' |
|
93 splitted_path = self._split_path(path)[len(self._hg_root):] |
88 # Even on Windows self._repo.dirstate.state() wants '/'. |
94 # Even on Windows self._repo.dirstate.state() wants '/'. |
89 return self._join_path(splitted_path).replace('\\', '/') |
95 return self._join_path(splitted_path).replace('\\', '/') |
90 |
96 |
91 def _split_path(self, path): |
97 def _split_path(self, path): |
|
98 ''' |
|
99 Retruns a list of the single files/directories in "path". |
|
100 For instance: |
|
101 '/home/user/test' -> ['/', 'home', 'user', 'test'] |
|
102 'C:\\Mercurial' -> ['C:\\', 'Mercurial'] |
|
103 ''' |
92 ret = [] |
104 ret = [] |
93 while True: |
105 while True: |
94 head, tail = os.path.split(path) |
106 head, tail = os.path.split(path) |
95 if tail: |
107 if tail: |
96 ret.append(tail) |
108 ret.append(tail) |