<p dir="ltr">Thanks for the heads up, I&#39;ll poke at it this evening.</p>
<div class="gmail_quote">On 18 May 2015 1:26 am, &quot;Robert Yang&quot; &lt;<a href="mailto:liezhi.yang@windriver.com">liezhi.yang@windriver.com</a>&gt; wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Hello,<br>
<br>
This patches breaks the BB_GENERATE_MIRROR_TARBALLS, it doesn&#39;t generate<br>
or untar the local tarball any more, the local tarball&#39;s mirror doesn&#39;t<br>
work any more.<br>
<br>
// Robert<br>
<br>
On 05/12/2015 11:25 AM, Dan McGregor wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
From: Daniel McGregor &lt;<a href="mailto:daniel.mcgregor@vecima.com" target="_blank">daniel.mcgregor@vecima.com</a>&gt;<br>
<br>
Use hg clone and hg pull to copy the source into the build<br>
directory rather than taring up the cloned repository and<br>
untarring in the destination.<br>
<br>
This allows submodules to be cloned. While here, make the default<br>
behaviour keep the hg scm data to match the behaviour of the git<br>
fetcher.<br>
<br>
Signed-off-by: Daniel McGregor &lt;<a href="mailto:daniel.mcgregor@vecima.com" target="_blank">daniel.mcgregor@vecima.com</a>&gt;<br>
---<br>
  lib/bb/fetch2/hg.py | 55 +++++++++++++++++++++++++++++++++++------------------<br>
  1 file changed, 36 insertions(+), 19 deletions(-)<br>
<br>
diff --git a/lib/bb/fetch2/hg.py b/lib/bb/fetch2/hg.py<br>
index 81592f6..6547cca 100644<br>
--- a/lib/bb/fetch2/hg.py<br>
+++ b/lib/bb/fetch2/hg.py<br>
@@ -64,7 +64,9 @@ class Hg(FetchMethod):<br>
          elif not ud.revision:<br>
              ud.revision = self.latest_revision(ud, d)<br>
<br>
-        ud.localfile = data.expand(&#39;%s_%s_%s_%s.tar.gz&#39; % (ud.module.replace(&#39;/&#39;, &#39;.&#39;), ud.host, ud.path.replace(&#39;/&#39;, &#39;.&#39;), ud.revision), d)<br>
+        ud.localfile = ud.moddir<br>
+<br>
+        ud.basecmd = data.getVar(&quot;FETCHCMD_hg&quot;, d, True) or &quot;/usr/bin/env hg&quot;<br>
<br>
      def need_update(self, ud, d):<br>
          revTag = ud.parm.get(&#39;rev&#39;, &#39;tip&#39;)<br>
@@ -80,8 +82,6 @@ class Hg(FetchMethod):<br>
          command is &quot;fetch&quot;, &quot;update&quot;, &quot;info&quot;<br>
          &quot;&quot;&quot;<br>
<br>
-        basecmd = data.expand(&#39;${FETCHCMD_hg}&#39;, d)<br>
-<br>
          proto = ud.parm.get(&#39;protocol&#39;, &#39;http&#39;)<br>
<br>
          host = ud.host<br>
@@ -98,7 +98,7 @@ class Hg(FetchMethod):<br>
                  hgroot = ud.user + &quot;@&quot; + host + ud.path<br>
<br>
          if command == &quot;info&quot;:<br>
-            return &quot;%s identify -i %s://%s/%s&quot; % (basecmd, proto, hgroot, ud.module)<br>
+            return &quot;%s identify -i %s://%s/%s&quot; % (ud.basecmd, proto, hgroot, ud.module)<br>
<br>
          options = [];<br>
<br>
@@ -111,22 +111,22 @@ class Hg(FetchMethod):<br>
<br>
          if command == &quot;fetch&quot;:<br>
              if ud.user and ud.pswd:<br>
-                cmd = &quot;%s --config auth.default.prefix=* --config auth.default.username=%s --config auth.default.password=%s --config \&quot;auth.default.schemes=%s\&quot; clone %s %s://%s/%s %s&quot; % (basecmd, ud.user, ud.pswd, proto, &quot; &quot;.join(options), proto, hgroot, ud.module, ud.module)<br>
+                cmd = &quot;%s --config auth.default.prefix=* --config auth.default.username=%s --config auth.default.password=%s --config \&quot;auth.default.schemes=%s\&quot; clone %s %s://%s/%s %s&quot; % (ud.basecmd, ud.user, ud.pswd, proto, &quot; &quot;.join(options), proto, hgroot, ud.module, ud.module)<br>
              else:<br>
-                cmd = &quot;%s clone %s %s://%s/%s %s&quot; % (basecmd, &quot; &quot;.join(options), proto, hgroot, ud.module, ud.module)  <br>
+                cmd = &quot;%s clone %s %s://%s/%s %s&quot; % (ud.basecmd, &quot; &quot;.join(options), proto, hgroot, ud.module, ud.module)<br>
          elif command == &quot;pull&quot;:<br>
              # do not pass options list; limiting pull to rev causes the local<br>
              # repo not to contain it and immediately following &quot;update&quot; command<br>
              # will crash<br>
              if ud.user and ud.pswd:<br>
-                cmd = &quot;%s --config auth.default.prefix=* --config auth.default.username=%s --config auth.default.password=%s --config \&quot;auth.default.schemes=%s\&quot; pull&quot; % (basecmd, ud.user, ud.pswd, proto)<br>
+                cmd = &quot;%s --config auth.default.prefix=* --config auth.default.username=%s --config auth.default.password=%s --config \&quot;auth.default.schemes=%s\&quot; pull&quot; % (ud.basecmd, ud.user, ud.pswd, proto)<br>
              else:<br>
-                cmd = &quot;%s pull&quot; % (basecmd)<br>
+                cmd = &quot;%s pull&quot; % (ud.basecmd)<br>
          elif command == &quot;update&quot;:<br>
              if ud.user and ud.pswd:<br>
-                cmd = &quot;%s --config auth.default.prefix=* --config auth.default.username=%s --config auth.default.password=%s --config \&quot;auth.default.schemes=%s\&quot; update -C %s&quot; % (basecmd, ud.user, ud.pswd, proto, &quot; &quot;.join(options))<br>
+                cmd = &quot;%s --config auth.default.prefix=* --config auth.default.username=%s --config auth.default.password=%s --config \&quot;auth.default.schemes=%s\&quot; update -C %s&quot; % (ud.basecmd, ud.user, ud.pswd, proto, &quot; &quot;.join(options))<br>
              else:<br>
-                cmd = &quot;%s update -C %s&quot; % (basecmd, &quot; &quot;.join(options))<br>
+                cmd = &quot;%s update -C %s&quot; % (ud.basecmd, &quot; &quot;.join(options))<br>
          else:<br>
              raise FetchError(&quot;Invalid hg command %s&quot; % command, ud.url)<br>
<br>
@@ -163,15 +163,6 @@ class Hg(FetchMethod):<br>
          logger.debug(1, &quot;Running %s&quot;, updatecmd)<br>
          runfetchcmd(updatecmd, d)<br>
<br>
-        scmdata = ud.parm.get(&quot;scmdata&quot;, &quot;&quot;)<br>
-        if scmdata == &quot;keep&quot;:<br>
-            tar_flags = &quot;&quot;<br>
-        else:<br>
-            tar_flags = &quot;--exclude &#39;.hg&#39; --exclude &#39;.hgrags&#39;&quot;<br>
-<br>
-        os.chdir(ud.pkgdir)<br>
-        runfetchcmd(&quot;tar %s -czf %s %s&quot; % (tar_flags, ud.localpath, ud.module), d, cleanup = [ud.localpath])<br>
-<br>
      def supports_srcrev(self):<br>
          return True<br>
<br>
@@ -191,3 +182,29 @@ class Hg(FetchMethod):<br>
          Return a unique key for the url<br>
          &quot;&quot;&quot;<br>
          return &quot;hg:&quot; + ud.moddir<br>
+<br>
+    def localpath(self, ud, d):<br>
+        return ud.moddir<br>
+<br>
+    def unpack(self, ud, destdir, d):<br>
+        &quot;&quot;&quot;<br>
+        Make a local clone or export for the url<br>
+        &quot;&quot;&quot;<br>
+<br>
+        revflag = &quot;-r %s&quot; % ud.revision<br>
+        subdir = ud.parm.get(&quot;destsuffix&quot;, ud.module)<br>
+        codir = &quot;%s/%s&quot; % (destdir, subdir)<br>
+<br>
+        scmdata = ud.parm.get(&quot;scmdata&quot;, &quot;&quot;)<br>
+        if scmdata != &quot;nokeep&quot;:<br>
+            if not os.access(os.path.join(codir, &#39;.hg&#39;), os.R_OK):<br>
+                logger.debug(2, &quot;Unpack: creating new hg repository in &#39;&quot; + codir + &quot;&#39;&quot;)<br>
+                runfetchcmd(&quot;%s init %s&quot; % (ud.basecmd, codir), d)<br>
+            logger.debug(2, &quot;Unpack: updating source in &#39;&quot; + codir + &quot;&#39;&quot;)<br>
+            os.chdir(codir)<br>
+            runfetchcmd(&quot;%s pull %s&quot; % (ud.basecmd, ud.moddir), d)<br>
+            runfetchcmd(&quot;%s up -C %s&quot; % (ud.basecmd, revflag), d)<br>
+        else:<br>
+            logger.debug(2, &quot;Unpack: extracting source to &#39;&quot; + codir + &quot;&#39;&quot;)<br>
+            os.chdir(ud.moddir)<br>
+            runfetchcmd(&quot;%s archive -t files %s %s&quot; % (ud.basecmd, revflag, codir), d)<br>
<br>
</blockquote>
</blockquote></div>