[PATCH] revset: add remote() predicate to lookup remote revisions
Na'Tosha Bard
natosha at unity3d.com
Fri Jan 20 04:57:19 CST 2012
Whoops, ignore this one (patchbomb fail).
Na'Tosha
2012/1/20 Na'Tosha Bard <natosha at unity3d.com>
> # HG changeset patch
> # User Matt Mackall <mpm at selenic.com>
> # Date 1327005065 21600
> # Node ID 878bc4a62a735a1624e9b69c672d5fb5074d4855
> # Parent 6c97eb445341c9a806e0e657ea62415c7519c693
> revset: add remote() predicate to lookup remote revisions
>
> diff -r 6c97eb445341 -r 878bc4a62a73 mercurial/revset.py
> --- a/mercurial/revset.py Thu Jan 19 14:07:48 2012 -0600
> +++ b/mercurial/revset.py Thu Jan 19 14:31:05 2012 -0600
> @@ -742,6 +742,41 @@
> getargs(x, 0, 0, _("public takes no arguments"))
> return [r for r in subset if repo._phaserev[r] == phases.public]
>
> +def remote(repo, subset, x):
> + """``remote([id], [path])``
> + Local revision that corresponds to the given identifier in a
> + remote repository, if present. Here, the '.' identifier is a
> + synonym for the current local branch.
> + """
> +
> + import hg # avoid start-up nasties
> + # i18n: "remote" is a keyword
> + l = getargs(x, 0, 2, _("outgoing takes one or two arguments"))
> +
> + q = '.'
> + if len(l) > 0:
> + # i18n: "remote" is a keyword
> + q = getstring(l[0], _("remote requires a string id"))
> + if q == '.':
> + q = repo['.'].branch()
> +
> + dest = ''
> + if len(l) > 1:
> + # i18n: "remote" is a keyword
> + dest = getstring(l[1], _("remote requires a repository path"))
> + dest = repo.ui.expandpath(dest or 'default')
> + dest, branches = hg.parseurl(dest)
> + revs, checkout = hg.addbranchrevs(repo, repo, branches, [])
> + if revs:
> + revs = [repo.lookup(rev) for rev in revs]
> + other = hg.peer(repo, {}, dest)
> + n = other.lookup(q)
> + if n in repo:
> + r = repo[n].rev()
> + if r in subset:
> + return [r]
> + return []
> +
> def removes(repo, subset, x):
> """``removes(pattern)``
> Changesets which remove files matching pattern.
> @@ -916,6 +951,7 @@
> "parents": parents,
> "present": present,
> "public": public,
> + "remote": remote,
> "removes": removes,
> "rev": rev,
> "reverse": reverse,
>
--
*Na'Tosha Bard*
Build & Infrastructure Developer | Unity Technologies - Copenhagen
*E-Mail:* natosha at unity3d.com
*Skype:* natosha.bard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20120120/a2be62d8/attachment.html>
More information about the Mercurial-devel
mailing list