##// END OF EJS Templates
mq: replace module-wide repo hash with a repo attribute
Brendan Cully -
r2724:9c41ae19 default
parent child Browse files
Show More
@@ -36,8 +36,6 b' from mercurial import ui, hg, revlog, co'
36
36
37 versionstr = "0.45"
37 versionstr = "0.45"
38
38
39 repomap = {}
40
41 commands.norepo += " qclone qversion"
39 commands.norepo += " qclone qversion"
42
40
43 class queue:
41 class queue:
@@ -1141,24 +1139,24 b' class queue:'
1141
1139
1142 def delete(ui, repo, patch, **opts):
1140 def delete(ui, repo, patch, **opts):
1143 """remove a patch from the series file"""
1141 """remove a patch from the series file"""
1144 q = repomap[repo]
1142 q = repo.mq
1145 q.delete(repo, patch)
1143 q.delete(repo, patch)
1146 q.save_dirty()
1144 q.save_dirty()
1147 return 0
1145 return 0
1148
1146
1149 def applied(ui, repo, patch=None, **opts):
1147 def applied(ui, repo, patch=None, **opts):
1150 """print the patches already applied"""
1148 """print the patches already applied"""
1151 repomap[repo].qapplied(repo, patch)
1149 repo.mq.qapplied(repo, patch)
1152 return 0
1150 return 0
1153
1151
1154 def unapplied(ui, repo, patch=None, **opts):
1152 def unapplied(ui, repo, patch=None, **opts):
1155 """print the patches not yet applied"""
1153 """print the patches not yet applied"""
1156 repomap[repo].unapplied(repo, patch)
1154 repo.mq.unapplied(repo, patch)
1157 return 0
1155 return 0
1158
1156
1159 def qimport(ui, repo, *filename, **opts):
1157 def qimport(ui, repo, *filename, **opts):
1160 """import a patch"""
1158 """import a patch"""
1161 q = repomap[repo]
1159 q = repo.mq
1162 q.qimport(repo, filename, patch=opts['name'],
1160 q.qimport(repo, filename, patch=opts['name'],
1163 existing=opts['existing'], force=opts['force'])
1161 existing=opts['existing'], force=opts['force'])
1164 q.save_dirty()
1162 q.save_dirty()
@@ -1166,7 +1164,7 b' def qimport(ui, repo, *filename, **opts)'
1166
1164
1167 def init(ui, repo, **opts):
1165 def init(ui, repo, **opts):
1168 """init a new queue repository"""
1166 """init a new queue repository"""
1169 q = repomap[repo]
1167 q = repo.mq
1170 r = q.init(repo, create=opts['create_repo'])
1168 r = q.init(repo, create=opts['create_repo'])
1171 q.save_dirty()
1169 q.save_dirty()
1172 if r:
1170 if r:
@@ -1226,34 +1224,34 b' def clone(ui, source, dest=None, **opts)'
1226
1224
1227 def commit(ui, repo, *pats, **opts):
1225 def commit(ui, repo, *pats, **opts):
1228 """commit changes in the queue repository"""
1226 """commit changes in the queue repository"""
1229 q = repomap[repo]
1227 q = repo.mq
1230 r = q.qrepo()
1228 r = q.qrepo()
1231 if not r: raise util.Abort('no queue repository')
1229 if not r: raise util.Abort('no queue repository')
1232 commands.commit(r.ui, r, *pats, **opts)
1230 commands.commit(r.ui, r, *pats, **opts)
1233
1231
1234 def series(ui, repo, **opts):
1232 def series(ui, repo, **opts):
1235 """print the entire series file"""
1233 """print the entire series file"""
1236 repomap[repo].qseries(repo, missing=opts['missing'])
1234 repo.mq.qseries(repo, missing=opts['missing'])
1237 return 0
1235 return 0
1238
1236
1239 def top(ui, repo, **opts):
1237 def top(ui, repo, **opts):
1240 """print the name of the current patch"""
1238 """print the name of the current patch"""
1241 repomap[repo].top(repo)
1239 repo.mq.top(repo)
1242 return 0
1240 return 0
1243
1241
1244 def next(ui, repo, **opts):
1242 def next(ui, repo, **opts):
1245 """print the name of the next patch"""
1243 """print the name of the next patch"""
1246 repomap[repo].next(repo)
1244 repo.mq.next(repo)
1247 return 0
1245 return 0
1248
1246
1249 def prev(ui, repo, **opts):
1247 def prev(ui, repo, **opts):
1250 """print the name of the previous patch"""
1248 """print the name of the previous patch"""
1251 repomap[repo].prev(repo)
1249 repo.mq.prev(repo)
1252 return 0
1250 return 0
1253
1251
1254 def new(ui, repo, patch, **opts):
1252 def new(ui, repo, patch, **opts):
1255 """create a new patch"""
1253 """create a new patch"""
1256 q = repomap[repo]
1254 q = repo.mq
1257 message=commands.logmessage(**opts)
1255 message=commands.logmessage(**opts)
1258 q.new(repo, patch, msg=message, force=opts['force'])
1256 q.new(repo, patch, msg=message, force=opts['force'])
1259 q.save_dirty()
1257 q.save_dirty()
@@ -1261,7 +1259,7 b' def new(ui, repo, patch, **opts):'
1261
1259
1262 def refresh(ui, repo, **opts):
1260 def refresh(ui, repo, **opts):
1263 """update the current patch"""
1261 """update the current patch"""
1264 q = repomap[repo]
1262 q = repo.mq
1265 message=commands.logmessage(**opts)
1263 message=commands.logmessage(**opts)
1266 q.refresh(repo, msg=message, short=opts['short'])
1264 q.refresh(repo, msg=message, short=opts['short'])
1267 q.save_dirty()
1265 q.save_dirty()
@@ -1270,7 +1268,7 b' def refresh(ui, repo, **opts):'
1270 def diff(ui, repo, *files, **opts):
1268 def diff(ui, repo, *files, **opts):
1271 """diff of the current patch"""
1269 """diff of the current patch"""
1272 # deep in the dirstate code, the walkhelper method wants a list, not a tuple
1270 # deep in the dirstate code, the walkhelper method wants a list, not a tuple
1273 repomap[repo].diff(repo, list(files))
1271 repo.mq.diff(repo, list(files))
1274 return 0
1272 return 0
1275
1273
1276 def lastsavename(path):
1274 def lastsavename(path):
@@ -1299,7 +1297,7 b' def savename(path):'
1299
1297
1300 def push(ui, repo, patch=None, **opts):
1298 def push(ui, repo, patch=None, **opts):
1301 """push the next patch onto the stack"""
1299 """push the next patch onto the stack"""
1302 q = repomap[repo]
1300 q = repo.mq
1303 mergeq = None
1301 mergeq = None
1304
1302
1305 if opts['all']:
1303 if opts['all']:
@@ -1327,7 +1325,7 b' def pop(ui, repo, patch=None, **opts):'
1327 ui.warn('using patch queue: %s\n' % q.path)
1325 ui.warn('using patch queue: %s\n' % q.path)
1328 localupdate = False
1326 localupdate = False
1329 else:
1327 else:
1330 q = repomap[repo]
1328 q = repo.mq
1331 q.pop(repo, patch, force=opts['force'], update=localupdate, all=opts['all'])
1329 q.pop(repo, patch, force=opts['force'], update=localupdate, all=opts['all'])
1332 q.save_dirty()
1330 q.save_dirty()
1333 return 0
1331 return 0
@@ -1335,7 +1333,7 b' def pop(ui, repo, patch=None, **opts):'
1335 def restore(ui, repo, rev, **opts):
1333 def restore(ui, repo, rev, **opts):
1336 """restore the queue state saved by a rev"""
1334 """restore the queue state saved by a rev"""
1337 rev = repo.lookup(rev)
1335 rev = repo.lookup(rev)
1338 q = repomap[repo]
1336 q = repo.mq
1339 q.restore(repo, rev, delete=opts['delete'],
1337 q.restore(repo, rev, delete=opts['delete'],
1340 qupdate=opts['update'])
1338 qupdate=opts['update'])
1341 q.save_dirty()
1339 q.save_dirty()
@@ -1343,7 +1341,7 b' def restore(ui, repo, rev, **opts):'
1343
1341
1344 def save(ui, repo, **opts):
1342 def save(ui, repo, **opts):
1345 """save current queue state"""
1343 """save current queue state"""
1346 q = repomap[repo]
1344 q = repo.mq
1347 message=commands.logmessage(**opts)
1345 message=commands.logmessage(**opts)
1348 ret = q.save(repo, msg=message)
1346 ret = q.save(repo, msg=message)
1349 if ret:
1347 if ret:
@@ -1379,7 +1377,7 b' def strip(ui, repo, rev, **opts):'
1379 backup = 'strip'
1377 backup = 'strip'
1380 elif opts['nobackup']:
1378 elif opts['nobackup']:
1381 backup = 'none'
1379 backup = 'none'
1382 repomap[repo].strip(repo, rev, backup=backup)
1380 repo.mq.strip(repo, rev, backup=backup)
1383 return 0
1381 return 0
1384
1382
1385 def version(ui, q=None):
1383 def version(ui, q=None):
@@ -1395,7 +1393,7 b' def reposetup(ui, repo):'
1395
1393
1396 tagscache = super(self.__class__, self).tags()
1394 tagscache = super(self.__class__, self).tags()
1397
1395
1398 q = repomap[repo]
1396 q = self.mq
1399 if not q.applied:
1397 if not q.applied:
1400 return tagscache
1398 return tagscache
1401
1399
@@ -1411,7 +1409,7 b' def reposetup(ui, repo):'
1411 return tagscache
1409 return tagscache
1412
1410
1413 repo.__class__ = MqRepo
1411 repo.__class__ = MqRepo
1414 repomap[repo] = queue(ui, repo.join(""))
1412 repo.mq = queue(ui, repo.join(""))
1415
1413
1416 cmdtable = {
1414 cmdtable = {
1417 "qapplied": (applied, [], 'hg qapplied [PATCH]'),
1415 "qapplied": (applied, [], 'hg qapplied [PATCH]'),
General Comments 0
You need to be logged in to leave comments. Login now