mercurial/hg.py
changeset 302 498fb0fa2795
parent 299 7c239fad0f27
child 305 719812eb0156
equal deleted inserted replaced
301:5add718d92db 302:498fb0fa2795
   134                         (f, hex(map[f]), flags[f] and "x" or '')
   134                         (f, hex(map[f]), flags[f] and "x" or '')
   135                         for f in files]
   135                         for f in files]
   136         text = "".join(self.addlist)
   136         text = "".join(self.addlist)
   137 
   137 
   138         n = self.addrevision(text, transaction, link, p1, p2)
   138         n = self.addrevision(text, transaction, link, p1, p2)
   139         self.mapcache = (n, map)
   139         self.mapcache = (n, map, flags)
   140         self.listcache = (text, self.addlist)
   140         self.listcache = (text, self.addlist)
   141         self.addlist = None
   141         self.addlist = None
   142 
   142 
   143         return n
   143         return n
   144 
   144 
   423             raise inst
   423             raise inst
   424 
   424 
   425     def rawcommit(self, files, text, user, date, p1=None, p2=None):
   425     def rawcommit(self, files, text, user, date, p1=None, p2=None):
   426         p1 = p1 or self.dirstate.parents()[0] or nullid
   426         p1 = p1 or self.dirstate.parents()[0] or nullid
   427         p2 = p2 or self.dirstate.parents()[1] or nullid
   427         p2 = p2 or self.dirstate.parents()[1] or nullid
   428         pchange = self.changelog.read(p1)
   428         c1 = self.changelog.read(p1)
   429         pmmap = self.manifest.read(pchange[0])
   429         c2 = self.changelog.read(p2)
       
   430         m1 = self.manifest.read(c1[0])
       
   431         mf1 = self.manifest.readflags(c1[0])
       
   432         m2 = self.manifest.read(c2[0])
       
   433 
   430         tr = self.transaction()
   434         tr = self.transaction()
   431         mmap = {}
   435         mm = m1.copy()
       
   436         mfm = mf1.copy()
   432         linkrev = self.changelog.count()
   437         linkrev = self.changelog.count()
   433         for f in files:
   438         for f in files:
   434             try:
   439             try:
   435                 t = file(f).read()
   440                 t = self.wfile(f).read()
       
   441                 tm = is_exec(self.wjoin(f))
       
   442                 r = self.file(f)
       
   443                 mfm[f] = tm
       
   444                 mm[f] = r.add(t, tr, linkrev,
       
   445                               m1.get(f, nullid), m2.get(f, nullid))
   436             except IOError:
   446             except IOError:
   437                 self.ui.warn("Read file %s error, skipped\n" % f)
   447                 del mm[f]
   438                 continue
   448                 del mfm[f]
   439             r = self.file(f)
   449 
   440             # FIXME - need to find both parents properly
   450         mnode = self.manifest.add(mm, mfm, tr, linkrev, c1[0], c2[0])
   441             prev = pmmap.get(f, nullid)
   451         n = self.changelog.add(mnode, files, text, tr, p1, p2, user, date)
   442             mmap[f] = r.add(t, tr, linkrev, prev)
       
   443 
       
   444         mnode = self.manifest.add(mmap, tr, linkrev, pchange[0])
       
   445         n = self.changelog.add(mnode, files, text, tr, p1, p2, user ,date, )
       
   446         tr.close()
   452         tr.close()
   447         self.dirstate.setparents(p1, p2)
   453         self.dirstate.setparents(p1, p2)
   448         self.dirstate.clear()
   454         self.dirstate.clear()
   449         self.dirstate.update(mmap.keys(), "n")
   455         self.dirstate.update(files, "n")
   450 
   456 
   451     def commit(self, files = None, text = ""):
   457     def commit(self, files = None, text = ""):
   452         commit = []
   458         commit = []
   453         remove = []
   459         remove = []
   454         if files:
   460         if files:
  1063         os.unlink(c)
  1069         os.unlink(c)
  1064 
  1070 
  1065     def verify(self):
  1071     def verify(self):
  1066         filelinkrevs = {}
  1072         filelinkrevs = {}
  1067         filenodes = {}
  1073         filenodes = {}
  1068         manifestchangeset = {}
       
  1069         changesets = revisions = files = 0
  1074         changesets = revisions = files = 0
  1070         errors = 0
  1075         errors = 0
  1071 
  1076 
       
  1077         seen = {}
  1072         self.ui.status("checking changesets\n")
  1078         self.ui.status("checking changesets\n")
  1073         for i in range(self.changelog.count()):
  1079         for i in range(self.changelog.count()):
  1074             changesets += 1
  1080             changesets += 1
  1075             n = self.changelog.node(i)
  1081             n = self.changelog.node(i)
       
  1082             if n in seen:
       
  1083                 self.ui.warn("duplicate changeset at revision %d\n" % i)
       
  1084                 errors += 1
       
  1085             seen[n] = 1
       
  1086             
  1076             for p in self.changelog.parents(n):
  1087             for p in self.changelog.parents(n):
  1077                 if p not in self.changelog.nodemap:
  1088                 if p not in self.changelog.nodemap:
  1078                     self.ui.warn("changeset %s has unknown parent %s\n" %
  1089                     self.ui.warn("changeset %s has unknown parent %s\n" %
  1079                                  (short(n), short(p)))
  1090                                  (short(n), short(p)))
  1080                     errors += 1
  1091                     errors += 1
  1082                 changes = self.changelog.read(n)
  1093                 changes = self.changelog.read(n)
  1083             except Exception, inst:
  1094             except Exception, inst:
  1084                 self.ui.warn("unpacking changeset %s: %s\n" % (short(n), inst))
  1095                 self.ui.warn("unpacking changeset %s: %s\n" % (short(n), inst))
  1085                 errors += 1
  1096                 errors += 1
  1086 
  1097 
  1087             manifestchangeset[changes[0]] = n
       
  1088             for f in changes[3]:
  1098             for f in changes[3]:
  1089                 filelinkrevs.setdefault(f, []).append(i)
  1099                 filelinkrevs.setdefault(f, []).append(i)
  1090 
  1100 
       
  1101         seen = {}
  1091         self.ui.status("checking manifests\n")
  1102         self.ui.status("checking manifests\n")
  1092         for i in range(self.manifest.count()):
  1103         for i in range(self.manifest.count()):
  1093             n = self.manifest.node(i)
  1104             n = self.manifest.node(i)
       
  1105             if n in seen:
       
  1106                 self.ui.warn("duplicate manifest at revision %d\n" % i)
       
  1107                 errors += 1
       
  1108             seen[n] = 1
       
  1109             
  1094             for p in self.manifest.parents(n):
  1110             for p in self.manifest.parents(n):
  1095                 if p not in self.manifest.nodemap:
  1111                 if p not in self.manifest.nodemap:
  1096                     self.ui.warn("manifest %s has unknown parent %s\n" %
  1112                     self.ui.warn("manifest %s has unknown parent %s\n" %
  1097                             (short(n), short(p)))
  1113                             (short(n), short(p)))
  1098                     errors += 1
  1114                     errors += 1
  1099             ca = self.changelog.node(self.manifest.linkrev(n))
       
  1100             cc = manifestchangeset[n]
       
  1101             if ca != cc:
       
  1102                 self.ui.warn("manifest %s points to %s, not %s\n" %
       
  1103                         (hex(n), hex(ca), hex(cc)))
       
  1104                 errors += 1
       
  1105 
  1115 
  1106             try:
  1116             try:
  1107                 delta = mdiff.patchtext(self.manifest.delta(n))
  1117                 delta = mdiff.patchtext(self.manifest.delta(n))
  1108             except KeyboardInterrupt:
  1118             except KeyboardInterrupt:
  1109                 print "aborted"
  1119                 print "aborted"
  1134         for f in ff:
  1144         for f in ff:
  1135             if f == "/dev/null": continue
  1145             if f == "/dev/null": continue
  1136             files += 1
  1146             files += 1
  1137             fl = self.file(f)
  1147             fl = self.file(f)
  1138             nodes = { nullid: 1 }
  1148             nodes = { nullid: 1 }
       
  1149             seen = {}
  1139             for i in range(fl.count()):
  1150             for i in range(fl.count()):
  1140                 revisions += 1
  1151                 revisions += 1
  1141                 n = fl.node(i)
  1152                 n = fl.node(i)
       
  1153 
       
  1154                 if n in seen:
       
  1155                     self.ui.warn("%s: duplicate revision %d\n" % (f, i))
       
  1156                     errors += 1
  1142 
  1157 
  1143                 if n not in filenodes[f]:
  1158                 if n not in filenodes[f]:
  1144                     self.ui.warn("%s: %d:%s not in manifests\n"
  1159                     self.ui.warn("%s: %d:%s not in manifests\n"
  1145                                  % (f, i, short(n)))
  1160                                  % (f, i, short(n)))
  1146                     print len(filenodes[f].keys()), fl.count(), f
  1161                     print len(filenodes[f].keys()), fl.count(), f