public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Brian Dolbec" <brian.dolbec@gmail.com>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/layman:master commit in: layman/overlays/
Date: Mon, 16 Jun 2014 03:40:18 +0000 (UTC)	[thread overview]
Message-ID: <1402607509.2c8417794872d797ef816760d5d9161c90f449fc.dol-sen@gentoo> (raw)

commit:     2c8417794872d797ef816760d5d9161c90f449fc
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Fri May 30 01:19:52 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Jun 12 21:11:49 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=2c841779

mercurial.py: Adds update() function

Also adds _fix_mercurial_source() function to be used by add() and update().

---
 layman/overlays/mercurial.py | 40 ++++++++++++++++++++++++++++++++++++----
 1 file changed, 36 insertions(+), 4 deletions(-)

diff --git a/layman/overlays/mercurial.py b/layman/overlays/mercurial.py
index c188381..74f1934 100644
--- a/layman/overlays/mercurial.py
+++ b/layman/overlays/mercurial.py
@@ -27,6 +27,7 @@ __version__ = "$Id: mercurial.py 236 2006-09-05 20:39:37Z wrobel $"
 #
 #-------------------------------------------------------------------------------
 
+import re
 from   layman.utils             import path
 from   layman.overlays.source   import OverlaySource, require_supported
 
@@ -49,6 +50,16 @@ class MercurialOverlay(OverlaySource):
             config, _location, ignore)
         self.subpath = None
 
+    def _fix_mercurial_source(self, source):
+    '''
+    Adds trailing slash to source URL if needed.
+
+    @params source: source URL, string.
+    '''
+        if source.endswith("/"):
+            return source
+        return source + '/'
+
     def add(self, base):
         '''Add overlay.'''
 
@@ -58,10 +69,7 @@ class MercurialOverlay(OverlaySource):
         cfg_opts = self.config["mercurial_addopts"]
         target = path([base, self.parent.name])
 
-        if self.src.endswith("/"):
-            src = self.src
-        else:
-            src = self.src + '/'
+        src = self._fix_mercurial_source(self.src)
 
         # hg clone SOURCE TARGET
         if len(cfg_opts):
@@ -73,6 +81,30 @@ class MercurialOverlay(OverlaySource):
             self.run_command(self.command(), args, cmd=self.type),
             cwd=target)
 
+    def update(self, base, src):
+        '''
+        Updates overlay src-url.
+        
+        @params base: base location where all overlays are installed.
+        @params src: source URL.
+        '''
+
+        if not self.supported():
+            return 1
+
+        target = path([base, self.parent.name])
+        hgrc = ".hg/hgrc"
+
+        old_src = re.sub('/', '\/', self._fix_mercurial_source(self.src))
+        new_src = re.sub('/', '\/', self._fix_mercurial_source(src))
+        expression = "s/" + old_src + "/" + new_src + "/"
+
+        # sed -i 's/oldurl/newurl/' <target>/.hg/hgrc
+        args = ['-i', expression, hgrc]
+
+        # Run sed.
+        return self.run_command('sed', args, cmd='sed', cwd=target)
+
     def sync(self, base):
         '''Sync overlay.'''
 


WARNING: multiple messages have this Message-ID (diff)
From: "Brian Dolbec" <brian.dolbec@gmail.com>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/
Date: Mon, 16 Jun 2014 03:37:28 +0000 (UTC)	[thread overview]
Message-ID: <1402607509.2c8417794872d797ef816760d5d9161c90f449fc.dol-sen@gentoo> (raw)
Message-ID: <20140616033728.gakIoFvB1pJ-iDfOS9Mti1JpgnVAPdEbjctnQiQIU-o@z> (raw)

commit:     2c8417794872d797ef816760d5d9161c90f449fc
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Fri May 30 01:19:52 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Jun 12 21:11:49 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=2c841779

mercurial.py: Adds update() function

Also adds _fix_mercurial_source() function to be used by add() and update().

---
 layman/overlays/mercurial.py | 40 ++++++++++++++++++++++++++++++++++++----
 1 file changed, 36 insertions(+), 4 deletions(-)

diff --git a/layman/overlays/mercurial.py b/layman/overlays/mercurial.py
index c188381..74f1934 100644
--- a/layman/overlays/mercurial.py
+++ b/layman/overlays/mercurial.py
@@ -27,6 +27,7 @@ __version__ = "$Id: mercurial.py 236 2006-09-05 20:39:37Z wrobel $"
 #
 #-------------------------------------------------------------------------------
 
+import re
 from   layman.utils             import path
 from   layman.overlays.source   import OverlaySource, require_supported
 
@@ -49,6 +50,16 @@ class MercurialOverlay(OverlaySource):
             config, _location, ignore)
         self.subpath = None
 
+    def _fix_mercurial_source(self, source):
+    '''
+    Adds trailing slash to source URL if needed.
+
+    @params source: source URL, string.
+    '''
+        if source.endswith("/"):
+            return source
+        return source + '/'
+
     def add(self, base):
         '''Add overlay.'''
 
@@ -58,10 +69,7 @@ class MercurialOverlay(OverlaySource):
         cfg_opts = self.config["mercurial_addopts"]
         target = path([base, self.parent.name])
 
