Mercurial > hg > mercurial-crew-with-dirclash
comparison purge.py @ 2375:9f4f77693890
Added some comments
author | Marco Barisione <marco@barisione.org> |
---|---|
date | Tue, 16 May 2006 21:43:21 +0200 |
parents | ffc2ed61061b |
children | 52cfb9864257 |
comparison
equal
deleted
inserted
replaced
2374:ffc2ed61061b | 2375:9f4f77693890 |
---|---|
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) |
100 path = head | 112 path = head |
101 ret.reverse() | 113 ret.reverse() |
102 return ret | 114 return ret |
103 | 115 |
104 def _join_path(self, splitted_path): | 116 def _join_path(self, splitted_path): |
117 ''' | |
118 Joins a list returned by _split_path(). | |
119 ''' | |
105 ret = '' | 120 ret = '' |
106 for part in splitted_path: | 121 for part in splitted_path: |
107 if ret: | 122 if ret: |
108 ret = os.path.join(ret, part) | 123 ret = os.path.join(ret, part) |
109 else: | 124 else: |