##// END OF EJS Templates
revset: add remote() predicate to lookup remote revisions
Matt Mackall -
r15936:878bc4a6 default
parent child Browse files
Show More
@@ -742,6 +742,41 b' def public(repo, subset, x):'
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.
@@ -916,6 +951,7 b' symbols = {'
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,
General Comments 0
You need to be logged in to leave comments. Login now