hgext/mq.py
changeset 17191 5884812686f7
parent 17153 54da604fefee
child 17424 e7cfe3587ea4
child 17512 39e7e74b3cd3
equal deleted inserted replaced
17190:d99d0b559084 17191:5884812686f7
  2243         return url + '/.hg/patches'
  2243         return url + '/.hg/patches'
  2244 
  2244 
  2245     # main repo (destination and sources)
  2245     # main repo (destination and sources)
  2246     if dest is None:
  2246     if dest is None:
  2247         dest = hg.defaultdest(source)
  2247         dest = hg.defaultdest(source)
  2248     sr = hg.repository(hg.remoteui(ui, opts), ui.expandpath(source))
  2248     sr = hg.peer(ui, opts, ui.expandpath(source))
  2249 
  2249 
  2250     # patches repo (source only)
  2250     # patches repo (source only)
  2251     if opts.get('patches'):
  2251     if opts.get('patches'):
  2252         patchespath = ui.expandpath(opts.get('patches'))
  2252         patchespath = ui.expandpath(opts.get('patches'))
  2253     else:
  2253     else:
  2254         patchespath = patchdir(sr)
  2254         patchespath = patchdir(sr)
  2255     try:
  2255     try:
  2256         hg.repository(ui, patchespath)
  2256         hg.peer(ui, opts, patchespath)
  2257     except error.RepoError:
  2257     except error.RepoError:
  2258         raise util.Abort(_('versioned patch repository not found'
  2258         raise util.Abort(_('versioned patch repository not found'
  2259                            ' (see init --mq)'))
  2259                            ' (see init --mq)'))
  2260     qbase, destrev = None, None
  2260     qbase, destrev = None, None
  2261     if sr.local():
  2261     if sr.local():
  2262         if sr.mq.applied and sr[qbase].phase() != phases.secret:
  2262         repo = sr.local()
  2263             qbase = sr.mq.applied[0].node
  2263         if repo.mq.applied and repo[qbase].phase() != phases.secret:
       
  2264             qbase = repo.mq.applied[0].node
  2264             if not hg.islocal(dest):
  2265             if not hg.islocal(dest):
  2265                 heads = set(sr.heads())
  2266                 heads = set(repo.heads())
  2266                 destrev = list(heads.difference(sr.heads(qbase)))
  2267                 destrev = list(heads.difference(repo.heads(qbase)))
  2267                 destrev.append(sr.changelog.parents(qbase)[0])
  2268                 destrev.append(repo.changelog.parents(qbase)[0])
  2268     elif sr.capable('lookup'):
  2269     elif sr.capable('lookup'):
  2269         try:
  2270         try:
  2270             qbase = sr.lookup('qbase')
  2271             qbase = sr.lookup('qbase')
  2271         except error.RepoError:
  2272         except error.RepoError:
  2272             pass
  2273             pass
  2282     hg.clone(ui, opts, opts.get('patches') or patchdir(sr), patchdir(dr),
  2283     hg.clone(ui, opts, opts.get('patches') or patchdir(sr), patchdir(dr),
  2283              pull=opts.get('pull'), update=not opts.get('noupdate'),
  2284              pull=opts.get('pull'), update=not opts.get('noupdate'),
  2284              stream=opts.get('uncompressed'))
  2285              stream=opts.get('uncompressed'))
  2285 
  2286 
  2286     if dr.local():
  2287     if dr.local():
       
  2288         repo = dr.local()
  2287         if qbase:
  2289         if qbase:
  2288             ui.note(_('stripping applied patches from destination '
  2290             ui.note(_('stripping applied patches from destination '
  2289                       'repository\n'))
  2291                       'repository\n'))
  2290             dr.mq.strip(dr, [qbase], update=False, backup=None)
  2292             repo.mq.strip(repo, [qbase], update=False, backup=None)
  2291         if not opts.get('noupdate'):
  2293         if not opts.get('noupdate'):
  2292             ui.note(_('updating destination repository\n'))
  2294             ui.note(_('updating destination repository\n'))
  2293             hg.update(dr, dr.changelog.tip())
  2295             hg.update(repo, repo.changelog.tip())
  2294 
  2296 
  2295 @command("qcommit|qci",
  2297 @command("qcommit|qci",
  2296          commands.table["^commit|ci"][1],
  2298          commands.table["^commit|ci"][1],
  2297          _('hg qcommit [OPTION]... [FILE]...'))
  2299          _('hg qcommit [OPTION]... [FILE]...'))
  2298 def commit(ui, repo, *pats, **opts):
  2300 def commit(ui, repo, *pats, **opts):