comparison mercurial/revset.py @ 15936:878bc4a62a73

revset: add remote() predicate to lookup remote revisions
author Matt Mackall <mpm@selenic.com>
date Thu, 19 Jan 2012 14:31:05 -0600
parents 0329d3b12d8e
children f8272c70eb7f
comparison
equal deleted inserted replaced
15935:6c97eb445341 15936:878bc4a62a73
740 """``public()`` 740 """``public()``
741 Changeset in public phase.""" 741 Changeset in public phase."""
742 getargs(x, 0, 0, _("public takes no arguments")) 742 getargs(x, 0, 0, _("public takes no arguments"))
743 return [r for r in subset if repo._phaserev[r] == phases.public] 743 return [r for r in subset if repo._phaserev[r] == phases.public]
744 744
745 def remote(repo, subset, x):
746 """``remote([id], [path])``
747 Local revision that corresponds to the given identifier in a
748 remote repository, if present. Here, the '.' identifier is a
749 synonym for the current local branch.
750 """
751
752 import hg # avoid start-up nasties
753 # i18n: "remote" is a keyword
754 l = getargs(x, 0, 2, _("outgoing takes one or two arguments"))
755
756 q = '.'
757 if len(l) > 0:
758 # i18n: "remote" is a keyword
759 q = getstring(l[0], _("remote requires a string id"))
760 if q == '.':
761 q = repo['.'].branch()
762
763 dest = ''
764 if len(l) > 1:
765 # i18n: "remote" is a keyword
766 dest = getstring(l[1], _("remote requires a repository path"))
767 dest = repo.ui.expandpath(dest or 'default')
768 dest, branches = hg.parseurl(dest)
769 revs, checkout = hg.addbranchrevs(repo, repo, branches, [])
770 if revs:
771 revs = [repo.lookup(rev) for rev in revs]
772 other = hg.peer(repo, {}, dest)
773 n = other.lookup(q)
774 if n in repo:
775 r = repo[n].rev()
776 if r in subset:
777 return [r]
778 return []
779
745 def removes(repo, subset, x): 780 def removes(repo, subset, x):
746 """``removes(pattern)`` 781 """``removes(pattern)``
747 Changesets which remove files matching pattern. 782 Changesets which remove files matching pattern.
748 """ 783 """
749 # i18n: "removes" is a keyword 784 # i18n: "removes" is a keyword
914 "p1": p1, 949 "p1": p1,
915 "p2": p2, 950 "p2": p2,
916 "parents": parents, 951 "parents": parents,
917 "present": present, 952 "present": present,
918 "public": public, 953 "public": public,
954 "remote": remote,
919 "removes": removes, 955 "removes": removes,
920 "rev": rev, 956 "rev": rev,
921 "reverse": reverse, 957 "reverse": reverse,
922 "roots": roots, 958 "roots": roots,
923 "sort": sort, 959 "sort": sort,