mercurial/hg.py
changeset 515 03f27b1381f9
parent 514 874e577e332e
child 516 873228c2f6cf
equal deleted inserted replaced
514:874e577e332e 515:03f27b1381f9
   229         while pos < len(st):
   229         while pos < len(st):
   230             e = struct.unpack(">cllll", st[pos:pos+17])
   230             e = struct.unpack(">cllll", st[pos:pos+17])
   231             l = e[4]
   231             l = e[4]
   232             pos += 17
   232             pos += 17
   233             f = st[pos:pos + l]
   233             f = st[pos:pos + l]
   234             if '\0' in f: 
   234             if '\0' in f:
   235                 f, c = f.split('\0')
   235                 f, c = f.split('\0')
   236                 self.copies[f] = c
   236                 self.copies[f] = c
   237             self.map[f] = e[:4]
   237             self.map[f] = e[:4]
   238             pos += l
   238             pos += l
   239 
   239 
   242         self.dirty = 1
   242         self.dirty = 1
   243         self.copies[dest] = source
   243         self.copies[dest] = source
   244 
   244 
   245     def copied(self, file):
   245     def copied(self, file):
   246         return self.copies.get(file, None)
   246         return self.copies.get(file, None)
   247         
   247 
   248     def update(self, files, state):
   248     def update(self, files, state):
   249         ''' current states:
   249         ''' current states:
   250         n  normal
   250         n  normal
   251         m  needs merging
   251         m  needs merging
   252         r  marked for removal
   252         r  marked for removal
   343 
   343 
   344         self.root = path
   344         self.root = path
   345         self.ui = ui
   345         self.ui = ui
   346 
   346 
   347         if create:
   347         if create:
   348             os.mkdir(self.path)  
   348             os.mkdir(self.path)
   349             os.mkdir(self.join("data"))
   349             os.mkdir(self.join("data"))
   350 
   350 
   351         self.opener = opener(self.path)
   351         self.opener = opener(self.path)
   352         self.wopener = opener(self.root)
   352         self.wopener = opener(self.root)
   353         self.manifest = manifest(self.opener)
   353         self.manifest = manifest(self.opener)
   476         try:
   476         try:
   477             ds = self.opener("dirstate").read()
   477             ds = self.opener("dirstate").read()
   478         except IOError:
   478         except IOError:
   479             ds = ""
   479             ds = ""
   480         self.opener("undo.dirstate", "w").write(ds)
   480         self.opener("undo.dirstate", "w").write(ds)
   481         
   481 
   482         return transaction.transaction(self.opener, self.join("journal"),
   482         return transaction.transaction(self.opener, self.join("journal"),
   483                                        self.join("undo"))
   483                                        self.join("undo"))
   484 
   484 
   485     def recover(self):
   485     def recover(self):
   486         lock = self.lock()
   486         lock = self.lock()
   666             return cmp(t1, t2)
   666             return cmp(t1, t2)
   667 
   667 
   668         for dir, subdirs, files in os.walk(path):
   668         for dir, subdirs, files in os.walk(path):
   669             d = dir[len(self.root)+1:]
   669             d = dir[len(self.root)+1:]
   670             if ".hg" in subdirs: subdirs.remove(".hg")
   670             if ".hg" in subdirs: subdirs.remove(".hg")
   671             
   671 
   672             for f in files:
   672             for f in files:
   673                 fn = util.pconvert(os.path.join(d, f))
   673                 fn = util.pconvert(os.path.join(d, f))
   674                 try: s = os.stat(os.path.join(self.root, fn))
   674                 try: s = os.stat(os.path.join(self.root, fn))
   675                 except: continue
   675                 except: continue
   676                 if fn in dc:
   676                 if fn in dc:
   712                 if mf1[fn] != mf2[fn]:
   712                 if mf1[fn] != mf2[fn]:
   713                     changed.append(fn)
   713                     changed.append(fn)
   714                 del mf1[fn]
   714                 del mf1[fn]
   715             else:
   715             else:
   716                 added.append(fn)
   716                 added.append(fn)
   717                 
   717 
   718         deleted = mf1.keys()
   718         deleted = mf1.keys()
   719         deleted.sort()
   719         deleted.sort()
   720     
   720 
   721         return (changed, added, deleted)
   721         return (changed, added, deleted)
   722 
   722 
   723     def add(self, list):
   723     def add(self, list):
   724         for f in list:
   724         for f in list:
   725             p = self.wjoin(f)
   725             p = self.wjoin(f)
   844             self.ui.status("nothing to do!\n")
   844             self.ui.status("nothing to do!\n")
   845             return None
   845             return None
   846 
   846 
   847         rep = {}
   847         rep = {}
   848         reqcnt = 0
   848         reqcnt = 0
   849         
   849 
   850         unknown = remote.branches(unknown)
   850         unknown = remote.branches(unknown)
   851         while unknown:
   851         while unknown:
   852             r = []
   852             r = []
   853             while unknown:
   853             while unknown:
   854                 n = unknown.pop(0)
   854                 n = unknown.pop(0)
   889                     for b in remote.branches(r[p:p+10]):
   889                     for b in remote.branches(r[p:p+10]):
   890                         self.ui.debug("received %s:%s\n" %
   890                         self.ui.debug("received %s:%s\n" %
   891                                       (short(b[0]), short(b[1])))
   891                                       (short(b[0]), short(b[1])))
   892                         if b[0] not in m and b[0] not in seen:
   892                         if b[0] not in m and b[0] not in seen:
   893                             unknown.append(b)
   893                             unknown.append(b)
   894   
   894 
   895         while search:
   895         while search:
   896             n = search.pop(0)
   896             n = search.pop(0)
   897             reqcnt += 1
   897             reqcnt += 1
   898             l = remote.between([(n[0], n[1])])[0]
   898             l = remote.between([(n[0], n[1])])[0]
   899             l.append(n[1])
   899             l.append(n[1])
   967                         self.buf += self.g.next()
   967                         self.buf += self.g.next()
   968                     except StopIteration:
   968                     except StopIteration:
   969                         break
   969                         break
   970                 d, self.buf = self.buf[:l], self.buf[l:]
   970                 d, self.buf = self.buf[:l], self.buf[l:]
   971                 return d
   971                 return d
   972                 
   972 
   973         def getchunk():
   973         def getchunk():
   974             d = source.read(4)
   974             d = source.read(4)
   975             if not d: return ""
   975             if not d: return ""
   976             l = struct.unpack(">l", d)[0]
   976             l = struct.unpack(">l", d)[0]
   977             if l <= 4: return ""
   977             if l <= 4: return ""
  1268             n = self.changelog.node(i)
  1268             n = self.changelog.node(i)
  1269             if n in seen:
  1269             if n in seen:
  1270                 self.ui.warn("duplicate changeset at revision %d\n" % i)
  1270                 self.ui.warn("duplicate changeset at revision %d\n" % i)
  1271                 errors += 1
  1271                 errors += 1
  1272             seen[n] = 1
  1272             seen[n] = 1
  1273             
  1273 
  1274             for p in self.changelog.parents(n):
  1274             for p in self.changelog.parents(n):
  1275                 if p not in self.changelog.nodemap:
  1275                 if p not in self.changelog.nodemap:
  1276                     self.ui.warn("changeset %s has unknown parent %s\n" %
  1276                     self.ui.warn("changeset %s has unknown parent %s\n" %
  1277                                  (short(n), short(p)))
  1277                                  (short(n), short(p)))
  1278                     errors += 1
  1278                     errors += 1
  1291             n = self.manifest.node(i)
  1291             n = self.manifest.node(i)
  1292             if n in seen:
  1292             if n in seen:
  1293                 self.ui.warn("duplicate manifest at revision %d\n" % i)
  1293                 self.ui.warn("duplicate manifest at revision %d\n" % i)
  1294                 errors += 1
  1294                 errors += 1
  1295             seen[n] = 1
  1295             seen[n] = 1
  1296             
  1296 
  1297             for p in self.manifest.parents(n):
  1297             for p in self.manifest.parents(n):
  1298                 if p not in self.manifest.nodemap:
  1298                 if p not in self.manifest.nodemap:
  1299                     self.ui.warn("manifest %s has unknown parent %s\n" %
  1299                     self.ui.warn("manifest %s has unknown parent %s\n" %
  1300                             (short(n), short(p)))
  1300                             (short(n), short(p)))
  1301                     errors += 1
  1301                     errors += 1
  1406         no = ui.config("http_proxy", "no")
  1406         no = ui.config("http_proxy", "no")
  1407         if no is None:
  1407         if no is None:
  1408             no = os.environ.get("no_proxy")
  1408             no = os.environ.get("no_proxy")
  1409         if no:
  1409         if no:
  1410             no_list = no_list + no.split(",")
  1410             no_list = no_list + no.split(",")
  1411             
  1411 
  1412         no_proxy = 0
  1412         no_proxy = 0
  1413         for h in no_list:
  1413         for h in no_list:
  1414             if (path.startswith("http://" + h + "/") or
  1414             if (path.startswith("http://" + h + "/") or
  1415                 path.startswith("http://" + h + ":") or
  1415                 path.startswith("http://" + h + ":") or
  1416                 path == "http://" + h):
  1416                 path == "http://" + h):