14 demandload(globals(), "bisect select") |
14 demandload(globals(), "bisect select") |
15 |
15 |
16 class filelog(revlog): |
16 class filelog(revlog): |
17 def __init__(self, opener, path): |
17 def __init__(self, opener, path): |
18 revlog.__init__(self, opener, |
18 revlog.__init__(self, opener, |
19 os.path.join("data", path + ".i"), |
19 os.path.join("data", self.encodedir(path + ".i")), |
20 os.path.join("data", path + ".d")) |
20 os.path.join("data", self.encodedir(path + ".d"))) |
|
21 |
|
22 # This avoids a collision between a file named foo and a dir named |
|
23 # foo.i or foo.d |
|
24 def encodedir(self, path): |
|
25 path.replace(".hg/", ".hg.hg/") |
|
26 path.replace(".i/", ".i.hg/") |
|
27 path.replace(".d/", ".i.hg/") |
|
28 return path |
|
29 |
|
30 def decodedir(self, path): |
|
31 path.replace(".d.hg/", ".d/") |
|
32 path.replace(".i.hg/", ".i/") |
|
33 path.replace(".hg.hg/", ".hg/") |
|
34 return path |
21 |
35 |
22 def read(self, node): |
36 def read(self, node): |
23 t = self.revision(node) |
37 t = self.revision(node) |
24 if not t.startswith('\1\n'): |
38 if not t.startswith('\1\n'): |
25 return t |
39 return t |
673 # save dirstate for undo |
687 # save dirstate for undo |
674 try: |
688 try: |
675 ds = self.opener("dirstate").read() |
689 ds = self.opener("dirstate").read() |
676 except IOError: |
690 except IOError: |
677 ds = "" |
691 ds = "" |
678 self.opener("undo.dirstate", "w").write(ds) |
692 self.opener("journal.dirstate", "w").write(ds) |
679 |
693 |
680 return transaction.transaction(self.ui.warn, |
694 def after(): |
681 self.opener, self.join("journal"), |
695 util.rename(self.join("journal"), self.join("undo")) |
682 self.join("undo")) |
696 util.rename(self.join("journal.dirstate"), |
|
697 self.join("undo.dirstate")) |
|
698 |
|
699 return transaction.transaction(self.ui.warn, self.opener, |
|
700 self.join("journal"), after) |
683 |
701 |
684 def recover(self): |
702 def recover(self): |
685 lock = self.lock() |
703 lock = self.lock() |
686 if os.path.exists(self.join("journal")): |
704 if os.path.exists(self.join("journal")): |
687 self.ui.status("rolling back interrupted transaction\n") |
705 self.ui.status("rolling back interrupted transaction\n") |
957 else: |
975 else: |
958 self.dirstate.update([f], "r") |
976 self.dirstate.update([f], "r") |
959 |
977 |
960 def copy(self, source, dest): |
978 def copy(self, source, dest): |
961 p = self.wjoin(dest) |
979 p = self.wjoin(dest) |
962 if not os.path.exists(dest): |
980 if not os.path.exists(p): |
963 self.ui.warn("%s does not exist!\n" % dest) |
981 self.ui.warn("%s does not exist!\n" % dest) |
964 elif not os.path.isfile(dest): |
982 elif not os.path.isfile(p): |
965 self.ui.warn("copy failed: %s is not a file\n" % dest) |
983 self.ui.warn("copy failed: %s is not a file\n" % dest) |
966 else: |
984 else: |
967 if self.dirstate.state(dest) == '?': |
985 if self.dirstate.state(dest) == '?': |
968 self.dirstate.update([dest], "a") |
986 self.dirstate.update([dest], "a") |
969 self.dirstate.copy(source, dest) |
987 self.dirstate.copy(source, dest) |
1276 self.ui.status("adding manifests\n") |
1294 self.ui.status("adding manifests\n") |
1277 mm = self.manifest.tip() |
1295 mm = self.manifest.tip() |
1278 mo = self.manifest.addgroup(getgroup(), revmap, tr) |
1296 mo = self.manifest.addgroup(getgroup(), revmap, tr) |
1279 |
1297 |
1280 # process the files |
1298 # process the files |
1281 self.ui.status("adding file revisions\n") |
1299 self.ui.status("adding file changes\n") |
1282 while 1: |
1300 while 1: |
1283 f = getchunk() |
1301 f = getchunk() |
1284 if not f: break |
1302 if not f: break |
1285 self.ui.debug("adding %s revisions\n" % f) |
1303 self.ui.debug("adding %s revisions\n" % f) |
1286 fl = self.file(f) |
1304 fl = self.file(f) |
1287 o = fl.count() |
1305 o = fl.count() |
1288 n = fl.addgroup(getgroup(), revmap, tr) |
1306 n = fl.addgroup(getgroup(), revmap, tr) |
1289 revisions += fl.count() - o |
1307 revisions += fl.count() - o |
1290 files += 1 |
1308 files += 1 |
1291 |
1309 |
1292 self.ui.status(("modified %d files, added %d changesets" + |
1310 self.ui.status(("added %d changesets" + |
1293 " and %d new revisions\n") |
1311 " with %d changes to %d files\n") |
1294 % (files, changesets, revisions)) |
1312 % (changesets, revisions, files)) |
1295 |
1313 |
1296 tr.close() |
1314 tr.close() |
|
1315 |
|
1316 if not self.hook("changegroup"): |
|
1317 return 1 |
|
1318 |
1297 return |
1319 return |
1298 |
1320 |
1299 def update(self, node, allow=False, force=False, choose=None, |
1321 def update(self, node, allow=False, force=False, choose=None, |
1300 moddirstate=True): |
1322 moddirstate=True): |
1301 pl = self.dirstate.parents() |
1323 pl = self.dirstate.parents() |