summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/fetch2/hg.py
diff options
context:
space:
mode:
authorDaniel McGregor <daniel.mcgregor@vecima.com>2015-05-11 21:25:18 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-05-12 12:14:14 +0100
commit9e24bde011479d9f22830080720510e52e9923d8 (patch)
tree68885162cb2d45f6a734c88746d882ef60dd2b51 /bitbake/lib/bb/fetch2/hg.py
parentd30aedcdf91d78c1553d8aa1f6769d3afa5cce8e (diff)
downloadpoky-9e24bde011479d9f22830080720510e52e9923d8.tar.gz
bitbake: fetch/hg: support submodules
Use hg clone and hg pull to copy the source into the build directory rather than taring up the cloned repository and untarring in the destination. This allows submodules to be cloned. While here, make the default behaviour keep the hg scm data to match the behaviour of the git fetcher. (Bitbake rev: f002b1ca80cb542a4ed0c06c53c914cd5e076565) Signed-off-by: Daniel McGregor <daniel.mcgregor@vecima.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/fetch2/hg.py')
-rw-r--r--bitbake/lib/bb/fetch2/hg.py55
1 files changed, 36 insertions, 19 deletions
diff --git a/bitbake/lib/bb/fetch2/hg.py b/bitbake/lib/bb/fetch2/hg.py
index 81592f6e04..6547cca73e 100644
--- a/bitbake/lib/bb/fetch2/hg.py
+++ b/bitbake/lib/bb/fetch2/hg.py
@@ -64,7 +64,9 @@ class Hg(FetchMethod):
64 elif not ud.revision: 64 elif not ud.revision:
65 ud.revision = self.latest_revision(ud, d) 65 ud.revision = self.latest_revision(ud, d)
66 66
67 ud.localfile = data.expand('%s_%s_%s_%s.tar.gz' % (ud.module.replace('/', '.'), ud.host, ud.path.replace('/', '.'), ud.revision), d) 67 ud.localfile = ud.moddir
68
69 ud.basecmd = data.getVar("FETCHCMD_hg", d, True) or "/usr/bin/env hg"
68 70
69 def need_update(self, ud, d): 71 def need_update(self, ud, d):
70 revTag = ud.parm.get('rev', 'tip') 72 revTag = ud.parm.get('rev', 'tip')
@@ -80,8 +82,6 @@ class Hg(FetchMethod):
80 command is "fetch", "update", "info" 82 command is "fetch", "update", "info"
81 """ 83 """
82 84
83 basecmd = data.expand('${FETCHCMD_hg}', d)
84
85 proto = ud.parm.get('protocol', 'http') 85 proto = ud.parm.get('protocol', 'http')
86 86
87 host = ud.host 87 host = ud.host
@@ -98,7 +98,7 @@ class Hg(FetchMethod):
98 hgroot = ud.user + "@" + host + ud.path 98 hgroot = ud.user + "@" + host + ud.path
99 99
100 if command == "info": 100 if command == "info":
101 return "%s identify -i %s://%s/%s" % (basecmd, proto, hgroot, ud.module) 101 return "%s identify -i %s://%s/%s" % (ud.basecmd, proto, hgroot, ud.module)
102 102
103 options = []; 103 options = [];
104 104
@@ -111,22 +111,22 @@ class Hg(FetchMethod):
111 111
112 if command == "fetch": 112 if command == "fetch":
113 if ud.user and ud.pswd: 113 if ud.user and ud.pswd:
114 cmd = "%s --config auth.default.prefix=* --config auth.default.username=%s --config auth.default.password=%s --config \"auth.default.schemes=%s\" clone %s %s://%s/%s %s" % (basecmd, ud.user, ud.pswd, proto, " ".join(options), proto, hgroot, ud.module, ud.module) 114 cmd = "%s --config auth.default.prefix=* --config auth.default.username=%s --config auth.default.password=%s --config \"auth.default.schemes=%s\" clone %s %s://%s/%s %s" % (ud.basecmd, ud.user, ud.pswd, proto, " ".join(options), proto, hgroot, ud.module, ud.module)
115 else: 115 else:
116 cmd = "%s clone %s %s://%s/%s %s" % (basecmd, " ".join(options), proto, hgroot, ud.module, ud.module) 116 cmd = "%s clone %s %s://%s/%s %s" % (ud.basecmd, " ".join(options), proto, hgroot, ud.module, ud.module)
117 elif command == "pull": 117 elif command == "pull":
118 # do not pass options list; limiting pull to rev causes the local 118 # do not pass options list; limiting pull to rev causes the local
119 # repo not to contain it and immediately following "update" command 119 # repo not to contain it and immediately following "update" command
120 # will crash 120 # will crash
121 if ud.user and ud.pswd: 121 if ud.user and ud.pswd:
122 cmd = "%s --config auth.default.prefix=* --config auth.default.username=%s --config auth.default.password=%s --config \"auth.default.schemes=%s\" pull" % (basecmd, ud.user, ud.pswd, proto) 122 cmd = "%s --config auth.default.prefix=* --config auth.default.username=%s --config auth.default.password=%s --config \"auth.default.schemes=%s\" pull" % (ud.basecmd, ud.user, ud.pswd, proto)
123 else: 123 else:
124 cmd = "%s pull" % (basecmd) 124 cmd = "%s pull" % (ud.basecmd)
125 elif command == "update": 125 elif command == "update":
126 if ud.user and ud.pswd: 126 if ud.user and ud.pswd:
127 cmd = "%s --config auth.default.prefix=* --config auth.default.username=%s --config auth.default.password=%s --config \"auth.default.schemes=%s\" update -C %s" % (basecmd, ud.user, ud.pswd, proto, " ".join(options)) 127 cmd = "%s --config auth.default.prefix=* --config auth.default.username=%s --config auth.default.password=%s --config \"auth.default.schemes=%s\" update -C %s" % (ud.basecmd, ud.user, ud.pswd, proto, " ".join(options))
128 else: 128 else:
129 cmd = "%s update -C %s" % (basecmd, " ".join(options)) 129 cmd = "%s update -C %s" % (ud.basecmd, " ".join(options))
130 else: 130 else:
131 raise FetchError("Invalid hg command %s" % command, ud.url) 131 raise FetchError("Invalid hg command %s" % command, ud.url)
132 132
@@ -163,15 +163,6 @@ class Hg(FetchMethod):
163 logger.debug(1, "Running %s", updatecmd) 163 logger.debug(1, "Running %s", updatecmd)
164 runfetchcmd(updatecmd, d) 164 runfetchcmd(updatecmd, d)
165 165
166 scmdata = ud.parm.get("scmdata", "")
167 if scmdata == "keep":
168 tar_flags = ""
169 else:
170 tar_flags = "--exclude '.hg' --exclude '.hgrags'"
171
172 os.chdir(ud.pkgdir)
173 runfetchcmd("tar %s -czf %s %s" % (tar_flags, ud.localpath, ud.module), d, cleanup = [ud.localpath])
174
175 def supports_srcrev(self): 166 def supports_srcrev(self):
176 return True 167 return True
177 168
@@ -191,3 +182,29 @@ class Hg(FetchMethod):
191 Return a unique key for the url 182 Return a unique key for the url
192 """ 183 """
193 return "hg:" + ud.moddir 184 return "hg:" + ud.moddir
185
186 def localpath(self, ud, d):
187 return ud.moddir
188
189 def unpack(self, ud, destdir, d):
190 """
191 Make a local clone or export for the url
192 """
193
194 revflag = "-r %s" % ud.revision
195 subdir = ud.parm.get("destsuffix", ud.module)
196 codir = "%s/%s" % (destdir, subdir)
197
198 scmdata = ud.parm.get("scmdata", "")
199 if scmdata != "nokeep":
200 if not os.access(os.path.join(codir, '.hg'), os.R_OK):
201 logger.debug(2, "Unpack: creating new hg repository in '" + codir + "'")
202 runfetchcmd("%s init %s" % (ud.basecmd, codir), d)
203 logger.debug(2, "Unpack: updating source in '" + codir + "'")
204 os.chdir(codir)
205 runfetchcmd("%s pull %s" % (ud.basecmd, ud.moddir), d)
206 runfetchcmd("%s up -C %s" % (ud.basecmd, revflag), d)
207 else:
208 logger.debug(2, "Unpack: extracting source to '" + codir + "'")
209 os.chdir(ud.moddir)
210 runfetchcmd("%s archive -t files %s %s" % (ud.basecmd, revflag, codir), d)