-        if self.src.endswith("/"):
-            src = self.src
-        else:
-            src = self.src + '/'
+        src = self._fix_mercurial_source(self.src)
 
         # hg clone SOURCE TARGET
         if len(cfg_opts):
@@ -73,6 +81,30 @@ class MercurialOverlay(OverlaySource):
             self.run_command(self.command(), args, cmd=self.type),
             cwd=target)
 
+    def update(self, base, src):
+        '''
+        Updates overlay src-url.
+        
+        @params base: base location where all overlays are installed.
+        @params src: source URL.
+        '''
+
+        if not self.supported():
+            return 1
+
+        target = path([base, self.parent.name])
+        hgrc = ".hg/hgrc"
+
+        old_src = re.sub('/', '\/', self._fix_mercurial_source(self.src))
+        new_src = re.sub('/', '\/', self._fix_mercurial_source(src))
+        expression = "s/" + old_src + "/" + new_src + "/"
+
+        # sed -i 's/oldurl/newurl/' <target>/.hg/hgrc
+        args = ['-i', expression, hgrc]
+
+        # Run sed.
+        return self.run_command('sed', args, cmd='sed', cwd=target)
+
     def sync(self, base):
         '''Sync overlay.'''
 


             reply	other threads:[~2014-06-16  3:40 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-16  3:40 Brian Dolbec [this message]
2014-06-16  3:37 ` [gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/ Brian Dolbec
  -- strict thread matches above, loose matches on Subject: below --
2015-08-28  3:50 [gentoo-commits] proj/layman:master " Devan Franchini
2015-08-28  3:43 Devan Franchini
2015-08-28  0:41 Devan Franchini
2015-08-04  0:23 Devan Franchini
2015-07-21 16:39 Devan Franchini
2015-07-14 15:15 Devan Franchini
2015-07-13 23:05 Devan Franchini
2015-07-13 19:04 Devan Franchini
2015-07-13 18:59 Devan Franchini
2015-07-13 18:52 Devan Franchini
2015-07-13 18:48 Devan Franchini
2015-07-10 16:13 Devan Franchini
2015-03-26 23:47 Devan Franchini
2015-03-26 23:08 Devan Franchini
2015-03-26 18:13 Devan Franchini
2014-12-08  4:15 Devan Franchini
2014-06-16  3:40 Brian Dolbec
2014-06-16  3:37 [gentoo-commits] proj/layman:gsoc2014 " Brian Dolbec
2014-06-16  3:40 ` [gentoo-commits] proj/layman:master " Brian Dolbec
2014-06-16  3:37 [gentoo-commits] proj/layman:gsoc2014 " Brian Dolbec
2014-06-16  3:40 ` [gentoo-commits] proj/layman:master " Brian Dolbec
2014-06-16  3:37 [gentoo-commits] proj/layman:gsoc2014 " Brian Dolbec
2014-06-16  3:40 ` [gentoo-commits] proj/layman:master " Brian Dolbec
2014-06-16  3:37 [gentoo-commits] proj/layman:gsoc2014 " Brian Dolbec
2014-06-16  3:40 ` [gentoo-commits] proj/layman:master " Brian Dolbec
2014-06-16  3:37 [gentoo-commits] proj/layman:gsoc2014 " Brian Dolbec
2014-06-16  3:40 ` [gentoo-commits] proj/layman:master " Brian Dolbec
2014-06-16  3:37 [gentoo-commits] proj/layman:gsoc2014 " Brian Dolbec
2014-06-16  3:40 ` [gentoo-commits] proj/layman:master " Brian Dolbec
2014-06-16  3:37 [gentoo-commits] proj/layman:gsoc2014 " Brian Dolbec
2014-06-16  3:40 ` [gentoo-commits] proj/layman:master " Brian Dolbec
2014-03-10  3:18 Brian Dolbec
2013-08-18 16:46 Brian Dolbec
2012-11-01  7:06 Brian Dolbec
2012-10-08  6:16 Brian Dolbec
2012-10-08  4:36 Brian Dolbec
2012-10-07 23:40 Brian Dolbec
2012-01-06  8:16 Brian Dolbec
2011-09-26  1:18 Brian Dolbec
2011-09-24  6:07 Brian Dolbec
2011-09-13 14:16 Brian Dolbec
2011-09-05 16:09 Brian Dolbec
2011-08-07  8:47 Brian Dolbec
2011-08-07  8:39 Brian Dolbec
2011-07-28 21:33 Brian Dolbec
2011-07-23  6:45 Brian Dolbec
2011-05-05  9:44 Brian Dolbec
2011-04-30 22:37 Brian Dolbec
2011-04-30  6:37 Brian Dolbec
2011-04-27 10:58 Brian Dolbec
2011-04-27 10:58 Brian Dolbec
2011-04-27 10:58 Brian Dolbec
2011-04-27 10:58 Brian Dolbec
2011-04-27 10:58 Brian Dolbec
2011-02-17 21:53 Brian Dolbec
2011-02-14  6:00 Brian Dolbec
2011-02-14  6:00 Brian Dolbec

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1402607509.2c8417794872d797ef816760d5d9161c90f449fc.dol-sen@gentoo \
    --to=brian.dolbec@gmail.com \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox