Show More
@@ -1645,11 +1645,7 b' def incoming(ui, repo, source="default",' | |||
|
1645 | 1645 | other = hg.repository(ui, source) |
|
1646 | 1646 | ui.status(_('comparing with %s\n') % source) |
|
1647 | 1647 | if revs: |
|
1648 | if 'lookup' in other.capabilities: | |
|
1649 | revs = [other.lookup(rev) for rev in revs] | |
|
1650 | else: | |
|
1651 | error = _("Other repository doesn't support revision lookup, so a rev cannot be specified.") | |
|
1652 | raise util.Abort(error) | |
|
1648 | revs = [other.lookup(rev) for rev in revs] | |
|
1653 | 1649 | incoming = repo.findincoming(other, heads=revs, force=opts["force"]) |
|
1654 | 1650 | if not incoming: |
|
1655 | 1651 | try: |
@@ -1667,8 +1663,6 b' def incoming(ui, repo, source="default",' | |||
|
1667 | 1663 | if revs is None: |
|
1668 | 1664 | cg = other.changegroup(incoming, "incoming") |
|
1669 | 1665 | else: |
|
1670 | if 'changegroupsubset' not in other.capabilities: | |
|
1671 | raise util.Abort(_("Partial incoming cannot be done because other repository doesn't support changegroupsubset.")) | |
|
1672 | 1666 | cg = other.changegroupsubset(incoming, revs, 'incoming') |
|
1673 | 1667 | bundletype = other.local() and "HG10BZ" or "HG10UN" |
|
1674 | 1668 | fname = cleanup = changegroup.writebundle(cg, fname, bundletype) |
@@ -2078,10 +2072,11 b' def pull(ui, repo, source="default", **o' | |||
|
2078 | 2072 | other = hg.repository(ui, source) |
|
2079 | 2073 | ui.status(_('pulling from %s\n') % (source)) |
|
2080 | 2074 | if revs: |
|
2081 | if 'lookup' in other.capabilities: | |
|
2075 | try: | |
|
2082 | 2076 | revs = [other.lookup(rev) for rev in revs] |
|
2083 | else: | |
|
2084 |
error = _("Other repository doesn't support revision lookup, |
|
|
2077 | except repo.NoCapability: | |
|
2078 | error = _("Other repository doesn't support revision lookup, " | |
|
2079 | "so a rev cannot be specified.") | |
|
2085 | 2080 | raise util.Abort(error) |
|
2086 | 2081 | |
|
2087 | 2082 | modheads = repo.pull(other, heads=revs, force=opts['force']) |
@@ -354,6 +354,7 b' class httprepository(remoterepository):' | |||
|
354 | 354 | fp.close() |
|
355 | 355 | |
|
356 | 356 | def lookup(self, key): |
|
357 | self.requirecap('lookup', _('look up remote revision')) | |
|
357 | 358 | d = self.do_cmd("lookup", key = key).read() |
|
358 | 359 | success, data = d[:-1].split(' ', 1) |
|
359 | 360 | if int(success): |
@@ -391,6 +392,7 b' class httprepository(remoterepository):' | |||
|
391 | 392 | return util.chunkbuffer(zgenerator(f)) |
|
392 | 393 | |
|
393 | 394 | def changegroupsubset(self, bases, heads, source): |
|
395 | self.requirecap('changegroupsubset', _('look up remote changes')) | |
|
394 | 396 | baselst = " ".join([hex(n) for n in bases]) |
|
395 | 397 | headlst = " ".join([hex(n) for n in heads]) |
|
396 | 398 | f = self.do_cmd("changegroupsubset", bases=baselst, heads=headlst) |
@@ -9,16 +9,26 b'' | |||
|
9 | 9 | class RepoError(Exception): |
|
10 | 10 | pass |
|
11 | 11 | |
|
12 | class NoCapability(RepoError): | |
|
13 | pass | |
|
14 | ||
|
12 | 15 | class repository(object): |
|
13 | 16 | def capable(self, name): |
|
14 | 17 | '''tell whether repo supports named capability. |
|
15 | 18 | return False if not supported. |
|
16 | 19 | if boolean capability, return True. |
|
17 | 20 | if string capability, return string.''' |
|
21 | if name in self.capabilities: | |
|
22 | return True | |
|
18 | 23 | name_eq = name + '=' |
|
19 | 24 | for cap in self.capabilities: |
|
20 | if name == cap: | |
|
21 | return True | |
|
22 | 25 | if cap.startswith(name_eq): |
|
23 | 26 | return cap[len(name_eq):] |
|
24 | 27 | return False |
|
28 | ||
|
29 | def requirecap(self, name, purpose): | |
|
30 | '''raise an exception if the given capability is not present''' | |
|
31 | if not self.capable(name): | |
|
32 | raise NoCapability(_('cannot %s; remote repository does not ' | |
|
33 | 'support the %r capability') % | |
|
34 | (purpose, name)) |
@@ -131,6 +131,7 b' class sshrepository(remoterepository):' | |||
|
131 | 131 | self.call("unlock") |
|
132 | 132 | |
|
133 | 133 | def lookup(self, key): |
|
134 | self.requirecap('lookup', _('look up remote revision')) | |
|
134 | 135 | d = self.call("lookup", key=key) |
|
135 | 136 | success, data = d[:-1].split(" ", 1) |
|
136 | 137 | if int(success): |
@@ -168,6 +169,7 b' class sshrepository(remoterepository):' | |||
|
168 | 169 | return self.do_cmd("changegroup", roots=n) |
|
169 | 170 | |
|
170 | 171 | def changegroupsubset(self, bases, heads, kind): |
|
172 | self.requirecap('changegroupsubset', _('look up remote changes')) | |
|
171 | 173 | bases = " ".join(map(hex, bases)) |
|
172 | 174 | heads = " ".join(map(hex, heads)) |
|
173 | 175 | return self.do_cmd("changegroupsubset", bases=bases, heads=heads) |
General Comments 0
You need to be logged in to leave comments.
Login now