r"""FullName after removing the local path to the repository. If we have a real absolute path name here we can try to do something smart: detecting the root of the checkout and truncating /path/to/checkout from the name so that we get header guards that don't include things
(self)
| 1759 | return os.path.abspath(self._filename).replace("\\", "/") |
| 1760 | |
| 1761 | def RepositoryName(self): |
| 1762 | r"""FullName after removing the local path to the repository. |
| 1763 | |
| 1764 | If we have a real absolute path name here we can try to do something smart: |
| 1765 | detecting the root of the checkout and truncating /path/to/checkout from |
| 1766 | the name so that we get header guards that don't include things like |
| 1767 | "C:\\Documents and Settings\\..." or "/home/username/..." in them and thus |
| 1768 | people on different computers who have checked the source out to different |
| 1769 | locations won't see bogus errors. |
| 1770 | """ |
| 1771 | fullname = self.FullName() |
| 1772 | |
| 1773 | if os.path.exists(fullname): |
| 1774 | project_dir = os.path.dirname(fullname) |
| 1775 | |
| 1776 | # If the user specified a repository path, it exists, and the file is |
| 1777 | # contained in it, use the specified repository path |
| 1778 | if _repository: |
| 1779 | repo = FileInfo(_repository).FullName() |
| 1780 | root_dir = project_dir |
| 1781 | while os.path.exists(root_dir): |
| 1782 | # allow case insensitive compare on Windows |
| 1783 | if os.path.normcase(root_dir) == os.path.normcase(repo): |
| 1784 | return os.path.relpath(fullname, root_dir).replace("\\", "/") |
| 1785 | one_up_dir = os.path.dirname(root_dir) |
| 1786 | if one_up_dir == root_dir: |
| 1787 | break |
| 1788 | root_dir = one_up_dir |
| 1789 | |
| 1790 | if os.path.exists(os.path.join(project_dir, ".svn")): |
| 1791 | # If there's a .svn file in the current directory, we recursively look |
| 1792 | # up the directory tree for the top of the SVN checkout |
| 1793 | root_dir = project_dir |
| 1794 | one_up_dir = os.path.dirname(root_dir) |
| 1795 | while os.path.exists(os.path.join(one_up_dir, ".svn")): |
| 1796 | root_dir = os.path.dirname(root_dir) |
| 1797 | one_up_dir = os.path.dirname(one_up_dir) |
| 1798 | |
| 1799 | prefix = os.path.commonprefix([root_dir, project_dir]) |
| 1800 | return fullname[len(prefix) + 1 :] |
| 1801 | |
| 1802 | # Not SVN <= 1.6? Try to find a git, hg, or svn top level directory by |
| 1803 | # searching up from the current path. |
| 1804 | root_dir = current_dir = os.path.dirname(fullname) |
| 1805 | while current_dir != os.path.dirname(current_dir): |
| 1806 | if ( |
| 1807 | os.path.exists(os.path.join(current_dir, ".git")) |
| 1808 | or os.path.exists(os.path.join(current_dir, ".hg")) |
| 1809 | or os.path.exists(os.path.join(current_dir, ".svn")) |
| 1810 | ): |
| 1811 | root_dir = current_dir |
| 1812 | break |
| 1813 | current_dir = os.path.dirname(current_dir) |
| 1814 | |
| 1815 | if ( |
| 1816 | os.path.exists(os.path.join(root_dir, ".git")) |
| 1817 | or os.path.exists(os.path.join(root_dir, ".hg")) |
| 1818 | or os.path.exists(os.path.join(root_dir, ".svn")) |
no test coverage detected