comparison hgext/mq.py @ 2720:c91ca61c8953

mq: add qclone command
author Vadim Gelfer <vadim.gelfer@gmail.com>
date Fri, 28 Jul 2006 10:46:41 -0700
parents 35caf437a201
children 04d9b31faeca
comparison
equal deleted inserted replaced
2719:532809ba1db5 2720:c91ca61c8953
36 36
37 versionstr = "0.45" 37 versionstr = "0.45"
38 38
39 repomap = {} 39 repomap = {}
40 40
41 commands.norepo += " qversion" 41 commands.norepo += " qclone qversion"
42
42 class queue: 43 class queue:
43 def __init__(self, ui, path, patchdir=None): 44 def __init__(self, ui, path, patchdir=None):
44 self.basepath = path 45 self.basepath = path
45 if patchdir: 46 if patchdir:
46 self.path = patchdir 47 self.path = patchdir
1175 fp.close() 1176 fp.close()
1176 r.wopener('series', 'w').close() 1177 r.wopener('series', 'w').close()
1177 r.add(['.hgignore', 'series']) 1178 r.add(['.hgignore', 'series'])
1178 return 0 1179 return 0
1179 1180
1181 def clone(ui, source, dest=None, **opts):
1182 '''clone main and patch repository at same time
1183
1184 If source is local, destination will have no patches applied. If
1185 source is remote, this command can not check if patches are
1186 applied in source, so cannot guarantee that patches are not
1187 applied in destination. If you clone remote repository, be sure
1188 before that it has no patches applied.
1189
1190 Source patch repository is looked for in <src>/.hg/patches by
1191 default. Use -p <url> to change.
1192 '''
1193 ui.setconfig_remoteopts(**opts)
1194 if dest is None:
1195 dest = hg.defaultdest(source)
1196 sr = hg.repository(ui, ui.expandpath(source))
1197 qbase, destrev = None, None
1198 if sr.local():
1199 reposetup(ui, sr)
1200 sq = repomap[sr]
1201 if sq.applied:
1202 qbase = revlog.bin(sq.applied[0].split(':')[0])
1203 if not hg.islocal(dest):
1204 destrev = sr.parents(qbase)[0]
1205 ui.note(_('cloning main repo\n'))
1206 sr, dr = hg.clone(ui, sr, dest,
1207 pull=opts['pull'],
1208 rev=destrev,
1209 update=False,
1210 stream=opts['uncompressed'])
1211 ui.note(_('cloning patch repo\n'))
1212 spr, dpr = hg.clone(ui, opts['patches'] or (sr.url() + '/.hg/patches'),
1213 dr.url() + '/.hg/patches',
1214 pull=opts['pull'],
1215 update=not opts['noupdate'],
1216 stream=opts['uncompressed'])
1217 if dr.local():
1218 if qbase:
1219 ui.note(_('stripping applied patches from destination repo\n'))
1220 reposetup(ui, dr)
1221 dq = repomap[dr]
1222 dq.strip(dr, qbase, update=False, backup=None)
1223 if not opts['noupdate']:
1224 ui.note(_('updating destination repo\n'))
1225 dr.update(dr.changelog.tip())
1226
1180 def commit(ui, repo, *pats, **opts): 1227 def commit(ui, repo, *pats, **opts):
1181 """commit changes in the queue repository""" 1228 """commit changes in the queue repository"""
1182 q = repomap[repo] 1229 q = repomap[repo]
1183 r = q.qrepo() 1230 r = q.qrepo()
1184 if not r: raise util.Abort('no queue repository') 1231 if not r: raise util.Abort('no queue repository')
1367 1414
1368 repo.tags = qtags 1415 repo.tags = qtags
1369 1416
1370 cmdtable = { 1417 cmdtable = {
1371 "qapplied": (applied, [], 'hg qapplied [PATCH]'), 1418 "qapplied": (applied, [], 'hg qapplied [PATCH]'),
1419 "qclone": (clone,
1420 [('', 'pull', None, _('use pull protocol to copy metadata')),
1421 ('U', 'noupdate', None, _('do not update the new working directories')),
1422 ('', 'uncompressed', None,
1423 _('use uncompressed transfer (fast over LAN)')),
1424 ('e', 'ssh', '', _('specify ssh command to use')),
1425 ('p', 'patches', '', _('location of source patch repo')),
1426 ('', 'remotecmd', '',
1427 _('specify hg command to run on the remote side'))],
1428 'hg qclone [OPTION]... SOURCE [DEST]'),
1372 "qcommit|qci": 1429 "qcommit|qci":
1373 (commit, 1430 (commit,
1374 commands.table["^commit|ci"][1], 1431 commands.table["^commit|ci"][1],
1375 'hg qcommit [OPTION]... [FILE]...'), 1432 'hg qcommit [OPTION]... [FILE]...'),
1376 "^qdiff": (diff, [], 'hg qdiff [FILE]...'), 1433 "^qdiff": (diff, [], 'hg qdiff [FILE]...'),