comparison hgext/mq.py @ 2712:35caf437a201

mq: fix queue.apply to not call os.chdir() call to os.chdir broke "hg -R dirname qpush". instead pass -d (change directory) option to patch command.
author Vadim Gelfer <vadim.gelfer@gmail.com>
date Thu, 27 Jul 2006 18:24:59 -0700
parents 8e5cd8d11b51
children c91ca61c8953
comparison
equal deleted inserted replaced
2711:8e5cd8d11b51 2712:35caf437a201
274 def apply(self, repo, series, list=False, update_status=True, 274 def apply(self, repo, series, list=False, update_status=True,
275 strict=False, patchdir=None, merge=None, wlock=None): 275 strict=False, patchdir=None, merge=None, wlock=None):
276 # TODO unify with commands.py 276 # TODO unify with commands.py
277 if not patchdir: 277 if not patchdir:
278 patchdir = self.path 278 patchdir = self.path
279 pwd = os.getcwd()
280 os.chdir(repo.root)
281 err = 0 279 err = 0
282 if not wlock: 280 if not wlock:
283 wlock = repo.wlock() 281 wlock = repo.wlock()
284 lock = repo.lock() 282 lock = repo.lock()
285 tr = repo.transaction() 283 tr = repo.transaction()
302 message.append("\nimported patch %s" % patch) 300 message.append("\nimported patch %s" % patch)
303 message = '\n'.join(message) 301 message = '\n'.join(message)
304 302
305 try: 303 try:
306 pp = util.find_in_path('gpatch', os.environ.get('PATH', ''), 'patch') 304 pp = util.find_in_path('gpatch', os.environ.get('PATH', ''), 'patch')
307 f = os.popen("%s -p1 --no-backup-if-mismatch < '%s'" % (pp, pf)) 305 f = os.popen("%s -d '%s' -p1 --no-backup-if-mismatch < '%s'" %
306 (pp, repo.root, pf))
308 except: 307 except:
309 self.ui.warn("patch failed, unable to continue (try -v)\n") 308 self.ui.warn("patch failed, unable to continue (try -v)\n")
310 err = 1 309 err = 1
311 break 310 break
312 files = [] 311 files = []
369 if fuzz and strict: 368 if fuzz and strict:
370 self.ui.warn("fuzz found when applying patch, stopping\n") 369 self.ui.warn("fuzz found when applying patch, stopping\n")
371 err = 1 370 err = 1
372 break 371 break
373 tr.close() 372 tr.close()
374 os.chdir(pwd)
375 return (err, n) 373 return (err, n)
376 374
377 def delete(self, repo, patch): 375 def delete(self, repo, patch):
378 patch = self.lookup(patch, strict=True) 376 patch = self.lookup(patch, strict=True)
379 info = self.isapplied(patch) 377 info = self.isapplied(patch)