Kiln » largefiles » largefiles
Clone URL:  

1.8 compat: don't use hg.peer, handle nonexistent batchable attribute

Changeset 3f7c774d4737

Parent d4dadfbc9448

by Profile picture of User 521Andrew Pritchard <andrewp@fogcreek.com>

Changes to 2 files · Browse files at 3f7c774d4737 Showing diff from parent d4dadfbc9448 Diff from another changeset...

 
178
179
180
181
 
182
183
184
 
178
179
180
 
181
182
183
184
@@ -178,7 +178,7 @@
  path = ''   remote = repo   else: - remote = hg.peer(repo, {}, path) + remote = hg.repository(hg.remoteui(ui, {}), path, False)     # The path could be a scheme so use Mercurial's normal functionality   # to resolve the scheme to a repository and use its path
 
114
115
116
117
118
119
120
121
122
123
124
125
126
127
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128
129
130
 
114
115
116
 
 
 
 
 
 
 
 
 
 
 
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
@@ -114,17 +114,30 @@
  # way, consider it missing   return 2   - @wireproto.batchable - def heads(self): - f = wireproto.future() - yield {}, f - d = f.value - if d[:len(_heads_prefix)] == _heads_prefix: - d = d[len(_heads_prefix):] - try: - yield wireproto.decodelist(d[:-1]) - except ValueError: - self._abort(error.ResponseError(_("unexpected response:"), d)) + try: + @wireproto.batchable + def heads(self): + f = wireproto.future() + yield {}, f + d = f.value + if d[:len(_heads_prefix)] == _heads_prefix: + d = d[len(_heads_prefix):] + try: + yield wireproto.decodelist(d[:-1]) + except ValueError: + self._abort(error.ResponseError(_("unexpected response:"), d)) + except AttributeError: + # Mercurial < 1.9 has no @batchable; define a normal wirerepo heads + # command + def heads(self): + d = self._call('heads') + if d[:len(_heads_prefix)] == _heads_prefix: + d = d[len(_heads_prefix):] + try: + return wireproto.decodelist(d[:-1]) + except ValueError: + self._abort(error.ResponseError(_("unexpected response:"), d)) +   repo.__class__ = kbfileswirerepository    # wrap dispatch to check for and remove the kbfiles argument so commands with