summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@sonymobile.com>2012-11-27 22:25:30 +0900
committerDavid Pursehouse <david.pursehouse@sonymobile.com>2013-04-10 09:17:50 +0900
commitede7f12d4a0f7362aaccd2c825a83765b9b9d968 (patch)
treee2b1683926292028a8e32ce32419228517d60d56
parent04d84a23fd04c9e1dd15341eb7dd28a0d8ce99c6 (diff)
downloadgit-repo-ede7f12d4a0f7362aaccd2c825a83765b9b9d968.tar.gz
Allow clone depth to be specified per project
If the clone-depth attribute is set on a project, its value will be used to set the depth when fetching the git. The value, if given, must be a positive integer. The value in the clone-depth attribute overrides any value given to repo init via the --depth command line option. Change-Id: I273015b3724213600b63e40cca4cafaa9f782ddf
-rw-r--r--docs/manifest-format.txt5
-rw-r--r--manifest_xml.py11
-rw-r--r--project.py9
3 files changed, 23 insertions, 2 deletions
diff --git a/docs/manifest-format.txt b/docs/manifest-format.txt
index 0bf09f6f..f4629a55 100644
--- a/docs/manifest-format.txt
+++ b/docs/manifest-format.txt
@@ -56,6 +56,7 @@ following DTD:
56 <!ATTLIST project sync-c CDATA #IMPLIED> 56 <!ATTLIST project sync-c CDATA #IMPLIED>
57 <!ATTLIST project sync-s CDATA #IMPLIED> 57 <!ATTLIST project sync-s CDATA #IMPLIED>
58 <!ATTLIST project upstream CDATA #IMPLIED> 58 <!ATTLIST project upstream CDATA #IMPLIED>
59 <!ATTLIST project clone-depth CDATA #IMPLIED>
59 60
60 <!ELEMENT annotation (EMPTY)> 61 <!ELEMENT annotation (EMPTY)>
61 <!ATTLIST annotation name CDATA #REQUIRED> 62 <!ATTLIST annotation name CDATA #REQUIRED>
@@ -222,6 +223,10 @@ Attribute `upstream`: Name of the Git branch in which a sha1
222can be found. Used when syncing a revision locked manifest in 223can be found. Used when syncing a revision locked manifest in
223-c mode to avoid having to sync the entire ref space. 224-c mode to avoid having to sync the entire ref space.
224 225
226Attribute `clone-depth`: Set the depth to use when fetching this
227project. If specified, this value will override any value given
228to repo init with the --depth option on the command line.
229
225Element annotation 230Element annotation
226------------------ 231------------------
227 232
diff --git a/manifest_xml.py b/manifest_xml.py
index 92ef7859..4eef748f 100644
--- a/manifest_xml.py
+++ b/manifest_xml.py
@@ -665,6 +665,16 @@ class XmlManifest(object):
665 else: 665 else:
666 sync_s = sync_s.lower() in ("yes", "true", "1") 666 sync_s = sync_s.lower() in ("yes", "true", "1")
667 667
668 clone_depth = node.getAttribute('clone-depth')
669 if clone_depth:
670 try:
671 clone_depth = int(clone_depth)
672 if clone_depth <= 0:
673 raise ValueError()
674 except ValueError:
675 raise ManifestParseError('invalid clone-depth %s in %s' %
676 (clone_depth, self.manifestFile))
677
668 upstream = node.getAttribute('upstream') 678 upstream = node.getAttribute('upstream')
669 679
670 groups = '' 680 groups = ''
@@ -692,6 +702,7 @@ class XmlManifest(object):
692 groups = groups, 702 groups = groups,
693 sync_c = sync_c, 703 sync_c = sync_c,
694 sync_s = sync_s, 704 sync_s = sync_s,
705 clone_depth = clone_depth,
695 upstream = upstream, 706 upstream = upstream,
696 parent = parent) 707 parent = parent)
697 708
diff --git a/project.py b/project.py
index 901a2831..20bf866c 100644
--- a/project.py
+++ b/project.py
@@ -488,6 +488,7 @@ class Project(object):
488 groups = None, 488 groups = None,
489 sync_c = False, 489 sync_c = False,
490 sync_s = False, 490 sync_s = False,
491 clone_depth = None,
491 upstream = None, 492 upstream = None,
492 parent = None, 493 parent = None,
493 is_derived = False): 494 is_derived = False):
@@ -533,6 +534,7 @@ class Project(object):
533 self.groups = groups 534 self.groups = groups
534 self.sync_c = sync_c 535 self.sync_c = sync_c
535 self.sync_s = sync_s 536 self.sync_s = sync_s
537 self.clone_depth = clone_depth
536 self.upstream = upstream 538 self.upstream = upstream
537 self.parent = parent 539 self.parent = parent
538 self.is_derived = is_derived 540 self.is_derived = is_derived
@@ -1645,7 +1647,10 @@ class Project(object):
1645 1647
1646 # The --depth option only affects the initial fetch; after that we'll do 1648 # The --depth option only affects the initial fetch; after that we'll do
1647 # full fetches of changes. 1649 # full fetches of changes.
1648 depth = self.manifest.manifestProject.config.GetString('repo.depth') 1650 if self.clone_depth:
1651 depth = self.clone_depth
1652 else:
1653 depth = self.manifest.manifestProject.config.GetString('repo.depth')
1649 if depth and initial: 1654 if depth and initial:
1650 cmd.append('--depth=%s' % depth) 1655 cmd.append('--depth=%s' % depth)
1651 1656
@@ -1705,7 +1710,7 @@ class Project(object):
1705 return ok 1710 return ok
1706 1711
1707 def _ApplyCloneBundle(self, initial=False, quiet=False): 1712 def _ApplyCloneBundle(self, initial=False, quiet=False):
1708 if initial and self.manifest.manifestProject.config.GetString('repo.depth'): 1713 if initial and (self.manifest.manifestProject.config.GetString('repo.depth') or self.clone_depth):
1709 return False 1714 return False
1710 1715
1711 remote = self.GetRemote(self.remote.name) 1716 remote = self.GetRemote(self.remote.name)