mercurial/hg.py
changeset 29 4d3a5dcb6972
parent 25 daa724b27300
child 30 12f598340423
equal deleted inserted replaced
28:9f64ee817199 29:4d3a5dcb6972
   406         edittext = self.ui.edit(edittext)
   406         edittext = self.ui.edit(edittext)
   407         n = self.changelog.add(node, new, edittext, tr, co, cn)
   407         n = self.changelog.add(node, new, edittext, tr, co, cn)
   408 
   408 
   409         tr.close()
   409         tr.close()
   410 
   410 
   411     def commit(self, update = None, text = ""):
   411     def commit(self, update = None, parent, text = ""):
   412         tr = self.transaction()
   412         tr = self.transaction()
   413         
   413         
   414         try:
   414         try:
   415             remove = [ l[:-1] for l in self.opener("to-remove") ]
   415             remove = [ l[:-1] for l in self.opener("to-remove") ]
   416             os.unlink(self.join("to-remove"))
   416             os.unlink(self.join("to-remove"))
   417 
   417 
   418         except IOError:
   418         except IOError:
   419             remove = []
   419             remove = []
   420 
   420 
   421         if update == None:
   421         if update == None:
   422             update = self.diffdir(self.root)[0]
   422             update = self.diffdir(self.root, parent)[0]
   423 
   423 
   424         # check in files
   424         # check in files
   425         new = {}
   425         new = {}
   426         linkrev = self.changelog.count()
   426         linkrev = self.changelog.count()
   427         for f in update:
   427         for f in update:
   482 
   482 
   483         self.setcurrent(node)
   483         self.setcurrent(node)
   484         self.dircache.clear()
   484         self.dircache.clear()
   485         self.dircache.update(l)
   485         self.dircache.update(l)
   486 
   486 
   487     def diffdir(self, path):
   487     def diffdir(self, path, changeset):
   488         dc = self.dircache.copy()
       
   489         changed = []
   488         changed = []
   490         mf = {}
   489         mf = {}
   491         added = []
   490         added = []
   492 
   491 
   493         if self.current:
   492         if changeset:
   494             change = self.changelog.read(self.current)
   493             change = self.changelog.read(changeset)
   495             mf = self.manifest.read(change[0])
   494             mf = self.manifest.read(change[0])
       
   495 
       
   496         if changeset == self.current:
       
   497             dc = self.dircache.copy()
       
   498         else:
       
   499             dc = dict.fromkeys(mf)
       
   500 
       
   501         def fcmp(fn):
       
   502             t1 = file(fn).read()
       
   503             t2 = self.file(fn).revision(mf[fn])
       
   504             return cmp(t1, t2)
   496 
   505 
   497         for dir, subdirs, files in os.walk(self.root):
   506         for dir, subdirs, files in os.walk(self.root):
   498             d = dir[len(self.root)+1:]
   507             d = dir[len(self.root)+1:]
   499             if ".hg" in subdirs: subdirs.remove(".hg")
   508             if ".hg" in subdirs: subdirs.remove(".hg")
   500             
   509             
   503                 try: s = os.stat(fn)
   512                 try: s = os.stat(fn)
   504                 except: continue
   513                 except: continue
   505                 if fn in dc:
   514                 if fn in dc:
   506                     c = dc[fn]
   515                     c = dc[fn]
   507                     del dc[fn]
   516                     del dc[fn]
       
   517                     if not c:
       
   518                         if fcmp(fn):
       
   519                             changed.append(fn)
   508                     if c[1] != s.st_size:
   520                     if c[1] != s.st_size:
   509                         changed.append(fn)
   521                         changed.append(fn)
   510                     elif c[0] != s.st_mode or c[2] != s.st_mtime:
   522                     elif c[0] != s.st_mode or c[2] != s.st_mtime:
   511                         t1 = file(fn).read()
   523                         if fcmp(fn):
   512                         t2 = self.file(fn).revision(mf[fn])
       
   513                         if t1 != t2:
       
   514                             changed.append(fn)
   524                             changed.append(fn)
   515                 else:
   525                 else:
   516                     if self.ignore(fn): continue
   526                     if self.ignore(fn): continue
   517                     added.append(fn)
   527                     added.append(fn)
   518 
   528