diff options
Diffstat (limited to 'project.py')
-rw-r--r-- | project.py | 57 |
1 files changed, 34 insertions, 23 deletions
@@ -320,11 +320,13 @@ class RemoteSpec(object): | |||
320 | def __init__(self, | 320 | def __init__(self, |
321 | name, | 321 | name, |
322 | url=None, | 322 | url=None, |
323 | pushUrl=None, | ||
323 | review=None, | 324 | review=None, |
324 | revision=None, | 325 | revision=None, |
325 | orig_name=None): | 326 | orig_name=None): |
326 | self.name = name | 327 | self.name = name |
327 | self.url = url | 328 | self.url = url |
329 | self.pushUrl = pushUrl | ||
328 | self.review = review | 330 | self.review = review |
329 | self.revision = revision | 331 | self.revision = revision |
330 | self.orig_name = orig_name | 332 | self.orig_name = orig_name |
@@ -909,11 +911,13 @@ class Project(object): | |||
909 | else: | 911 | else: |
910 | return False | 912 | return False |
911 | 913 | ||
912 | def PrintWorkTreeStatus(self, output_redir=None): | 914 | def PrintWorkTreeStatus(self, output_redir=None, quiet=False): |
913 | """Prints the status of the repository to stdout. | 915 | """Prints the status of the repository to stdout. |
914 | 916 | ||
915 | Args: | 917 | Args: |
916 | output: If specified, redirect the output to this object. | 918 | output: If specified, redirect the output to this object. |
919 | quiet: If True then only print the project name. Do not print | ||
920 | the modified files, branch name, etc. | ||
917 | """ | 921 | """ |
918 | if not os.path.isdir(self.worktree): | 922 | if not os.path.isdir(self.worktree): |
919 | if output_redir is None: | 923 | if output_redir is None: |
@@ -939,6 +943,10 @@ class Project(object): | |||
939 | out.redirect(output_redir) | 943 | out.redirect(output_redir) |
940 | out.project('project %-40s', self.relpath + '/ ') | 944 | out.project('project %-40s', self.relpath + '/ ') |
941 | 945 | ||
946 | if quiet: | ||
947 | out.nl() | ||
948 | return 'DIRTY' | ||
949 | |||
942 | branch = self.CurrentBranch | 950 | branch = self.CurrentBranch |
943 | if branch is None: | 951 | if branch is None: |
944 | out.nobranch('(*** NO BRANCH ***)') | 952 | out.nobranch('(*** NO BRANCH ***)') |
@@ -1256,13 +1264,18 @@ class Project(object): | |||
1256 | elif self.manifest.default.sync_c: | 1264 | elif self.manifest.default.sync_c: |
1257 | current_branch_only = True | 1265 | current_branch_only = True |
1258 | 1266 | ||
1267 | if self.clone_depth: | ||
1268 | depth = self.clone_depth | ||
1269 | else: | ||
1270 | depth = self.manifest.manifestProject.config.GetString('repo.depth') | ||
1271 | |||
1259 | need_to_fetch = not (optimized_fetch and | 1272 | need_to_fetch = not (optimized_fetch and |
1260 | (ID_RE.match(self.revisionExpr) and | 1273 | (ID_RE.match(self.revisionExpr) and |
1261 | self._CheckForSha1())) | 1274 | self._CheckForSha1())) |
1262 | if (need_to_fetch and | 1275 | if (need_to_fetch and |
1263 | not self._RemoteFetch(initial=is_new, quiet=quiet, alt_dir=alt_dir, | 1276 | not self._RemoteFetch(initial=is_new, quiet=quiet, alt_dir=alt_dir, |
1264 | current_branch_only=current_branch_only, | 1277 | current_branch_only=current_branch_only, |
1265 | no_tags=no_tags, prune=prune)): | 1278 | no_tags=no_tags, prune=prune, depth=depth)): |
1266 | return False | 1279 | return False |
1267 | 1280 | ||
1268 | if self.worktree: | 1281 | if self.worktree: |
@@ -1825,6 +1838,7 @@ class Project(object): | |||
1825 | 1838 | ||
1826 | remote = RemoteSpec(self.remote.name, | 1839 | remote = RemoteSpec(self.remote.name, |
1827 | url=url, | 1840 | url=url, |
1841 | pushUrl=self.remote.pushUrl, | ||
1828 | review=self.remote.review, | 1842 | review=self.remote.review, |
1829 | revision=self.remote.revision) | 1843 | revision=self.remote.revision) |
1830 | subproject = Project(manifest=self.manifest, | 1844 | subproject = Project(manifest=self.manifest, |
@@ -1834,7 +1848,7 @@ class Project(object): | |||
1834 | objdir=objdir, | 1848 | objdir=objdir, |
1835 | worktree=worktree, | 1849 | worktree=worktree, |
1836 | relpath=relpath, | 1850 | relpath=relpath, |
1837 | revisionExpr=self.revisionExpr, | 1851 | revisionExpr=rev, |
1838 | revisionId=rev, | 1852 | revisionId=rev, |
1839 | rebase=self.rebase, | 1853 | rebase=self.rebase, |
1840 | groups=self.groups, | 1854 | groups=self.groups, |
@@ -1877,23 +1891,17 @@ class Project(object): | |||
1877 | quiet=False, | 1891 | quiet=False, |
1878 | alt_dir=None, | 1892 | alt_dir=None, |
1879 | no_tags=False, | 1893 | no_tags=False, |
1880 | prune=False): | 1894 | prune=False, |
1895 | depth=None): | ||
1881 | 1896 | ||
1882 | is_sha1 = False | 1897 | is_sha1 = False |
1883 | tag_name = None | 1898 | tag_name = None |
1884 | depth = None | ||
1885 | |||
1886 | # The depth should not be used when fetching to a mirror because | 1899 | # The depth should not be used when fetching to a mirror because |
1887 | # it will result in a shallow repository that cannot be cloned or | 1900 | # it will result in a shallow repository that cannot be cloned or |
1888 | # fetched from. | 1901 | # fetched from. |
1889 | if not self.manifest.IsMirror: | 1902 | # The repo project should also never be synced with partial depth. |
1890 | if self.clone_depth: | 1903 | if self.manifest.IsMirror or self.relpath == '.repo/repo': |
1891 | depth = self.clone_depth | 1904 | depth = None |
1892 | else: | ||
1893 | depth = self.manifest.manifestProject.config.GetString('repo.depth') | ||
1894 | # The repo project should never be synced with partial depth | ||
1895 | if self.relpath == '.repo/repo': | ||
1896 | depth = None | ||
1897 | 1905 | ||
1898 | if depth: | 1906 | if depth: |
1899 | current_branch_only = True | 1907 | current_branch_only = True |
@@ -2054,21 +2062,22 @@ class Project(object): | |||
2054 | os.remove(packed_refs) | 2062 | os.remove(packed_refs) |
2055 | self.bare_git.pack_refs('--all', '--prune') | 2063 | self.bare_git.pack_refs('--all', '--prune') |
2056 | 2064 | ||
2057 | if is_sha1 and current_branch_only and self.upstream: | 2065 | if is_sha1 and current_branch_only: |
2058 | # We just synced the upstream given branch; verify we | 2066 | # We just synced the upstream given branch; verify we |
2059 | # got what we wanted, else trigger a second run of all | 2067 | # got what we wanted, else trigger a second run of all |
2060 | # refs. | 2068 | # refs. |
2061 | if not self._CheckForSha1(): | 2069 | if not self._CheckForSha1(): |
2062 | if not depth: | 2070 | if current_branch_only and depth: |
2063 | # Avoid infinite recursion when depth is True (since depth implies | 2071 | # Sync the current branch only with depth set to None |
2064 | # current_branch_only) | ||
2065 | return self._RemoteFetch(name=name, current_branch_only=False, | ||
2066 | initial=False, quiet=quiet, alt_dir=alt_dir) | ||
2067 | if self.clone_depth: | ||
2068 | self.clone_depth = None | ||
2069 | return self._RemoteFetch(name=name, | 2072 | return self._RemoteFetch(name=name, |
2070 | current_branch_only=current_branch_only, | 2073 | current_branch_only=current_branch_only, |
2071 | initial=False, quiet=quiet, alt_dir=alt_dir) | 2074 | initial=False, quiet=quiet, alt_dir=alt_dir, |
2075 | depth=None) | ||
2076 | else: | ||
2077 | # Avoid infinite recursion: sync all branches with depth set to None | ||
2078 | return self._RemoteFetch(name=name, current_branch_only=False, | ||
2079 | initial=False, quiet=quiet, alt_dir=alt_dir, | ||
2080 | depth=None) | ||
2072 | 2081 | ||
2073 | return ok | 2082 | return ok |
2074 | 2083 | ||
@@ -2346,6 +2355,7 @@ class Project(object): | |||
2346 | if self.remote.url: | 2355 | if self.remote.url: |
2347 | remote = self.GetRemote(self.remote.name) | 2356 | remote = self.GetRemote(self.remote.name) |
2348 | remote.url = self.remote.url | 2357 | remote.url = self.remote.url |
2358 | remote.pushUrl = self.remote.pushUrl | ||
2349 | remote.review = self.remote.review | 2359 | remote.review = self.remote.review |
2350 | remote.projectname = self.name | 2360 | remote.projectname = self.name |
2351 | 2361 | ||
@@ -2390,6 +2400,7 @@ class Project(object): | |||
2390 | src = os.path.realpath(os.path.join(srcdir, name)) | 2400 | src = os.path.realpath(os.path.join(srcdir, name)) |
2391 | # Fail if the links are pointing to the wrong place | 2401 | # Fail if the links are pointing to the wrong place |
2392 | if src != dst: | 2402 | if src != dst: |
2403 | _error('%s is different in %s vs %s', name, destdir, srcdir) | ||
2393 | raise GitError('--force-sync not enabled; cannot overwrite a local ' | 2404 | raise GitError('--force-sync not enabled; cannot overwrite a local ' |
2394 | 'work tree. If you\'re comfortable with the ' | 2405 | 'work tree. If you\'re comfortable with the ' |
2395 | 'possibility of losing the work tree\'s git metadata,' | 2406 | 'possibility of losing the work tree\'s git metadata,' |