mercurial/hg.py
changeset 561 cdddf4652aec
parent 557 b9fee419a1bd
child 566 b2c9b36bd639
equal deleted inserted replaced
560:f9ad1a2c72eb 561:cdddf4652aec
    93         revlog.__init__(self, opener, "00manifest.i", "00manifest.d")
    93         revlog.__init__(self, opener, "00manifest.i", "00manifest.d")
    94 
    94 
    95     def read(self, node):
    95     def read(self, node):
    96         if node == nullid: return {} # don't upset local cache
    96         if node == nullid: return {} # don't upset local cache
    97         if self.mapcache and self.mapcache[0] == node:
    97         if self.mapcache and self.mapcache[0] == node:
    98             return self.mapcache[1].copy()
    98             return self.mapcache[1]
    99         text = self.revision(node)
    99         text = self.revision(node)
   100         map = {}
   100         map = {}
   101         flag = {}
   101         flag = {}
   102         self.listcache = (text, text.splitlines(1))
   102         self.listcache = (text, text.splitlines(1))
   103         for l in self.listcache[1]:
   103         for l in self.listcache[1]:
   685         self.dirstate.update(new, "n")
   685         self.dirstate.update(new, "n")
   686         self.dirstate.forget(remove)
   686         self.dirstate.forget(remove)
   687 
   687 
   688     def changes(self, node1, node2, files=None):
   688     def changes(self, node1, node2, files=None):
   689         # changed, added, deleted, unknown
   689         # changed, added, deleted, unknown
   690         c, a, d, u, mf1 = [], [], [], [], None
   690         c, a, d, u, mf2 = [], [], [], [], None
   691 
   691 
   692         def fcmp(fn, mf):
   692         def fcmp(fn, mf):
   693             t1 = self.wfile(fn).read()
   693             t1 = self.wfile(fn).read()
   694             t2 = self.file(fn).revision(mf[fn])
   694             t2 = self.file(fn).revision(mf[fn])
   695             return cmp(t1, t2)
   695             return cmp(t1, t2)
   696 
   696 
   697         # are we comparing the working directory?
   697         # are we comparing the working directory?
   698         if not node1:
   698         if not node2:
   699             l, c, a, d, u = self.dirstate.changes(files, self.ignore)
   699             l, c, a, d, u = self.dirstate.changes(files, self.ignore)
   700 
   700 
   701             # are we comparing working dir against its parent?
   701             # are we comparing working dir against its parent?
   702             if not node2:
   702             if not node1:
   703                 if l:
   703                 if l:
   704                     # do a full compare of any files that might have changed
   704                     # do a full compare of any files that might have changed
   705                     change = self.changelog.read(self.dirstate.parents()[0])
   705                     change = self.changelog.read(self.dirstate.parents()[0])
   706                     mf1 = self.manifest.read(change[0])
   706                     mf2 = self.manifest.read(change[0])
   707                     for f in l:
   707                     for f in l:
   708                         if fcmp(f, mf1):
   708                         if fcmp(f, mf2):
   709                             c.append(f)
   709                             c.append(f)
       
   710 
       
   711                 for l in c, a, d, u:
       
   712                     l.sort()
       
   713 
   710                 return (c, a, d, u)
   714                 return (c, a, d, u)
   711 
   715 
   712         # are we comparing working dir against non-tip?
   716         # are we comparing working dir against non-tip?
   713         # generate a pseudo-manifest for the working dir
   717         # generate a pseudo-manifest for the working dir
   714         if not node1:
   718         if not node2:
   715             if not mf1:
   719             if not mf2:
   716                 change = self.changelog.read(self.dirstate.parents()[0])
   720                 change = self.changelog.read(self.dirstate.parents()[0])
   717                 mf1 = self.manifest.read(change[0])
   721                 mf2 = self.manifest.read(change[0]).copy()
   718             for f in a + c + l:
   722             for f in a + c + l:
   719                 mf1[f] = ""
   723                 mf2[f] = ""
   720             for f in d:
   724             for f in d:
   721                 if f in mf1: del mf1[f]
   725                 if f in mf2: del mf2[f]
   722         else:
   726         else:
   723             change = self.changelog.read(node1)
   727             change = self.changelog.read(node2)
   724             mf1 = self.manifest.read(change[0])
   728             mf2 = self.manifest.read(change[0])
   725 
   729 
   726         change = self.changelog.read(node2)
   730         change = self.changelog.read(node1)
   727         mf2 = self.manifest.read(change[0])
   731         mf1 = self.manifest.read(change[0]).copy()
   728 
   732 
   729         for fn in mf2:
   733         for fn in mf2:
   730             if mf1.has_key(fn):
   734             if mf1.has_key(fn):
   731                 if mf1[fn] != mf2[fn]:
   735                 if mf1[fn] != mf2[fn]:
   732                     if mf1[fn] != "" or fcmp(fn, mf2):
   736                     if mf2[fn] != "" or fcmp(fn, mf1):
   733                         c.append(fn)
   737                         c.append(fn)
   734                 del mf1[fn]
   738                 del mf1[fn]
   735             else:
   739             else:
   736                 a.append(fn)
   740                 a.append(fn)
   737 
   741 
   738         d = mf1.keys()
   742         d = mf1.keys()
   739         d.sort()
   743 
       
   744         for l in c, a, d, u:
       
   745             l.sort()
   740 
   746 
   741         return (c, a, d, u)
   747         return (c, a, d, u)
   742 
   748 
   743     def add(self, list):
   749     def add(self, list):
   744         for f in list:
   750         for f in list: