1 |
commit: 9564e058ab9c952959bc6c1503944bb8cca76e69 |
2 |
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Feb 10 18:05:46 2016 +0000 |
4 |
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Mar 7 21:21:35 2016 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=9564e058 |
7 |
|
8 |
repoman: Migrate vcs index update code to the vcs modules |
9 |
|
10 |
pym/repoman/actions.py | 22 +--------------------- |
11 |
pym/repoman/modules/vcs/changes.py | 4 ++++ |
12 |
pym/repoman/modules/vcs/git/changes.py | 27 +++++++++++++++++++++++++++ |
13 |
3 files changed, 32 insertions(+), 21 deletions(-) |
14 |
|
15 |
diff --git a/pym/repoman/actions.py b/pym/repoman/actions.py |
16 |
index 21e7db6..4209d13 100644 |
17 |
--- a/pym/repoman/actions.py |
18 |
+++ b/pym/repoman/actions.py |
19 |
@@ -163,27 +163,7 @@ class Actions(object): |
20 |
if self.repo_settings.sign_manifests: |
21 |
self.sign_manifest(myupdates, myremoved, mymanifests) |
22 |
|
23 |
- if self.vcs_settings.vcs == 'git': |
24 |
- # It's not safe to use the git commit -a option since there might |
25 |
- # be some modified files elsewhere in the working tree that the |
26 |
- # user doesn't want to commit. Therefore, call git update-index |
27 |
- # in order to ensure that the index is updated with the latest |
28 |
- # versions of all new and modified files in the relevant portion |
29 |
- # of the working tree. |
30 |
- myfiles = mymanifests + myupdates |
31 |
- myfiles.sort() |
32 |
- update_index_cmd = ["git", "update-index"] |
33 |
- update_index_cmd.extend(f.lstrip("./") for f in myfiles) |
34 |
- if self.options.pretend: |
35 |
- print("(%s)" % (" ".join(update_index_cmd),)) |
36 |
- else: |
37 |
- retval = spawn(update_index_cmd, env=os.environ) |
38 |
- if retval != os.EX_OK: |
39 |
- writemsg_level( |
40 |
- "!!! Exiting on %s (shell) " |
41 |
- "error code: %s\n" % (self.vcs_settings.vcs, retval), |
42 |
- level=logging.ERROR, noiselevel=-1) |
43 |
- sys.exit(retval) |
44 |
+ self.vcs_settings.changes.update_index(mymanifests, myupdates) |
45 |
|
46 |
self.add_manifest(mymanifests, myheaders, myupdates, myremoved, commitmessage) |
47 |
|
48 |
|
49 |
diff --git a/pym/repoman/modules/vcs/changes.py b/pym/repoman/modules/vcs/changes.py |
50 |
index 27b627f..948407c 100644 |
51 |
--- a/pym/repoman/modules/vcs/changes.py |
52 |
+++ b/pym/repoman/modules/vcs/changes.py |
53 |
@@ -85,3 +85,7 @@ class ChangesBase(object): |
54 |
def clear_attic(myheaders): |
55 |
'''Old CVS leftover''' |
56 |
pass |
57 |
+ |
58 |
+ def update_index(self, mymanifests, myupdates): |
59 |
+ '''Update the vcs's modified index if it is needed''' |
60 |
+ pass |
61 |
|
62 |
diff --git a/pym/repoman/modules/vcs/git/changes.py b/pym/repoman/modules/vcs/git/changes.py |
63 |
index 1970b3a..018458c 100644 |
64 |
--- a/pym/repoman/modules/vcs/git/changes.py |
65 |
+++ b/pym/repoman/modules/vcs/git/changes.py |
66 |
@@ -2,11 +2,16 @@ |
67 |
Git module Changes class submodule |
68 |
''' |
69 |
|
70 |
+import logging |
71 |
+import sys |
72 |
+ |
73 |
from repoman.modules.vcs.changes import ChangesBase |
74 |
from repoman._subprocess import repoman_popen |
75 |
from repoman._portage import portage |
76 |
from portage import os |
77 |
from portage.package.ebuild.digestgen import digestgen |
78 |
+from portage.process import spawn |
79 |
+from portage.util import writemsg_level |
80 |
|
81 |
|
82 |
class Changes(ChangesBase): |
83 |
@@ -63,3 +68,25 @@ class Changes(ChangesBase): |
84 |
for x in broken_changelog_manifests: |
85 |
self.repoman_settings["O"] = os.path.join(self.repo_settings.repodir, x) |
86 |
digestgen(mysettings=self.repoman_settings, myportdb=self.repo_settings.portdb) |
87 |
+ |
88 |
+ def update_index(self, mymanifests, myupdates): |
89 |
+ # It's not safe to use the git commit -a option since there might |
90 |
+ # be some modified files elsewhere in the working tree that the |
91 |
+ # user doesn't want to commit. Therefore, call git update-index |
92 |
+ # in order to ensure that the index is updated with the latest |
93 |
+ # versions of all new and modified files in the relevant portion |
94 |
+ # of the working tree. |
95 |
+ myfiles = mymanifests + myupdates |
96 |
+ myfiles.sort() |
97 |
+ update_index_cmd = ["git", "update-index"] |
98 |
+ update_index_cmd.extend(f.lstrip("./") for f in myfiles) |
99 |
+ if self.options.pretend: |
100 |
+ print("(%s)" % (" ".join(update_index_cmd),)) |
101 |
+ else: |
102 |
+ retval = spawn(update_index_cmd, env=os.environ) |
103 |
+ if retval != os.EX_OK: |
104 |
+ writemsg_level( |
105 |
+ "!!! Exiting on %s (shell) " |
106 |
+ "error code: %s\n" % (self.vcs_settings.vcs, retval), |
107 |
+ level=logging.ERROR, noiselevel=-1) |
108 |
+ sys.exit(retval) |