Mercurial > public > mercurial-scm > hg-stable
diff hgext/mq.py @ 17191:5884812686f7
peer: introduce peer methods to prepare for peer classes
This introduces a peer method into all repository classes, which currently
simply returns self. It also changes hg.repository so it now raises an
exception if the supplied paths does not resolve to a localrepo or descendant.
Finally, all call sites are changed to use the peer and local methods as
appropriate, where peer is used whenever the code is dealing with a remote
repository (even if it's on local disk).
author | Sune Foldager <cryo@cyanite.org> |
---|---|
date | Fri, 13 Jul 2012 21:46:53 +0200 |
parents | 54da604fefee |
children | e7cfe3587ea4 39e7e74b3cd3 |
line wrap: on
line diff
--- a/hgext/mq.py Fri Jul 06 14:12:42 2012 -0500 +++ b/hgext/mq.py Fri Jul 13 21:46:53 2012 +0200 @@ -2245,7 +2245,7 @@ # main repo (destination and sources) if dest is None: dest = hg.defaultdest(source) - sr = hg.repository(hg.remoteui(ui, opts), ui.expandpath(source)) + sr = hg.peer(ui, opts, ui.expandpath(source)) # patches repo (source only) if opts.get('patches'): @@ -2253,18 +2253,19 @@ else: patchespath = patchdir(sr) try: - hg.repository(ui, patchespath) + hg.peer(ui, opts, patchespath) except error.RepoError: raise util.Abort(_('versioned patch repository not found' ' (see init --mq)')) qbase, destrev = None, None if sr.local(): - if sr.mq.applied and sr[qbase].phase() != phases.secret: - qbase = sr.mq.applied[0].node + repo = sr.local() + if repo.mq.applied and repo[qbase].phase() != phases.secret: + qbase = repo.mq.applied[0].node if not hg.islocal(dest): - heads = set(sr.heads()) - destrev = list(heads.difference(sr.heads(qbase))) - destrev.append(sr.changelog.parents(qbase)[0]) + heads = set(repo.heads()) + destrev = list(heads.difference(repo.heads(qbase))) + destrev.append(repo.changelog.parents(qbase)[0]) elif sr.capable('lookup'): try: qbase = sr.lookup('qbase') @@ -2284,13 +2285,14 @@ stream=opts.get('uncompressed')) if dr.local(): + repo = dr.local() if qbase: ui.note(_('stripping applied patches from destination ' 'repository\n')) - dr.mq.strip(dr, [qbase], update=False, backup=None) + repo.mq.strip(repo, [qbase], update=False, backup=None) if not opts.get('noupdate'): ui.note(_('updating destination repository\n')) - hg.update(dr, dr.changelog.tip()) + hg.update(repo, repo.changelog.tip()) @command("qcommit|qci", commands.table["^commit|ci"][1],