[40894] trunk

simon at macports.org simon at macports.org
Fri Oct 17 06:33:47 PDT 2008


Revision: 40894
          http://trac.macports.org/changeset/40894
Author:   simon at macports.org
Date:     2008-10-17 06:33:45 -0700 (Fri, 17 Oct 2008)
Log Message:
-----------
base: Add support to fetch using Mercurial.

Modified Paths:
--------------
    trunk/base/src/port1.0/portfetch.tcl
    trunk/doc-new/guide/xml/portfile-phase.xml

Modified: trunk/base/src/port1.0/portfetch.tcl
===================================================================
--- trunk/base/src/port1.0/portfetch.tcl	2008-10-17 11:53:38 UTC (rev 40893)
+++ trunk/base/src/port1.0/portfetch.tcl	2008-10-17 13:33:45 UTC (rev 40894)
@@ -46,7 +46,8 @@
 	master_sites.mirror_subdir patch_sites.mirror_subdir portname \
 	cvs.module cvs.root cvs.password cvs.date cvs.tag \
 	svn.url svn.tag \
-	git.url git.branch
+	git.url git.branch \
+	hg.url hg.tag
 	
 # XXX we use the command framework to buy us some useful features,
 # but this is not a user-modifiable command
@@ -79,6 +80,9 @@
 default git.dir {${workpath}}
 default git.branch {}
 
+default hg.dir {${workpath}}
+default hg.tag {tip}
+
 # Set distfiles
 default distfiles {[suffix $distname]}
 default dist_subdir {${portname}}
@@ -136,7 +140,8 @@
     switch -- "${fetch.type}" {
     	cvs			-
     	svn			-
-    	git			{ return "" }
+    	git			-
+    	hg			{ return "" }
     	standard	-
     	default 	{ return "${distname}${extract.suffix}" }
     }
@@ -538,6 +543,38 @@
     return 0
 }
 
+# Perform a mercurial fetch.
+proc hgfetch {args} {
+    global worksrcpath prefix_frozen
+    global hg.url hg.tag
+
+    # Look for the hg command.
+    set hg.cmd {}
+    foreach hgcmd "$prefix_frozen/bin/hg hg" {
+        if {[file executable $hgcmd]} {
+            set hg.cmd $hgcmd
+            break
+        }
+    }
+    if {${hg.cmd} == {}} {
+        ui_error "hg is required to fetch ${hg.url}"
+        ui_error "Please install the mercurial port before proceeding."
+        return -code error [msgcat::mc "Mercurial command not found"]
+    }
+
+    set cmdstring "${hg.cmd} clone --rev ${hg.tag} ${hg.url} ${worksrcpath} 2>&1"
+    ui_debug "Executing: $cmdstring"
+    if {[catch {system $cmdstring} result]} {
+        return -code error [msgcat::mc "Mercurial clone failed"]
+    }
+
+    if {[info exists patchfiles]} {
+        return [fetchfiles]
+    }
+
+    return 0
+}
+
 # Perform a standard fetch, assembling fetch urls from
 # the listed url variable and associated distfile
 proc fetchfiles {args} {
@@ -681,6 +718,7 @@
     	cvs		{ return [cvsfetch] }
     	svn		{ return [svnfetch] }
     	git		{ return [gitfetch] }
+    	hg		{ return [hgfetch] }
     	standard -
     	default	{ return [fetchfiles] }
     }

Modified: trunk/doc-new/guide/xml/portfile-phase.xml
===================================================================
--- trunk/doc-new/guide/xml/portfile-phase.xml	2008-10-17 11:53:38 UTC (rev 40893)
+++ trunk/doc-new/guide/xml/portfile-phase.xml	2008-10-17 13:33:45 UTC (rev 40894)
@@ -525,8 +525,9 @@
           <listitem>
             <para>Change the fetch type. This is only necessary if a <link
             linkend="reference.phases.fetch.cvs">CVS</link>, <link
-            linkend="reference.phases.fetch.svn">svn</link>, or <link
-            linkend="reference.phases.fetch.git">git</link> checkout is be
+            linkend="reference.phases.fetch.svn">svn</link>, <link
+            linkend="reference.phases.fetch.git">git</link> or <link
+            linkend="reference.phases.fetch.hg">hg</link> checkout is be
             used. <option>standard</option> is used for a normal http or ftp
             fetch using <varname>${distfiles}</varname> and is used as
             default.</para>
@@ -870,6 +871,67 @@
         </varlistentry>
       </variablelist>
     </section>
+
+    <section id="reference.phases.fetch.hg">
+      <title>Fetch from Mercurial</title>
+
+      <para><ulink url="http://selenic.com/mercurial">Mercurial</ulink> may be
+      used as an alternative method of fetching distribution files using the
+      keywords in this section. However, fetching via Mercurial may cause
+      non-reproducible builds, so it is strongly discouraged.</para>
+
+      <para>You have to set <link
+      linkend="reference.phases.fetch.advanced.fetch-type"><varname>fetch.type</varname></link>
+      to <option>hg</option> to fetch from Mercurial.</para>
+
+      <variablelist>
+        <varlistentry>
+          <term>hg.url</term>
+
+          <listitem>
+            <para>This specifies the url from which to fetch files.</para>
+
+            <itemizedlist>
+              <listitem>
+                <para>Default: none</para>
+              </listitem>
+
+              <listitem>
+                <para>Examples:</para>
+
+                <programlisting>hg.url              http://www.kernel.org/hg/index.cgi/linux-2.6/</programlisting>
+
+                <programlisting>hg.url              http://hg.intevation.org/mercurial</programlisting>
+              </listitem>
+            </itemizedlist>
+          </listitem>
+        </varlistentry>
+
+        <varlistentry>
+          <term>hg.tag</term>
+
+          <listitem>
+            <para>Optional tag which should be fetched. Can be a Mercurial tag
+            or a revision. To prevent non-reproducible builds use of tip as
+            revision is discouraged.</para>
+
+            <itemizedlist>
+              <listitem>
+                <para>Default: tip</para>
+              </listitem>
+
+              <listitem>
+                <para>Example:</para>
+
+                <programlisting>hg.tag                 v1.3</programlisting>
+
+                <programlisting>hg.tag                 ceb884843737</programlisting>
+              </listitem>
+            </itemizedlist>
+          </listitem>
+        </varlistentry>
+      </variablelist>
+    </section>
   </section>
 
   <section id="reference.phases.checksum">
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20081017/4361dae0/attachment.html 


More information about the macports-changes mailing list