* [gentoo-commits] proj/portage:master commit in: pym/portage/tests/update/, pym/portage/
@ 2012-09-19 19:48 Zac Medico
0 siblings, 0 replies; 2+ messages in thread
From: Zac Medico @ 2012-09-19 19:48 UTC (permalink / raw
To: gentoo-commits
commit: 60d7d3cf4364a1cc41cf98b57359a0faf1fdc5bd
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Sep 19 19:48:24 2012 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Sep 19 19:48:24 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=60d7d3cf
update_dbentry: improve slotmove support
This could be especially useful for "built" slot operator deps, in
order to avoid having a slotmove trigger unnecessary rebuilds.
---
pym/portage/tests/update/test_update_dbentry.py | 26 +++++++++++++
pym/portage/update.py | 46 +++++++++++++++++++---
2 files changed, 65 insertions(+), 7 deletions(-)
diff --git a/pym/portage/tests/update/test_update_dbentry.py b/pym/portage/tests/update/test_update_dbentry.py
index e13cfed..ac16a8a 100644
--- a/pym/portage/tests/update/test_update_dbentry.py
+++ b/pym/portage/tests/update/test_update_dbentry.py
@@ -6,14 +6,40 @@ import textwrap
import portage
from portage import os
+from portage.dep import Atom
from portage.tests import TestCase
from portage.tests.resolver.ResolverPlayground import ResolverPlayground
+from portage.update import update_dbentry
from portage.util import ensure_dirs
from portage._global_updates import _do_global_updates
class UpdateDbentryTestCase(TestCase):
def testUpdateDbentryTestCase(self):
+ cases = (
+ (("slotmove", Atom("dev-libs/A"), "0", "1"), "1",
+ " dev-libs/A:0 ", " dev-libs/A:1 "),
+
+ (("slotmove", Atom("dev-libs/A"), "0", "1"), "1",
+ " >=dev-libs/A-1:0 ", " >=dev-libs/A-1:1 "),
+
+ (("slotmove", Atom("dev-libs/A"), "0", "1"), "5_pre2",
+ " dev-libs/A:0/1=[foo] ", " dev-libs/A:1/1=[foo] "),
+
+ (("slotmove", Atom("dev-libs/A"), "0", "1"), "5_pre2",
+ " dev-libs/A:0/1[foo] ", " dev-libs/A:1/1[foo] "),
+
+ (("slotmove", Atom("dev-libs/A"), "0", "1"), "5_pre2",
+ " dev-libs/A:0/0[foo] ", " dev-libs/A:1/1[foo] "),
+
+ (("slotmove", Atom("dev-libs/A"), "0", "1"), "5_pre2",
+ " dev-libs/A:0=[foo] ", " dev-libs/A:1=[foo] "),
+ )
+ for update_cmd, eapi, input_str, output_str in cases:
+ result = update_dbentry(update_cmd, input_str, eapi=eapi)
+ self.assertEqual(result, output_str)
+
+ def testUpdateDbentryDbapiTestCase(self):
ebuilds = {
diff --git a/pym/portage/update.py b/pym/portage/update.py
index 121e957..017f71f 100644
--- a/pym/portage/update.py
+++ b/pym/portage/update.py
@@ -22,7 +22,7 @@ portage.proxy.lazyimport.lazyimport(globals(),
)
from portage.const import USER_CONFIG_PATH
-from portage.dep import _get_slot_re
+from portage.dep import Atom, _get_slot_re
from portage.eapi import _get_eapi_attrs
from portage.exception import DirectoryNotFound, InvalidAtom, PortageException
from portage.localization import _
@@ -57,12 +57,44 @@ def update_dbentry(update_cmd, mycontent, eapi=None):
return "".join(matchobj.groups())
mycontent = re.sub("(%s-)(\\S*)" % old_value, myreplace, mycontent)
elif update_cmd[0] == "slotmove" and update_cmd[1].operator is None:
- pkg, origslot, newslot = update_cmd[1:]
- old_value = "%s:%s" % (pkg, origslot)
- if old_value in mycontent:
- old_value = re.escape(old_value)
- new_value = "%s:%s" % (pkg, newslot)
- mycontent = re.sub(old_value+"($|\\s)", new_value+"\\1", mycontent)
+ orig_atom, origslot, newslot = update_cmd[1:]
+ orig_cp = orig_atom.cp
+
+ # We don't support versioned slotmove atoms here, since it can be
+ # difficult to determine if the version constraints really match
+ # the atoms that we're trying to update.
+ if orig_atom.version is None and orig_cp in mycontent:
+ # this split preserves existing whitespace
+ split_content = re.split(r'(\s+)', mycontent)
+ modified = False
+ for i, token in enumerate(split_content):
+ if orig_cp not in token:
+ continue
+ try:
+ atom = Atom(token, eapi=eapi)
+ except InvalidAtom:
+ continue
+ if atom.cp != orig_cp:
+ continue
+ if atom.slot is None or atom.slot != origslot:
+ continue
+
+ slot_part = newslot
+ if atom.sub_slot is not None:
+ if atom.sub_slot == origslot:
+ sub_slot = newslot
+ else:
+ sub_slot = atom.sub_slot
+ slot_part += "/" + sub_slot
+ if atom.slot_operator is not None:
+ slot_part += atom.slot_operator
+
+ split_content[i] = atom.with_slot(slot_part)
+ modified = True
+
+ if modified:
+ mycontent = "".join(split_content)
+
return mycontent
def update_dbentries(update_iter, mydata, eapi=None):
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/tests/update/, pym/portage/
@ 2012-09-20 4:08 Zac Medico
0 siblings, 0 replies; 2+ messages in thread
From: Zac Medico @ 2012-09-20 4:08 UTC (permalink / raw
To: gentoo-commits
commit: cc13d56d9f13e518eefd6ba67364d73ac464f184
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Sep 20 04:08:47 2012 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Sep 20 04:08:47 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=cc13d56d
update_dbentry: fix "move" to translate atom[use]
---
pym/portage/tests/update/test_update_dbentry.py | 3 ++
pym/portage/update.py | 31 ++++++++++++++---------
2 files changed, 22 insertions(+), 12 deletions(-)
diff --git a/pym/portage/tests/update/test_update_dbentry.py b/pym/portage/tests/update/test_update_dbentry.py
index 4063318..cb69053 100644
--- a/pym/portage/tests/update/test_update_dbentry.py
+++ b/pym/portage/tests/update/test_update_dbentry.py
@@ -24,6 +24,9 @@ class UpdateDbentryTestCase(TestCase):
(("move", Atom("dev-libs/A"), Atom("dev-libs/B")), "1",
" >=dev-libs/A-1:0 ", " >=dev-libs/B-1:0 "),
+ (("move", Atom("dev-libs/A"), Atom("dev-libs/B")), "2",
+ " dev-libs/A[foo] ", " dev-libs/B[foo] "),
+
(("move", Atom("dev-libs/A"), Atom("dev-libs/B")), "5_pre2",
" dev-libs/A:0/1=[foo] ", " dev-libs/B:0/1=[foo] "),
diff --git a/pym/portage/update.py b/pym/portage/update.py
index 017f71f..fe00b7e 100644
--- a/pym/portage/update.py
+++ b/pym/portage/update.py
@@ -44,18 +44,25 @@ def update_dbentry(update_cmd, mycontent, eapi=None):
# Use isvalidatom() to check if this move is valid for the
# EAPI (characters allowed in package names may vary).
if old_value in mycontent and isvalidatom(new_value, eapi=eapi):
- old_value = re.escape(old_value);
- mycontent = re.sub(old_value+"(:|$|\\s)", new_value+"\\1", mycontent)
- def myreplace(matchobj):
- # Strip slot and * operator if necessary
- # so that ververify works.
- ver = remove_slot(matchobj.group(2))
- ver = ver.rstrip("*")
- if ververify(ver):
- return "%s-%s" % (new_value, matchobj.group(2))
- else:
- return "".join(matchobj.groups())
- mycontent = re.sub("(%s-)(\\S*)" % old_value, myreplace, mycontent)
+ # this split preserves existing whitespace
+ split_content = re.split(r'(\s+)', mycontent)
+ modified = False
+ for i, token in enumerate(split_content):
+ if old_value not in token:
+ continue
+ try:
+ atom = Atom(token, eapi=eapi)
+ except InvalidAtom:
+ continue
+ if atom.cp != old_value:
+ continue
+
+ split_content[i] = token.replace(old_value, new_value, 1)
+ modified = True
+
+ if modified:
+ mycontent = "".join(split_content)
+
elif update_cmd[0] == "slotmove" and update_cmd[1].operator is None:
orig_atom, origslot, newslot = update_cmd[1:]
orig_cp = orig_atom.cp
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-09-20 4:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-20 4:08 [gentoo-commits] proj/portage:master commit in: pym/portage/tests/update/, pym/portage/ Zac Medico
-- strict thread matches above, loose matches on Subject: below --
2012-09-19 19:48 Zac Medico
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox