1 |
Author: zmedico |
2 |
Date: 2010-01-29 18:49:38 +0000 (Fri, 29 Jan 2010) |
3 |
New Revision: 15256 |
4 |
|
5 |
Modified: |
6 |
main/branches/2.1.7/bin/repoman |
7 |
Log: |
8 |
Support mercurial. Thanks to Rafael Martins <rafael@×××××××××××××.com> for |
9 |
this patch. (trunk r15203) |
10 |
|
11 |
Modified: main/branches/2.1.7/bin/repoman |
12 |
=================================================================== |
13 |
--- main/branches/2.1.7/bin/repoman 2010-01-29 18:49:23 UTC (rev 15255) |
14 |
+++ main/branches/2.1.7/bin/repoman 2010-01-29 18:49:38 UTC (rev 15256) |
15 |
@@ -486,11 +486,13 @@ |
16 |
vcs = "git" |
17 |
elif os.path.isdir(os.path.join(portdir_overlay, ".bzr")): |
18 |
vcs = "bzr" |
19 |
+elif os.path.isdir(os.path.join(portdir_overlay, ".hg")): |
20 |
+ vcs = "hg" |
21 |
|
22 |
vcs_local_opts = repoman_settings.get("REPOMAN_VCS_LOCAL_OPTS", "").split() |
23 |
vcs_global_opts = repoman_settings.get("REPOMAN_VCS_GLOBAL_OPTS") |
24 |
if vcs_global_opts is None: |
25 |
- if vcs not in ["git", "bzr"]: |
26 |
+ if vcs not in ("git", "bzr", "hg"): |
27 |
vcs_global_opts = "-q" |
28 |
else: |
29 |
vcs_global_opts = "" |
30 |
@@ -932,6 +934,11 @@ |
31 |
bzrstatus = os.popen("bzr status -S .").readlines() |
32 |
mychanged = [ "./" + elem.split()[-1:][0].split('/')[-1:][0] for elem in bzrstatus if elem and elem[1:2] == "M" ] |
33 |
mynew = [ "./" + elem.split()[-1:][0].split('/')[-1:][0] for elem in bzrstatus if elem and ( elem[1:2] == "NK" or elem[0:1] == "R" ) ] |
34 |
+elif vcs == "hg": |
35 |
+ mychanged = os.popen("hg status --no-status --modified .").readlines() |
36 |
+ mychanged = ["./" + elem.rstrip() for elem in mychanged] |
37 |
+ mynew = os.popen("hg status --no-status --added .").readlines() |
38 |
+ mynew = ["./" + elem.rstrip() for elem in mynew] |
39 |
|
40 |
if vcs: |
41 |
new_ebuilds.update(x for x in mynew if x.endswith(".ebuild")) |
42 |
@@ -1092,9 +1099,13 @@ |
43 |
s = s[s.rfind("\n") + 1:] |
44 |
fails["file.UTF8"].append("%s/%s: line %i, just after: '%s'" % (checkdir, y, line, s)) |
45 |
|
46 |
- if vcs == "git" and check_ebuild_notadded: |
47 |
- myf = os.popen("git ls-files --others %s" % \ |
48 |
- (portage._shell_quote(checkdir_relative),)) |
49 |
+ if vcs in ("git", "hg") and check_ebuild_notadded: |
50 |
+ if vcs == "git": |
51 |
+ myf = os.popen("git ls-files --others %s" % \ |
52 |
+ (portage._shell_quote(checkdir_relative),)) |
53 |
+ if vcs == "hg": |
54 |
+ myf = os.popen("hg status --no-status --unknown %s" % \ |
55 |
+ (portage._shell_quote(checkdir_relative),)) |
56 |
for l in myf: |
57 |
if l[:-1][-7:] == ".ebuild": |
58 |
stats["ebuild.notadded"] += 1 |
59 |
@@ -1259,7 +1270,7 @@ |
60 |
# It will be generated on server side from scm log, |
61 |
# before package moves to the rsync server. |
62 |
# This is needed because we try to avoid merge collisions. |
63 |
- if vcs not in ( "git", ) and "ChangeLog" not in checkdirlist: |
64 |
+ if vcs not in ("git", "hg") and "ChangeLog" not in checkdirlist: |
65 |
stats["changelog.missing"]+=1 |
66 |
fails["changelog.missing"].append(x+"/ChangeLog") |
67 |
|
68 |
@@ -1977,6 +1988,15 @@ |
69 |
raise # TODO propogate this |
70 |
except: |
71 |
err("Error retrieving bzr info; exiting.") |
72 |
+ if vcs == "hg": |
73 |
+ myunadded = os.popen("hg status --no-status --unknown .").readlines() |
74 |
+ myunadded = ["./" + elem.rstrip() for elem in myunadded] |
75 |
+ |
76 |
+ # Mercurial doesn't handle manually deleted files as removed from |
77 |
+ # the repository, so the user need to remove them before commit, |
78 |
+ # using "hg remove [FILES]" |
79 |
+ mydeleted = os.popen("hg status --no-status --deleted .").readlines() |
80 |
+ mydeleted = ["./" + elem.rstrip() for elem in mydeleted] |
81 |
|
82 |
|
83 |
myautoadd=[] |
84 |
@@ -2002,6 +2022,8 @@ |
85 |
print("(git add "+" ".join(myautoadd)+")") |
86 |
elif vcs == "bzr": |
87 |
print("(bzr add "+" ".join(myautoadd)+")") |
88 |
+ elif vcs == "hg": |
89 |
+ print("(hg add "+" ".join(myautoadd)+")") |
90 |
retval=0 |
91 |
else: |
92 |
if vcs == "cvs": |
93 |
@@ -2012,6 +2034,8 @@ |
94 |
retval=os.system("git add "+" ".join(myautoadd)) |
95 |
elif vcs == "bzr": |
96 |
retval=os.system("bzr add "+" ".join(myautoadd)) |
97 |
+ elif vcs == "hg": |
98 |
+ retval=os.system("hg add "+" ".join(myautoadd)) |
99 |
if retval: |
100 |
writemsg_level("!!! Exiting on %s (shell) error code: %s\n" % \ |
101 |
(vcs, retval), level=logging.ERROR, noiselevel=-1) |
102 |
@@ -2026,6 +2050,15 @@ |
103 |
print() |
104 |
sys.exit(1) |
105 |
|
106 |
+ if vcs == "hg" and mydeleted: |
107 |
+ print(red("!!! The following files are removed manually from your local tree but are not")) |
108 |
+ print(red("!!! removed from the repository. Please remove them, using \"hg remove [FILES]\".")) |
109 |
+ for x in mydeleted: |
110 |
+ print(" ",x) |
111 |
+ print() |
112 |
+ print() |
113 |
+ sys.exit(1) |
114 |
+ |
115 |
if vcs == "cvs": |
116 |
mycvstree = cvstree.getentries("./", recursive=1) |
117 |
mychanged = cvstree.findchanged(mycvstree, recursive=1, basedir="./") |
118 |
@@ -2084,8 +2117,16 @@ |
119 |
myremoved = [ "./" + elem.split()[-3:-2][0].split('/')[-1:][0] for elem in bzrstatus if elem and ( elem[1:2] == "K" or elem[0:1] == "R" ) ] |
120 |
# Bazaar expands nothing. |
121 |
|
122 |
+ if vcs == "hg": |
123 |
+ mychanged = os.popen("hg status --no-status --modified .").readlines() |
124 |
+ mychanged = ["./" + elem.rstrip() for elem in mychanged] |
125 |
+ mynew = os.popen("hg status --no-status --added .").readlines() |
126 |
+ mynew = ["./" + elem.rstrip() for elem in mynew] |
127 |
+ myremoved = os.popen("hg status --no-status --removed .").readlines() |
128 |
+ myremoved = ["./" + elem.rstrip() for elem in myremoved] |
129 |
+ |
130 |
if vcs: |
131 |
- if not (mychanged or mynew or myremoved): |
132 |
+ if not (mychanged or mynew or myremoved or (vcs == "hg" and mydeleted)): |
133 |
print(green("RepoMan sez:"), "\"Doing nothing is not always good for QA.\"") |
134 |
print() |
135 |
print("(Didn't find any changed files...)") |
136 |
@@ -2101,7 +2142,7 @@ |
137 |
mymanifests.add(f) |
138 |
else: |
139 |
myupdates.add(f) |
140 |
- if vcs == 'git': |
141 |
+ if vcs in ('git', 'hg'): |
142 |
myupdates.difference_update(myremoved) |
143 |
myupdates = list(myupdates) |
144 |
mymanifests = list(mymanifests) |
145 |
@@ -2126,8 +2167,8 @@ |
146 |
myheaders.append(myfile) |
147 |
|
148 |
print("* %s files being committed..." % green(str(len(myupdates))), end=' ') |
149 |
- if vcs in ('git', 'bzr'): |
150 |
- # With git and bzr, there's never any keyword expansion, so |
151 |
+ if vcs in ('git', 'bzr', 'hg'): |
152 |
+ # With git, bzr and hg, there's never any keyword expansion, so |
153 |
# there's no need to regenerate manifests and all files will be |
154 |
# committed in one big commit at the end. |
155 |
print() |
156 |
@@ -2182,7 +2223,7 @@ |
157 |
commitmessage += ", RepoMan options: --force" |
158 |
commitmessage += ")" |
159 |
|
160 |
- if vcs not in ['git', 'bzr'] and (myupdates or myremoved): |
161 |
+ if vcs not in ['git', 'bzr', 'hg'] and (myupdates or myremoved): |
162 |
myfiles = myupdates + myremoved |
163 |
if not myheaders and "sign" not in repoman_settings.features: |
164 |
myfiles += mymanifests |
165 |
@@ -2275,7 +2316,7 @@ |
166 |
write_atomic(x, "".join(mylines)) |
167 |
|
168 |
manifest_commit_required = True |
169 |
- if vcs not in ['git', 'bzr'] and (myupdates or myremoved): |
170 |
+ if vcs not in ['git', 'bzr', 'hg'] and (myupdates or myremoved): |
171 |
myfiles = myupdates + myremoved |
172 |
for x in range(len(myfiles)-1, -1, -1): |
173 |
if myfiles[x].count("/") < 4-repolevel: |
174 |
@@ -2418,10 +2459,10 @@ |
175 |
level=logging.ERROR, noiselevel=-1) |
176 |
sys.exit(retval) |
177 |
|
178 |
- if vcs in ['git', 'bzr'] or manifest_commit_required or signed: |
179 |
+ if vcs in ['git', 'bzr', 'hg'] or manifest_commit_required or signed: |
180 |
|
181 |
myfiles = mymanifests[:] |
182 |
- if vcs in ['git', 'bzr']: |
183 |
+ if vcs in ['git', 'bzr', 'hg']: |
184 |
myfiles += myupdates |
185 |
myfiles += myremoved |
186 |
myfiles.sort() |
187 |
@@ -2444,8 +2485,12 @@ |
188 |
commit_cmd.extend(vcs_global_opts) |
189 |
commit_cmd.append("commit") |
190 |
commit_cmd.extend(vcs_local_opts) |
191 |
- commit_cmd.extend(["-F", commitmessagefile]) |
192 |
- commit_cmd.extend(f.lstrip("./") for f in myfiles) |
193 |
+ if vcs in ('git', 'bzr'): |
194 |
+ commit_cmd.extend(["-F", commitmessagefile]) |
195 |
+ commit_cmd.extend(f.lstrip("./") for f in myfiles) |
196 |
+ elif vcs == "hg": |
197 |
+ commit_cmd.extend(["--logfile", commitmessagefile]) |
198 |
+ commit_cmd.extend(myfiles) |
199 |
|
200 |
try: |
201 |
if options.pretend: |