hgext/git/dirstate.py
branchstable
changeset 47772 0bdcb5ef932c
parent 47539 84391ddf4c78
child 48385 080151f18f3a
equal deleted inserted replaced
47771:03089463c554 47772:0bdcb5ef932c
    72     def __init__(self, ui, root, gitrepo):
    72     def __init__(self, ui, root, gitrepo):
    73         self._ui = ui
    73         self._ui = ui
    74         self._root = os.path.dirname(root)
    74         self._root = os.path.dirname(root)
    75         self.git = gitrepo
    75         self.git = gitrepo
    76         self._plchangecallbacks = {}
    76         self._plchangecallbacks = {}
       
    77         # TODO: context.poststatusfixup is bad and uses this attribute
       
    78         self._dirty = False
    77 
    79 
    78     def p1(self):
    80     def p1(self):
    79         try:
    81         try:
    80             return self.git.head.peel().id.raw
    82             return self.git.head.peel().id.raw
    81         except pygit2.GitError:
    83         except pygit2.GitError:
   253         for x in self.git.index:
   255         for x in self.git.index:
   254             p = pycompat.fsencode(x.path)
   256             p = pycompat.fsencode(x.path)
   255             if match(p):
   257             if match(p):
   256                 yield p
   258                 yield p
   257 
   259 
   258     def normal(self, f, parentfiledata=None):
   260     def set_clean(self, f, parentfiledata=None):
   259         """Mark a file normal and clean."""
   261         """Mark a file normal and clean."""
   260         # TODO: for now we just let libgit2 re-stat the file. We can
   262         # TODO: for now we just let libgit2 re-stat the file. We can
   261         # clearly do better.
   263         # clearly do better.
   262 
   264 
   263     def normallookup(self, f):
   265     def set_possibly_dirty(self, f):
   264         """Mark a file normal, but possibly dirty."""
   266         """Mark a file normal, but possibly dirty."""
   265         # TODO: for now we just let libgit2 re-stat the file. We can
   267         # TODO: for now we just let libgit2 re-stat the file. We can
   266         # clearly do better.
   268         # clearly do better.
   267 
   269 
   268     def walk(self, match, subrepos, unknown, ignored, full=True):
   270     def walk(self, match, subrepos, unknown, ignored, full=True):
   294 
   296 
   295     def restorebackup(self, tr, backupname):
   297     def restorebackup(self, tr, backupname):
   296         # TODO: figure out a strategy for saving index backups.
   298         # TODO: figure out a strategy for saving index backups.
   297         pass
   299         pass
   298 
   300 
       
   301     def set_tracked(self, f):
       
   302         uf = pycompat.fsdecode(f)
       
   303         if uf in self.git.index:
       
   304             return False
       
   305         index = self.git.index
       
   306         index.read()
       
   307         index.add(uf)
       
   308         index.write()
       
   309         return True
       
   310 
   299     def add(self, f):
   311     def add(self, f):
   300         index = self.git.index
   312         index = self.git.index
   301         index.read()
   313         index.read()
   302         index.add(pycompat.fsdecode(f))
   314         index.add(pycompat.fsdecode(f))
   303         index.write()
   315         index.write()
   308         fs = pycompat.fsdecode(f)
   320         fs = pycompat.fsdecode(f)
   309         if fs in index:
   321         if fs in index:
   310             index.remove(fs)
   322             index.remove(fs)
   311             index.write()
   323             index.write()
   312 
   324 
       
   325     def set_untracked(self, f):
       
   326         index = self.git.index
       
   327         index.read()
       
   328         fs = pycompat.fsdecode(f)
       
   329         if fs in index:
       
   330             index.remove(fs)
       
   331             index.write()
       
   332             return True
       
   333         return False
       
   334 
   313     def remove(self, f):
   335     def remove(self, f):
   314         index = self.git.index
   336         index = self.git.index
   315         index.read()
   337         index.read()
   316         index.remove(pycompat.fsdecode(f))
   338         index.remove(pycompat.fsdecode(f))
   317         index.write()
   339         index.write()
   319     def copied(self, path):
   341     def copied(self, path):
   320         # TODO: track copies?
   342         # TODO: track copies?
   321         return None
   343         return None
   322 
   344 
   323     def prefetch_parents(self):
   345     def prefetch_parents(self):
       
   346         # TODO
       
   347         pass
       
   348 
       
   349     def update_file(self, *args, **kwargs):
   324         # TODO
   350         # TODO
   325         pass
   351         pass
   326 
   352 
   327     @contextlib.contextmanager
   353     @contextlib.contextmanager
   328     def parentchange(self):
   354     def parentchange(self):