diff options
-rw-r--r-- | .mailmap | 1 | ||||
-rw-r--r-- | docs/manifest-format.txt | 3 | ||||
-rw-r--r-- | git_config.py | 3 | ||||
-rwxr-xr-x | main.py | 4 | ||||
-rw-r--r-- | manifest_xml.py | 4 | ||||
-rw-r--r-- | project.py | 59 | ||||
-rwxr-xr-x | repo | 3 | ||||
-rw-r--r-- | subcmds/abandon.py | 2 | ||||
-rw-r--r-- | subcmds/gitc_delete.py | 2 | ||||
-rw-r--r-- | subcmds/init.py | 10 | ||||
-rw-r--r-- | subcmds/sync.py | 5 |
11 files changed, 76 insertions, 20 deletions
@@ -1,4 +1,5 @@ | |||
1 | Anthony Newnam <anthony.newnam@garmin.com> Anthony <anthony@bnovc.com> | 1 | Anthony Newnam <anthony.newnam@garmin.com> Anthony <anthony@bnovc.com> |
2 | He Ping <tdihp@hotmail.com> heping <tdihp@hotmail.com> | ||
2 | Hu Xiuyun <xiuyun.hu@hisilicon.com> Hu xiuyun <xiuyun.hu@hisilicon.com> | 3 | Hu Xiuyun <xiuyun.hu@hisilicon.com> Hu xiuyun <xiuyun.hu@hisilicon.com> |
3 | Hu Xiuyun <xiuyun.hu@hisilicon.com> Hu Xiuyun <clouds08@qq.com> | 4 | Hu Xiuyun <xiuyun.hu@hisilicon.com> Hu Xiuyun <clouds08@qq.com> |
4 | Jelly Chen <chenguodong@huawei.com> chenguodong <chenguodong@huawei.com> | 5 | Jelly Chen <chenguodong@huawei.com> chenguodong <chenguodong@huawei.com> |
diff --git a/docs/manifest-format.txt b/docs/manifest-format.txt index 4484d803..77784099 100644 --- a/docs/manifest-format.txt +++ b/docs/manifest-format.txt | |||
@@ -27,7 +27,8 @@ following DTD: | |||
27 | remove-project*, | 27 | remove-project*, |
28 | project*, | 28 | project*, |
29 | extend-project*, | 29 | extend-project*, |
30 | repo-hooks?)> | 30 | repo-hooks?, |
31 | include*)> | ||
31 | 32 | ||
32 | <!ELEMENT notice (#PCDATA)> | 33 | <!ELEMENT notice (#PCDATA)> |
33 | 34 | ||
diff --git a/git_config.py b/git_config.py index e2236785..e00f6be2 100644 --- a/git_config.py +++ b/git_config.py | |||
@@ -631,6 +631,9 @@ class Remote(object): | |||
631 | elif u.startswith('sso:'): | 631 | elif u.startswith('sso:'): |
632 | self._review_url = u # Assume it's right | 632 | self._review_url = u # Assume it's right |
633 | REVIEW_CACHE[u] = self._review_url | 633 | REVIEW_CACHE[u] = self._review_url |
634 | elif 'REPO_IGNORE_SSH_INFO' in os.environ: | ||
635 | self._review_url = http_url | ||
636 | REVIEW_CACHE[u] = self._review_url | ||
634 | else: | 637 | else: |
635 | try: | 638 | try: |
636 | info_url = u + 'ssh_info' | 639 | info_url = u + 'ssh_info' |
@@ -198,6 +198,10 @@ class _Repo(object): | |||
198 | else: | 198 | else: |
199 | print('error: project group must be enabled for the project in the current directory', file=sys.stderr) | 199 | print('error: project group must be enabled for the project in the current directory', file=sys.stderr) |
200 | result = 1 | 200 | result = 1 |
201 | except SystemExit as e: | ||
202 | if e.code: | ||
203 | result = e.code | ||
204 | raise | ||
201 | finally: | 205 | finally: |
202 | elapsed = time.time() - start | 206 | elapsed = time.time() - start |
203 | hours, remainder = divmod(elapsed, 3600) | 207 | hours, remainder = divmod(elapsed, 3600) |
diff --git a/manifest_xml.py b/manifest_xml.py index 0859e1fb..73e34964 100644 --- a/manifest_xml.py +++ b/manifest_xml.py | |||
@@ -393,6 +393,10 @@ class XmlManifest(object): | |||
393 | def IsArchive(self): | 393 | def IsArchive(self): |
394 | return self.manifestProject.config.GetBoolean('repo.archive') | 394 | return self.manifestProject.config.GetBoolean('repo.archive') |
395 | 395 | ||
396 | @property | ||
397 | def HasSubmodules(self): | ||
398 | return self.manifestProject.config.GetBoolean('repo.submodules') | ||
399 | |||
396 | def _Unload(self): | 400 | def _Unload(self): |
397 | self._loaded = False | 401 | self._loaded = False |
398 | self._projects = {} | 402 | self._projects = {} |
@@ -1198,7 +1198,8 @@ class Project(object): | |||
1198 | no_tags=False, | 1198 | no_tags=False, |
1199 | archive=False, | 1199 | archive=False, |
1200 | optimized_fetch=False, | 1200 | optimized_fetch=False, |
1201 | prune=False): | 1201 | prune=False, |
1202 | submodules=False): | ||
1202 | """Perform only the network IO portion of the sync process. | 1203 | """Perform only the network IO portion of the sync process. |
1203 | Local working directory/branch state is not affected. | 1204 | Local working directory/branch state is not affected. |
1204 | """ | 1205 | """ |
@@ -1275,7 +1276,8 @@ class Project(object): | |||
1275 | if (need_to_fetch and | 1276 | if (need_to_fetch and |
1276 | not self._RemoteFetch(initial=is_new, quiet=quiet, alt_dir=alt_dir, | 1277 | not self._RemoteFetch(initial=is_new, quiet=quiet, alt_dir=alt_dir, |
1277 | current_branch_only=current_branch_only, | 1278 | current_branch_only=current_branch_only, |
1278 | no_tags=no_tags, prune=prune, depth=depth)): | 1279 | no_tags=no_tags, prune=prune, depth=depth, |
1280 | submodules=submodules)): | ||
1279 | return False | 1281 | return False |
1280 | 1282 | ||
1281 | if self.worktree: | 1283 | if self.worktree: |
@@ -1331,11 +1333,11 @@ class Project(object): | |||
1331 | raise ManifestInvalidRevisionError('revision %s in %s not found' % | 1333 | raise ManifestInvalidRevisionError('revision %s in %s not found' % |
1332 | (self.revisionExpr, self.name)) | 1334 | (self.revisionExpr, self.name)) |
1333 | 1335 | ||
1334 | def Sync_LocalHalf(self, syncbuf, force_sync=False): | 1336 | def Sync_LocalHalf(self, syncbuf, force_sync=False, submodules=False): |
1335 | """Perform only the local IO portion of the sync process. | 1337 | """Perform only the local IO portion of the sync process. |
1336 | Network access is not required. | 1338 | Network access is not required. |
1337 | """ | 1339 | """ |
1338 | self._InitWorkTree(force_sync=force_sync) | 1340 | self._InitWorkTree(force_sync=force_sync, submodules=submodules) |
1339 | all_refs = self.bare_ref.all | 1341 | all_refs = self.bare_ref.all |
1340 | self.CleanPublishedCache(all_refs) | 1342 | self.CleanPublishedCache(all_refs) |
1341 | revid = self.GetRevisionId(all_refs) | 1343 | revid = self.GetRevisionId(all_refs) |
@@ -1344,6 +1346,9 @@ class Project(object): | |||
1344 | self._FastForward(revid) | 1346 | self._FastForward(revid) |
1345 | self._CopyAndLinkFiles() | 1347 | self._CopyAndLinkFiles() |
1346 | 1348 | ||
1349 | def _dosubmodules(): | ||
1350 | self._SyncSubmodules(quiet=True) | ||
1351 | |||
1347 | head = self.work_git.GetHead() | 1352 | head = self.work_git.GetHead() |
1348 | if head.startswith(R_HEADS): | 1353 | if head.startswith(R_HEADS): |
1349 | branch = head[len(R_HEADS):] | 1354 | branch = head[len(R_HEADS):] |
@@ -1377,6 +1382,8 @@ class Project(object): | |||
1377 | 1382 | ||
1378 | try: | 1383 | try: |
1379 | self._Checkout(revid, quiet=True) | 1384 | self._Checkout(revid, quiet=True) |
1385 | if submodules: | ||
1386 | self._SyncSubmodules(quiet=True) | ||
1380 | except GitError as e: | 1387 | except GitError as e: |
1381 | syncbuf.fail(self, e) | 1388 | syncbuf.fail(self, e) |
1382 | return | 1389 | return |
@@ -1401,6 +1408,8 @@ class Project(object): | |||
1401 | branch.name) | 1408 | branch.name) |
1402 | try: | 1409 | try: |
1403 | self._Checkout(revid, quiet=True) | 1410 | self._Checkout(revid, quiet=True) |
1411 | if submodules: | ||
1412 | self._SyncSubmodules(quiet=True) | ||
1404 | except GitError as e: | 1413 | except GitError as e: |
1405 | syncbuf.fail(self, e) | 1414 | syncbuf.fail(self, e) |
1406 | return | 1415 | return |
@@ -1426,6 +1435,8 @@ class Project(object): | |||
1426 | # strict subset. We can fast-forward safely. | 1435 | # strict subset. We can fast-forward safely. |
1427 | # | 1436 | # |
1428 | syncbuf.later1(self, _doff) | 1437 | syncbuf.later1(self, _doff) |
1438 | if submodules: | ||
1439 | syncbuf.later1(self, _dosubmodules) | ||
1429 | return | 1440 | return |
1430 | 1441 | ||
1431 | # Examine the local commits not in the remote. Find the | 1442 | # Examine the local commits not in the remote. Find the |
@@ -1477,19 +1488,28 @@ class Project(object): | |||
1477 | branch.Save() | 1488 | branch.Save() |
1478 | 1489 | ||
1479 | if cnt_mine > 0 and self.rebase: | 1490 | if cnt_mine > 0 and self.rebase: |
1491 | def _docopyandlink(): | ||
1492 | self._CopyAndLinkFiles() | ||
1493 | |||
1480 | def _dorebase(): | 1494 | def _dorebase(): |
1481 | self._Rebase(upstream='%s^1' % last_mine, onto=revid) | 1495 | self._Rebase(upstream='%s^1' % last_mine, onto=revid) |
1482 | self._CopyAndLinkFiles() | ||
1483 | syncbuf.later2(self, _dorebase) | 1496 | syncbuf.later2(self, _dorebase) |
1497 | if submodules: | ||
1498 | syncbuf.later2(self, _dosubmodules) | ||
1499 | syncbuf.later2(self, _docopyandlink) | ||
1484 | elif local_changes: | 1500 | elif local_changes: |
1485 | try: | 1501 | try: |
1486 | self._ResetHard(revid) | 1502 | self._ResetHard(revid) |
1503 | if submodules: | ||
1504 | self._SyncSubmodules(quiet=True) | ||
1487 | self._CopyAndLinkFiles() | 1505 | self._CopyAndLinkFiles() |
1488 | except GitError as e: | 1506 | except GitError as e: |
1489 | syncbuf.fail(self, e) | 1507 | syncbuf.fail(self, e) |
1490 | return | 1508 | return |
1491 | else: | 1509 | else: |
1492 | syncbuf.later1(self, _doff) | 1510 | syncbuf.later1(self, _doff) |
1511 | if submodules: | ||
1512 | syncbuf.later1(self, _dosubmodules) | ||
1493 | 1513 | ||
1494 | def AddCopyFile(self, src, dest, absdest): | 1514 | def AddCopyFile(self, src, dest, absdest): |
1495 | # dest should already be an absolute path, but src is project relative | 1515 | # dest should already be an absolute path, but src is project relative |
@@ -1892,7 +1912,8 @@ class Project(object): | |||
1892 | alt_dir=None, | 1912 | alt_dir=None, |
1893 | no_tags=False, | 1913 | no_tags=False, |
1894 | prune=False, | 1914 | prune=False, |
1895 | depth=None): | 1915 | depth=None, |
1916 | submodules=False): | ||
1896 | 1917 | ||
1897 | is_sha1 = False | 1918 | is_sha1 = False |
1898 | tag_name = None | 1919 | tag_name = None |
@@ -1963,15 +1984,17 @@ class Project(object): | |||
1963 | ids.add(ref_id) | 1984 | ids.add(ref_id) |
1964 | tmp.add(r) | 1985 | tmp.add(r) |
1965 | 1986 | ||
1966 | tmp_packed = '' | 1987 | tmp_packed_lines = [] |
1967 | old_packed = '' | 1988 | old_packed_lines = [] |
1968 | 1989 | ||
1969 | for r in sorted(all_refs): | 1990 | for r in sorted(all_refs): |
1970 | line = '%s %s\n' % (all_refs[r], r) | 1991 | line = '%s %s\n' % (all_refs[r], r) |
1971 | tmp_packed += line | 1992 | tmp_packed_lines.append(line) |
1972 | if r not in tmp: | 1993 | if r not in tmp: |
1973 | old_packed += line | 1994 | old_packed_lines.append(line) |
1974 | 1995 | ||
1996 | tmp_packed = ''.join(tmp_packed_lines) | ||
1997 | old_packed = ''.join(old_packed_lines) | ||
1975 | _lwrite(packed_refs, tmp_packed) | 1998 | _lwrite(packed_refs, tmp_packed) |
1976 | else: | 1999 | else: |
1977 | alt_dir = None | 2000 | alt_dir = None |
@@ -2004,6 +2027,9 @@ class Project(object): | |||
2004 | if prune: | 2027 | if prune: |
2005 | cmd.append('--prune') | 2028 | cmd.append('--prune') |
2006 | 2029 | ||
2030 | if submodules: | ||
2031 | cmd.append('--recurse-submodules=on-demand') | ||
2032 | |||
2007 | spec = [] | 2033 | spec = [] |
2008 | if not current_branch_only: | 2034 | if not current_branch_only: |
2009 | # Fetch whole repo | 2035 | # Fetch whole repo |
@@ -2224,6 +2250,13 @@ class Project(object): | |||
2224 | if GitCommand(self, cmd).Wait() != 0: | 2250 | if GitCommand(self, cmd).Wait() != 0: |
2225 | raise GitError('%s reset --hard %s ' % (self.name, rev)) | 2251 | raise GitError('%s reset --hard %s ' % (self.name, rev)) |
2226 | 2252 | ||
2253 | def _SyncSubmodules(self, quiet=True): | ||
2254 | cmd = ['submodule', 'update', '--init', '--recursive'] | ||
2255 | if quiet: | ||
2256 | cmd.append('-q') | ||
2257 | if GitCommand(self, cmd).Wait() != 0: | ||
2258 | raise GitError('%s submodule update --init --recursive %s ' % self.name) | ||
2259 | |||
2227 | def _Rebase(self, upstream, onto=None): | 2260 | def _Rebase(self, upstream, onto=None): |
2228 | cmd = ['rebase'] | 2261 | cmd = ['rebase'] |
2229 | if onto is not None: | 2262 | if onto is not None: |
@@ -2464,7 +2497,7 @@ class Project(object): | |||
2464 | else: | 2497 | else: |
2465 | raise | 2498 | raise |
2466 | 2499 | ||
2467 | def _InitWorkTree(self, force_sync=False): | 2500 | def _InitWorkTree(self, force_sync=False, submodules=False): |
2468 | dotgit = os.path.join(self.worktree, '.git') | 2501 | dotgit = os.path.join(self.worktree, '.git') |
2469 | init_dotgit = not os.path.exists(dotgit) | 2502 | init_dotgit = not os.path.exists(dotgit) |
2470 | try: | 2503 | try: |
@@ -2479,7 +2512,7 @@ class Project(object): | |||
2479 | if force_sync: | 2512 | if force_sync: |
2480 | try: | 2513 | try: |
2481 | shutil.rmtree(dotgit) | 2514 | shutil.rmtree(dotgit) |
2482 | return self._InitWorkTree(force_sync=False) | 2515 | return self._InitWorkTree(force_sync=False, submodules=submodules) |
2483 | except: | 2516 | except: |
2484 | raise e | 2517 | raise e |
2485 | raise e | 2518 | raise e |
@@ -2493,6 +2526,8 @@ class Project(object): | |||
2493 | if GitCommand(self, cmd).Wait() != 0: | 2526 | if GitCommand(self, cmd).Wait() != 0: |
2494 | raise GitError("cannot initialize work tree") | 2527 | raise GitError("cannot initialize work tree") |
2495 | 2528 | ||
2529 | if submodules: | ||
2530 | self._SyncSubmodules(quiet=True) | ||
2496 | self._CopyAndLinkFiles() | 2531 | self._CopyAndLinkFiles() |
2497 | except Exception: | 2532 | except Exception: |
2498 | if init_dotgit: | 2533 | if init_dotgit: |
@@ -192,6 +192,9 @@ group.add_option('--archive', | |||
192 | dest='archive', action='store_true', | 192 | dest='archive', action='store_true', |
193 | help='checkout an archive instead of a git repository for ' | 193 | help='checkout an archive instead of a git repository for ' |
194 | 'each project. See git archive.') | 194 | 'each project. See git archive.') |
195 | group.add_option('--submodules', | ||
196 | dest='submodules', action='store_true', | ||
197 | help='sync any submodules associated with the manifest repo') | ||
195 | group.add_option('-g', '--groups', | 198 | group.add_option('-g', '--groups', |
196 | dest='groups', default='default', | 199 | dest='groups', default='default', |
197 | help='restrict manifest projects to ones with specified ' | 200 | help='restrict manifest projects to ones with specified ' |
diff --git a/subcmds/abandon.py b/subcmds/abandon.py index 6f78da74..be32dc5c 100644 --- a/subcmds/abandon.py +++ b/subcmds/abandon.py | |||
@@ -81,7 +81,7 @@ It is equivalent to "git branch -D <branchname>". | |||
81 | err_msg = "error: cannot abandon %s" %br | 81 | err_msg = "error: cannot abandon %s" %br |
82 | print(err_msg, file=sys.stderr) | 82 | print(err_msg, file=sys.stderr) |
83 | for proj in err[br]: | 83 | for proj in err[br]: |
84 | print(' '*len(err_msg) + " | %s" % p.relpath, file=sys.stderr) | 84 | print(' '*len(err_msg) + " | %s" % proj.relpath, file=sys.stderr) |
85 | sys.exit(1) | 85 | sys.exit(1) |
86 | elif not success: | 86 | elif not success: |
87 | print('error: no project has local branch(es) : %s' % nb, | 87 | print('error: no project has local branch(es) : %s' % nb, |
diff --git a/subcmds/gitc_delete.py b/subcmds/gitc_delete.py index 7380c352..19caac5a 100644 --- a/subcmds/gitc_delete.py +++ b/subcmds/gitc_delete.py | |||
@@ -14,12 +14,10 @@ | |||
14 | # limitations under the License. | 14 | # limitations under the License. |
15 | 15 | ||
16 | from __future__ import print_function | 16 | from __future__ import print_function |
17 | import os | ||
18 | import shutil | 17 | import shutil |
19 | import sys | 18 | import sys |
20 | 19 | ||
21 | from command import Command, GitcClientCommand | 20 | from command import Command, GitcClientCommand |
22 | import gitc_utils | ||
23 | 21 | ||
24 | from pyversion import is_python3 | 22 | from pyversion import is_python3 |
25 | if not is_python3(): | 23 | if not is_python3(): |
diff --git a/subcmds/init.py b/subcmds/init.py index bb7187d7..b260ec0f 100644 --- a/subcmds/init.py +++ b/subcmds/init.py | |||
@@ -111,6 +111,9 @@ to update the working directory files. | |||
111 | dest='archive', action='store_true', | 111 | dest='archive', action='store_true', |
112 | help='checkout an archive instead of a git repository for ' | 112 | help='checkout an archive instead of a git repository for ' |
113 | 'each project. See git archive.') | 113 | 'each project. See git archive.') |
114 | g.add_option('--submodules', | ||
115 | dest='submodules', action='store_true', | ||
116 | help='sync any submodules associated with the manifest repo') | ||
114 | g.add_option('-g', '--groups', | 117 | g.add_option('-g', '--groups', |
115 | dest='groups', default='default', | 118 | dest='groups', default='default', |
116 | help='restrict manifest projects to ones with specified ' | 119 | help='restrict manifest projects to ones with specified ' |
@@ -236,10 +239,13 @@ to update the working directory files. | |||
236 | 'in another location.', file=sys.stderr) | 239 | 'in another location.', file=sys.stderr) |
237 | sys.exit(1) | 240 | sys.exit(1) |
238 | 241 | ||
242 | if opt.submodules: | ||
243 | m.config.SetString('repo.submodules', 'true') | ||
244 | |||
239 | if not m.Sync_NetworkHalf(is_new=is_new, quiet=opt.quiet, | 245 | if not m.Sync_NetworkHalf(is_new=is_new, quiet=opt.quiet, |
240 | clone_bundle=not opt.no_clone_bundle, | 246 | clone_bundle=not opt.no_clone_bundle, |
241 | current_branch_only=opt.current_branch_only, | 247 | current_branch_only=opt.current_branch_only, |
242 | no_tags=opt.no_tags): | 248 | no_tags=opt.no_tags, submodules=opt.submodules): |
243 | r = m.GetRemote(m.remote.name) | 249 | r = m.GetRemote(m.remote.name) |
244 | print('fatal: cannot obtain manifest %s' % r.url, file=sys.stderr) | 250 | print('fatal: cannot obtain manifest %s' % r.url, file=sys.stderr) |
245 | 251 | ||
@@ -253,7 +259,7 @@ to update the working directory files. | |||
253 | m.MetaBranchSwitch() | 259 | m.MetaBranchSwitch() |
254 | 260 | ||
255 | syncbuf = SyncBuffer(m.config) | 261 | syncbuf = SyncBuffer(m.config) |
256 | m.Sync_LocalHalf(syncbuf) | 262 | m.Sync_LocalHalf(syncbuf, submodules=opt.submodules) |
257 | syncbuf.Finish() | 263 | syncbuf.Finish() |
258 | 264 | ||
259 | if is_new or m.CurrentBranch is None: | 265 | if is_new or m.CurrentBranch is None: |
diff --git a/subcmds/sync.py b/subcmds/sync.py index 8e8529ee..82056f33 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
@@ -723,11 +723,12 @@ later is required to fix a server side protocol bug. | |||
723 | mp.Sync_NetworkHalf(quiet=opt.quiet, | 723 | mp.Sync_NetworkHalf(quiet=opt.quiet, |
724 | current_branch_only=opt.current_branch_only, | 724 | current_branch_only=opt.current_branch_only, |
725 | no_tags=opt.no_tags, | 725 | no_tags=opt.no_tags, |
726 | optimized_fetch=opt.optimized_fetch) | 726 | optimized_fetch=opt.optimized_fetch, |
727 | submodules=self.manifest.HasSubmodules) | ||
727 | 728 | ||
728 | if mp.HasChanges: | 729 | if mp.HasChanges: |
729 | syncbuf = SyncBuffer(mp.config) | 730 | syncbuf = SyncBuffer(mp.config) |
730 | mp.Sync_LocalHalf(syncbuf) | 731 | mp.Sync_LocalHalf(syncbuf, submodules=self.manifest.HasSubmodules) |
731 | if not syncbuf.Finish(): | 732 | if not syncbuf.Finish(): |
732 | sys.exit(1) | 733 | sys.exit(1) |
733 | self._ReloadManifest(manifest_name) | 734 | self._ReloadManifest(manifest_name) |