Lines Matching refs:self
95 def __init__(self, msg, name): argument
106 util.Abort.__init__(self, "%s: changeset '%s' is missing\n"
117 def __init__(self, *args, **kwargs): argument
118 tarfile.TarFile.__init__(self, *args, **kwargs)
119 self.errorlevel = 2
121 def members_match_fs(self, rootpath): argument
155 for elt in self:
161 def addfilectx(self, filectx, path=None): argument
205 self.addfile(t, data)
211 def __init__(self, backup, ws): argument
212 self.ws = ws
213 self.bu = backup
214 self.files = ('bundle', 'nodes')
216 def _outgoing_nodes(self, parent): argument
220 outgoing = self.ws.findoutgoing(parent)
221 nodes = self.ws.repo.changelog.nodesbetween(outgoing)[0]
226 def backup(self): argument
228 parent = self.ws.parent()
231 self.ws.ui.warn('Workspace has no parent, committed changes will '
235 out = self.ws.findoutgoing(parent)
239 cg = self.ws.repo.changegroup(out, 'bundle')
240 changegroup.writebundle(cg, self.bu.backupfile('bundle'), 'HG10BZ')
242 outnodes = self._outgoing_nodes(parent)
249 fp = self.bu.open('nodes', 'w')
257 def restore(self): argument
260 if not self.bu.exists('bundle'):
263 bpath = self.bu.backupfile('bundle')
267 f = self.bu.open('bundle')
269 self.ws.repo.addchangegroup(bundle, 'strip',
281 def need_backup(self): argument
284 if self.bu.exists('nodes'):
288 f = self.bu.open('nodes')
299 outnodes = set(self._outgoing_nodes(self.ws.parent()))
311 def cleanup(self): argument
314 for f in self.files:
315 self.bu.unlink(f)
321 def __init__(self, backup, ws): argument
322 self.ws = ws
323 self.bu = backup
324 self.wctx = self.ws.workingctx(worklist=True)
326 def _clobbering_renames(self): argument
335 parent = self.wctx.parents()[0]
338 for fname in self.wctx.added() + self.wctx.modified():
339 rn = self.wctx.filectx(fname).renamed()
344 def backup(self): argument
347 if self.ws.merged():
351 dirstate = node.hex(self.wctx.parents()[0].node())
356 fp = self.bu.open('dirstate', 'w')
363 fp = self.bu.open('renames', 'w')
364 for cons in self._clobbering_renames():
371 fp = self.bu.open('diff', 'w')
372 match = self.ws.matcher(files=self.wctx.files())
373 fp.write(self.ws.diff(opts={'git': True}, match=match))
380 def _dirstate(self): argument
385 fp = self.bu.open('dirstate')
395 def restore(self): argument
397 dirstate = self._dirstate()
404 self.ws.repo.changelog.lookup(n)
410 self.ws.clean(rev=dirstate)
414 if not self.bu.exists('diff'):
431 diff = self.bu.backupfile('diff')
433 fuzz = patch.patch(diff, self.ws.ui, strip=1,
434 cwd=self.ws.repo.root, files=files)
442 cmdutil.updatedir(self.ws.ui, self.ws.repo, files)
444 patch.updatedir(self.ws.ui, self.ws.repo, files)
446 if not self.bu.exists('renames'):
455 fp = self.bu.open('renames')
458 self.ws.copy(source, dest)
463 self.bu.backupfile('renames'))
465 def need_backup(self): argument
467 cnode = self.wctx.parents()[0].node()
468 if self._dirstate() != node.hex(cnode):
472 match = self.ws.matcher(files=self.wctx.files())
473 curdiff = self.ws.diff(opts={'git': True}, match=match)
476 if self.bu.exists('diff'):
478 fd = self.bu.open('diff')
483 " %s" % (self.bu.backupfile('diff'), e))
490 currrenamed = self._clobbering_renames()
493 if self.bu.exists('renames'):
495 fd = self.bu.open('renames')
500 (self.bu.backupfile('renames'), e))
510 def cleanup(self): argument
514 self.bu.unlink(f)
520 def __init__(self, backup, ws): argument
521 self.bu = backup
522 self.ws = ws
523 self.files = ('hgrc', 'localtags', 'patches', 'cdm')
525 def backup(self): argument
528 tarpath = self.bu.backupfile('metadata.tar.gz')
535 zip(self.files, map(self.ws.repo.join, self.files)))
565 def old_restore(self): argument
568 for fname in self.files:
569 if self.bu.exists(fname):
570 bfile = self.bu.backupfile(fname)
571 wfile = self.ws.repo.join(fname)
579 def tar_restore(self): argument
582 if not self.bu.exists('metadata.tar.gz'):
585 tarpath = self.bu.backupfile('metadata.tar.gz')
595 tar.extract(elt, path=self.ws.repo.path)
610 def restore(self): argument
613 if self.bu.exists('hgrc'):
614 self.old_restore()
616 self.tar_restore()
618 def _walk(self): argument
622 for elt in self.files:
623 path = self.ws.repo.join(elt)
637 def need_backup(self): argument
644 if self.bu.exists('metadata.tar.gz'):
645 tarpath = self.bu.backupfile('metadata.tar.gz')
652 if not tar.members_match_fs(self.ws.repo.path):
661 repopath = self.ws.repo.path
665 for path in self._walk():
671 def cleanup(self): argument
673 self.bu.unlink('metadata.tar.gz')
688 def __init__(self, backup, ws): argument
689 self.bu = backup
690 self.ws = ws
692 def _branch_pairs(self): argument
698 parent = self.ws.parent()
701 outgoing = self.ws.findoutgoing(parent)
702 outnodes = set(self.ws.repo.changelog.nodesbetween(outgoing)[0])
704 heads = [self.ws.repo.changectx(n) for n in self.ws.repo.heads()
710 wctx = self.ws.workingctx()
721 pairs.append((self.ws.parenttip(c, outnodes), head))
724 def backup(self): argument
729 tarpath = self.bu.backupfile('clear.tar.gz')
730 branches = self._branch_pairs()
745 for fname, change in self.ws.status(parent, child).iteritems():
761 def cleanup(self): argument
767 self.bu.unlink('clear.tar.gz')
769 def restore(self): argument
773 def need_backup(self): argument
786 def __init__(self, ui, ws, name): argument
787 self.ws = ws
788 self.ui = ui
789 self.backupdir = self._find_backup_dir(name)
802 self.modules = [x(self, ws) for x in [CdmCommittedBackup,
807 if os.path.exists(os.path.join(self.backupdir, 'latest')):
808 generation = os.readlink(os.path.join(self.backupdir, 'latest'))
809 self.generation = int(os.path.split(generation)[1])
811 self.generation = 0
813 def _find_backup_dir(self, name): argument
819 if self.ui.config('cdm', 'backupdir'):
820 backupbase = os.path.expanduser(self.ui.config('cdm', 'backupdir'))
843 def _update_latest(self, gen): argument
845 linkpath = os.path.join(self.backupdir, 'latest')
852 def _create_gen(self, gen): argument
855 os.makedirs(os.path.join(self.backupdir, str(gen)))
856 self._update_latest(gen)
859 (os.path.join(self.backupdir, str(gen)), e))
861 def backupfile(self, path): argument
863 return os.path.join(self.backupdir, str(self.generation), path)
865 def unlink(self, name): argument
870 fpath = self.backupfile(name)
874 def open(self, name, mode='r'): argument
876 return open(self.backupfile(name), mode)
878 def exists(self, name): argument
881 return os.path.exists(self.backupfile(name))
883 def need_backup(self): argument
890 if not self.generation or not self.exists('dirstate'):
893 for x in self.modules:
899 def backup(self): argument
905 if not os.path.exists(self.backupdir):
907 os.makedirs(self.backupdir)
910 (self.backupdir, e))
912 self.generation += 1
913 self._create_gen(self.generation)
916 for x in self.modules:
920 self.ws.ui.warn("Interrupted\n")
922 self.ws.ui.warn("Error: %s\n" % e)
923 show_traceback = self.ws.ui.configbool('ui', 'traceback',
935 for x in self.modules:
938 os.rmdir(os.path.join(self.backupdir, str(self.generation)))
939 self.generation -= 1
941 if self.generation != 0:
942 self._update_latest(self.generation)
944 os.unlink(os.path.join(self.backupdir, 'latest'))
948 def restore(self, gen=None): argument
957 if not os.path.exists(self.backupdir):
959 (self.backupdir))
962 if not os.path.exists(os.path.join(self.backupdir, str(gen))):
964 (os.path.join(self.backupdir, str(gen))))
965 self.generation = int(gen)
967 if not self.generation: # This is OK, 0 is not a valid generation
968 raise util.Abort('Backup has no generations: %s' % self.backupdir)
970 if not self.exists('dirstate'):
972 (self.backupdir, self.generation))
975 for x in self.modules: