Mercurial > public > mercurial-scm > python-hglib
comparison hglib/client.py @ 13:400cb1520834
client: add missing options to import_()
and don't read the file before calling hg, just pass it as one of the arguments
author | Idan Kamara <idankk86@gmail.com> |
---|---|
date | Wed, 10 Aug 2011 00:42:43 +0300 |
parents | c2a9b716cd80 |
children | e0d21c9db20b |
comparison
equal
deleted
inserted
replaced
12:c2a9b716cd80 | 13:400cb1520834 |
---|---|
211 self.server.stdin.write('getencoding\n') | 211 self.server.stdin.write('getencoding\n') |
212 self._encoding = self._readfromchannel('r') | 212 self._encoding = self._readfromchannel('r') |
213 | 213 |
214 return self._encoding | 214 return self._encoding |
215 | 215 |
216 def import_(self, patch): | 216 def import_(self, patches, strip=None, force=False, nocommit=False, |
217 if isinstance(patch, str): | 217 bypass=False, exact=False, importbranch=False, message=None, |
218 fp = open(patch) | 218 date=None, user=None, similarity=None): |
219 """ | |
220 patches can be a list of file names with patches to apply | |
221 or a file-like object that contains a patch (needs read and readline) | |
222 """ | |
223 if hasattr(patches, 'read') and hasattr(patches, 'readline'): | |
224 patch = patches | |
225 | |
226 def readline(size, output): | |
227 return patch.readline(size) | |
228 | |
229 stdin = True | |
230 patches = () | |
231 prompt = readline | |
232 input = patch.read | |
219 else: | 233 else: |
220 assert hasattr(patch, 'read') | 234 stdin = False |
221 assert hasattr(patch, 'readline') | 235 prompt = None |
222 | 236 input = None |
223 fp = patch | 237 |
224 | 238 args = cmdbuilder('import', *patches, strip=strip, force=force, |
225 try: | 239 nocommit=nocommit, bypass=bypass, exact=exact, |
226 def readline(size, output): | 240 importbranch=importbranch, message=message, |
227 return fp.readline(size) | 241 date=date, user=user, similarity=similarity, _=stdin) |
228 | 242 |
229 self.rawcommand(cmdbuilder('import', _=True), | 243 self.rawcommand(args, prompt=prompt, input=input) |
230 prompt=readline, input=fp.read) | |
231 finally: | |
232 if fp != patch: | |
233 fp.close() | |
234 | 244 |
235 def incoming(self, revrange=None, path=None): | 245 def incoming(self, revrange=None, path=None): |
236 args = cmdbuilder('incoming', | 246 args = cmdbuilder('incoming', |
237 path, | 247 path, |
238 template=templates.changeset, rev=revrange) | 248 template=templates.changeset, rev=revrange) |