comparison hgext/mq.py @ 11303:a1aad8333864

move working dir/dirstate methods from localrepo to workingctx
author Dirkjan Ochtman <dirkjan@ochtman.nl>
date Mon, 07 Jun 2010 20:03:32 +0200
parents e1dde7363601
children 7f72031d4047
comparison
equal deleted inserted replaced
11302:e1dde7363601 11303:a1aad8333864
703 703
704 def _cleanup(self, patches, numrevs, keep=False): 704 def _cleanup(self, patches, numrevs, keep=False):
705 if not keep: 705 if not keep:
706 r = self.qrepo() 706 r = self.qrepo()
707 if r: 707 if r:
708 r.remove(patches, True) 708 r[None].remove(patches, True)
709 else: 709 else:
710 for p in patches: 710 for p in patches:
711 os.unlink(self.join(p)) 711 os.unlink(self.join(p))
712 712
713 if numrevs: 713 if numrevs:
872 p.close() 872 p.close()
873 wlock.release() 873 wlock.release()
874 wlock = None 874 wlock = None
875 r = self.qrepo() 875 r = self.qrepo()
876 if r: 876 if r:
877 r.add([patchfn]) 877 r[None].add([patchfn])
878 except: 878 except:
879 repo.rollback() 879 repo.rollback()
880 raise 880 raise
881 except Exception: 881 except Exception:
882 patchpath = self.join(patchfn) 882 patchpath = self.join(patchfn)
1711 added.append(patchname) 1711 added.append(patchname)
1712 patchname = None 1712 patchname = None
1713 self.series_dirty = 1 1713 self.series_dirty = 1
1714 qrepo = self.qrepo() 1714 qrepo = self.qrepo()
1715 if qrepo: 1715 if qrepo:
1716 qrepo.add(added) 1716 qrepo[None].add(added)
1717 1717
1718 def delete(ui, repo, *patches, **opts): 1718 def delete(ui, repo, *patches, **opts):
1719 """remove patches from queue 1719 """remove patches from queue
1720 1720
1721 The patches must not be applied, and at least one patch is required. With 1721 The patches must not be applied, and at least one patch is required. With
1830 fp.write('status\n') 1830 fp.write('status\n')
1831 fp.write('guards\n') 1831 fp.write('guards\n')
1832 fp.close() 1832 fp.close()
1833 if not os.path.exists(r.wjoin('series')): 1833 if not os.path.exists(r.wjoin('series')):
1834 r.wopener('series', 'w').close() 1834 r.wopener('series', 'w').close()
1835 r.add(['.hgignore', 'series']) 1835 r[None].add(['.hgignore', 'series'])
1836 commands.add(ui, r) 1836 commands.add(ui, r)
1837 return 0 1837 return 0
1838 1838
1839 def init(ui, repo, **opts): 1839 def init(ui, repo, **opts):
1840 """init a new queue repository (DEPRECATED) 1840 """init a new queue repository (DEPRECATED)
2306 q.applied_dirty = 1 2306 q.applied_dirty = 1
2307 2307
2308 util.rename(q.join(patch), absdest) 2308 util.rename(q.join(patch), absdest)
2309 r = q.qrepo() 2309 r = q.qrepo()
2310 if r: 2310 if r:
2311 wctx = r[None]
2311 wlock = r.wlock() 2312 wlock = r.wlock()
2312 try: 2313 try:
2313 if r.dirstate[patch] == 'a': 2314 if r.dirstate[patch] == 'a':
2314 r.dirstate.forget(patch) 2315 r.dirstate.forget(patch)
2315 r.dirstate.add(name) 2316 r.dirstate.add(name)
2316 else: 2317 else:
2317 if r.dirstate[name] == 'r': 2318 if r.dirstate[name] == 'r':
2318 r.undelete([name]) 2319 wctx.undelete([name])
2319 r.copy(patch, name) 2320 wctx.copy(patch, name)
2320 r.remove([patch], False) 2321 wctx.remove([patch], False)
2321 finally: 2322 finally:
2322 wlock.release() 2323 wlock.release()
2323 2324
2324 q.save_dirty() 2325 q.save_dirty()
2325 2326