Show More
@@ -26,7 +26,7 b' class convert_mercurial(converter_sink):' | |||||
26 |
|
26 | |||
27 | def putfile(self, f, e, data): |
|
27 | def putfile(self, f, e, data): | |
28 | self.repo.wwrite(f, data, e) |
|
28 | self.repo.wwrite(f, data, e) | |
29 |
if self.repo.dirstate |
|
29 | if f not in self.repo.dirstate: | |
30 | self.repo.dirstate.add(f) |
|
30 | self.repo.dirstate.add(f) | |
31 |
|
31 | |||
32 | def copyfile(self, source, dest): |
|
32 | def copyfile(self, source, dest): |
@@ -240,7 +240,7 b' def sign(ui, repo, *revs, **opts):' | |||||
240 |
|
240 | |||
241 | repo.wfile(".hgsigs", "ab").write(sigmessage) |
|
241 | repo.wfile(".hgsigs", "ab").write(sigmessage) | |
242 |
|
242 | |||
243 | if repo.dirstate.state(".hgsigs") == '?': |
|
243 | if '.hgsigs' not in repo.dirstate: | |
244 | repo.add([".hgsigs"]) |
|
244 | repo.add([".hgsigs"]) | |
245 |
|
245 | |||
246 | if opts["no_commit"]: |
|
246 | if opts["no_commit"]: |
@@ -1872,7 +1872,7 b' def rename(ui, repo, patch, name=None, *' | |||||
1872 | r = q.qrepo() |
|
1872 | r = q.qrepo() | |
1873 | if r: |
|
1873 | if r: | |
1874 | wlock = r.wlock() |
|
1874 | wlock = r.wlock() | |
1875 |
if r.dirstate |
|
1875 | if r.dirstate[name] == 'r': | |
1876 | r.undelete([name], wlock) |
|
1876 | r.undelete([name], wlock) | |
1877 | r.copy(patch, name, wlock) |
|
1877 | r.copy(patch, name, wlock) | |
1878 | r.remove([patch], False, wlock) |
|
1878 | r.remove([patch], False, wlock) |
@@ -638,12 +638,12 b' def addremove(repo, pats=[], opts={}, wl' | |||||
638 | mapping = {} |
|
638 | mapping = {} | |
639 | for src, abs, rel, exact in walk(repo, pats, opts): |
|
639 | for src, abs, rel, exact in walk(repo, pats, opts): | |
640 | target = repo.wjoin(abs) |
|
640 | target = repo.wjoin(abs) | |
641 |
if src == 'f' and repo.dirstate |
|
641 | if src == 'f' and abs not in repo.dirstate: | |
642 | add.append(abs) |
|
642 | add.append(abs) | |
643 | mapping[abs] = rel, exact |
|
643 | mapping[abs] = rel, exact | |
644 | if repo.ui.verbose or not exact: |
|
644 | if repo.ui.verbose or not exact: | |
645 | repo.ui.status(_('adding %s\n') % ((pats and rel) or abs)) |
|
645 | repo.ui.status(_('adding %s\n') % ((pats and rel) or abs)) | |
646 |
if repo.dirstate |
|
646 | if repo.dirstate[abs] != 'r' and not util.lexists(target): | |
647 | remove.append(abs) |
|
647 | remove.append(abs) | |
648 | mapping[abs] = rel, exact |
|
648 | mapping[abs] = rel, exact | |
649 | if repo.ui.verbose or not exact: |
|
649 | if repo.ui.verbose or not exact: |
@@ -33,7 +33,7 b' def add(ui, repo, *pats, **opts):' | |||||
33 | if ui.verbose: |
|
33 | if ui.verbose: | |
34 | ui.status(_('adding %s\n') % rel) |
|
34 | ui.status(_('adding %s\n') % rel) | |
35 | names.append(abs) |
|
35 | names.append(abs) | |
36 |
elif repo.dirstate |
|
36 | elif abs not in repo.dirstate: | |
37 | ui.status(_('adding %s\n') % rel) |
|
37 | ui.status(_('adding %s\n') % rel) | |
38 | names.append(abs) |
|
38 | names.append(abs) | |
39 | if not opts.get('dry_run'): |
|
39 | if not opts.get('dry_run'): | |
@@ -456,7 +456,7 b' def commit(ui, repo, *pats, **opts):' | |||||
456 | elif not (stat.S_ISREG(mode) or stat.S_ISLNK(mode)): |
|
456 | elif not (stat.S_ISREG(mode) or stat.S_ISLNK(mode)): | |
457 | raise util.Abort(_("can't commit %s: " |
|
457 | raise util.Abort(_("can't commit %s: " | |
458 | "unsupported file type!") % rf) |
|
458 | "unsupported file type!") % rf) | |
459 |
elif repo.dirstate |
|
459 | elif f not in repo.dirstate: | |
460 | raise util.Abort(_("file %s not tracked!") % rf) |
|
460 | raise util.Abort(_("file %s not tracked!") % rf) | |
461 | else: |
|
461 | else: | |
462 | files = [] |
|
462 | files = [] | |
@@ -482,7 +482,7 b' def docopy(ui, repo, pats, opts, wlock):' | |||||
482 | def okaytocopy(abs, rel, exact): |
|
482 | def okaytocopy(abs, rel, exact): | |
483 | reasons = {'?': _('is not managed'), |
|
483 | reasons = {'?': _('is not managed'), | |
484 | 'r': _('has been marked for remove')} |
|
484 | 'r': _('has been marked for remove')} | |
485 |
state = repo.dirstate |
|
485 | state = repo.dirstate[abs] | |
486 | reason = reasons.get(state) |
|
486 | reason = reasons.get(state) | |
487 | if reason: |
|
487 | if reason: | |
488 | if exact: |
|
488 | if exact: | |
@@ -510,7 +510,7 b' def docopy(ui, repo, pats, opts, wlock):' | |||||
510 | repo.pathto(prevsrc, cwd))) |
|
510 | repo.pathto(prevsrc, cwd))) | |
511 | return |
|
511 | return | |
512 | if (not opts['after'] and os.path.exists(target) or |
|
512 | if (not opts['after'] and os.path.exists(target) or | |
513 |
opts['after'] and repo.dirstate |
|
513 | opts['after'] and repo.dirstate[abstarget] in 'mn'): | |
514 | if not opts['force']: |
|
514 | if not opts['force']: | |
515 | ui.warn(_('%s: not overwriting - file exists\n') % |
|
515 | ui.warn(_('%s: not overwriting - file exists\n') % | |
516 | reltarget) |
|
516 | reltarget) | |
@@ -525,7 +525,7 b' def docopy(ui, repo, pats, opts, wlock):' | |||||
525 | if not os.path.isdir(targetdir) and not opts.get('dry_run'): |
|
525 | if not os.path.isdir(targetdir) and not opts.get('dry_run'): | |
526 | os.makedirs(targetdir) |
|
526 | os.makedirs(targetdir) | |
527 | try: |
|
527 | try: | |
528 |
restore = repo.dirstate |
|
528 | restore = repo.dirstate[abstarget] == 'r' | |
529 | if restore and not opts.get('dry_run'): |
|
529 | if restore and not opts.get('dry_run'): | |
530 | repo.undelete([abstarget], wlock) |
|
530 | repo.undelete([abstarget], wlock) | |
531 | try: |
|
531 | try: | |
@@ -547,7 +547,7 b' def docopy(ui, repo, pats, opts, wlock):' | |||||
547 | ui.status(_('copying %s to %s\n') % (relsrc, reltarget)) |
|
547 | ui.status(_('copying %s to %s\n') % (relsrc, reltarget)) | |
548 | targets[abstarget] = abssrc |
|
548 | targets[abstarget] = abssrc | |
549 | if abstarget != origsrc: |
|
549 | if abstarget != origsrc: | |
550 |
if repo.dirstate |
|
550 | if repo.dirstate[origsrc] == 'a': | |
551 | if not ui.quiet: |
|
551 | if not ui.quiet: | |
552 | ui.warn(_("%s has not been committed yet, so no copy " |
|
552 | ui.warn(_("%s has not been committed yet, so no copy " | |
553 | "data will be stored for %s.\n") |
|
553 | "data will be stored for %s.\n") | |
@@ -718,12 +718,11 b' def debugrebuildstate(ui, repo, rev=""):' | |||||
718 | def debugcheckstate(ui, repo): |
|
718 | def debugcheckstate(ui, repo): | |
719 | """validate the correctness of the current dirstate""" |
|
719 | """validate the correctness of the current dirstate""" | |
720 | parent1, parent2 = repo.dirstate.parents() |
|
720 | parent1, parent2 = repo.dirstate.parents() | |
721 | dc = repo.dirstate |
|
|||
722 | m1 = repo.changectx(parent1).manifest() |
|
721 | m1 = repo.changectx(parent1).manifest() | |
723 | m2 = repo.changectx(parent2).manifest() |
|
722 | m2 = repo.changectx(parent2).manifest() | |
724 | errors = 0 |
|
723 | errors = 0 | |
725 |
for f in |
|
724 | for f in repo.dirstate: | |
726 |
state = repo.dirstate |
|
725 | state = repo.dirstate[f] | |
727 | if state in "nr" and f not in m1: |
|
726 | if state in "nr" and f not in m1: | |
728 | ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state)) |
|
727 | ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state)) | |
729 | errors += 1 |
|
728 | errors += 1 | |
@@ -735,7 +734,7 b' def debugcheckstate(ui, repo):' | |||||
735 | (f, state)) |
|
734 | (f, state)) | |
736 | errors += 1 |
|
735 | errors += 1 | |
737 | for f in m1: |
|
736 | for f in m1: | |
738 |
state = repo.dirstate |
|
737 | state = repo.dirstate[f] | |
739 | if state not in "nrm": |
|
738 | if state not in "nrm": | |
740 | ui.warn(_("%s in manifest1, but listed as state %s") % (f, state)) |
|
739 | ui.warn(_("%s in manifest1, but listed as state %s") % (f, state)) | |
741 | errors += 1 |
|
740 | errors += 1 | |
@@ -787,8 +786,10 b' def debugsetparents(ui, repo, rev1, rev2' | |||||
787 |
|
786 | |||
788 | def debugstate(ui, repo): |
|
787 | def debugstate(ui, repo): | |
789 | """show the contents of the current dirstate""" |
|
788 | """show the contents of the current dirstate""" | |
790 | dc = repo.dirstate |
|
789 | dc = repo.dirstate._map | |
791 | for file_ in dc: |
|
790 | k = dc.keys() | |
|
791 | k.sort() | |||
|
792 | for file_ in k: | |||
792 | if dc[file_][3] == -1: |
|
793 | if dc[file_][3] == -1: | |
793 | # Pad or slice to locale representation |
|
794 | # Pad or slice to locale representation | |
794 | locale_len = len(time.strftime("%x %X", time.localtime(0))) |
|
795 | locale_len = len(time.strftime("%x %X", time.localtime(0))) | |
@@ -1758,7 +1759,7 b' def locate(ui, repo, *pats, **opts):' | |||||
1758 | default='relglob'): |
|
1759 | default='relglob'): | |
1759 | if src == 'b': |
|
1760 | if src == 'b': | |
1760 | continue |
|
1761 | continue | |
1761 |
if not node and repo.dirstate |
|
1762 | if not node and abs not in repo.dirstate: | |
1762 | continue |
|
1763 | continue | |
1763 | if opts['fullpath']: |
|
1764 | if opts['fullpath']: | |
1764 | ui.write(os.path.join(repo.root, abs), end) |
|
1765 | ui.write(os.path.join(repo.root, abs), end) | |
@@ -2216,7 +2217,7 b' def remove(ui, repo, *pats, **opts):' | |||||
2216 | forget.append(abs) |
|
2217 | forget.append(abs) | |
2217 | continue |
|
2218 | continue | |
2218 | reason = _('has been marked for add (use -f to force removal)') |
|
2219 | reason = _('has been marked for add (use -f to force removal)') | |
2219 |
elif repo.dirstate |
|
2220 | elif abs not in repo.dirstate: | |
2220 | reason = _('is not managed') |
|
2221 | reason = _('is not managed') | |
2221 | elif opts['after'] and not exact and abs not in deleted: |
|
2222 | elif opts['after'] and not exact and abs not in deleted: | |
2222 | continue |
|
2223 | continue |
@@ -88,11 +88,14 b' class dirstate(object):' | |||||
88 | return path.replace(os.sep, '/') |
|
88 | return path.replace(os.sep, '/') | |
89 | return path |
|
89 | return path | |
90 |
|
90 | |||
91 | def __del__(self): |
|
|||
92 | self.write() |
|
|||
93 |
|
||||
94 | def __getitem__(self, key): |
|
91 | def __getitem__(self, key): | |
95 | return self._map[key] |
|
92 | ''' current states: | |
|
93 | n normal | |||
|
94 | m needs merging | |||
|
95 | r marked for removal | |||
|
96 | a marked for addition | |||
|
97 | ? not tracked''' | |||
|
98 | return self._map.get(key, ("?",))[0] | |||
96 |
|
99 | |||
97 | def __contains__(self, key): |
|
100 | def __contains__(self, key): | |
98 | return key in self._map |
|
101 | return key in self._map | |
@@ -117,14 +120,6 b' class dirstate(object):' | |||||
117 | self._branch = branch |
|
120 | self._branch = branch | |
118 | self._opener("branch", "w").write(branch + '\n') |
|
121 | self._opener("branch", "w").write(branch + '\n') | |
119 |
|
122 | |||
120 | def state(self, key): |
|
|||
121 | ''' current states: |
|
|||
122 | n normal |
|
|||
123 | m needs merging |
|
|||
124 | r marked for removal |
|
|||
125 | a marked for addition''' |
|
|||
126 | return self._map.get(key, ("?",))[0] |
|
|||
127 |
|
||||
128 | def _read(self): |
|
123 | def _read(self): | |
129 | self._map = {} |
|
124 | self._map = {} | |
130 | self._copymap = {} |
|
125 | self._copymap = {} | |
@@ -460,7 +455,7 b' class dirstate(object):' | |||||
460 |
|
455 | |||
461 | for src, fn, st in self.statwalk(files, match, ignored=list_ignored): |
|
456 | for src, fn, st in self.statwalk(files, match, ignored=list_ignored): | |
462 | try: |
|
457 | try: | |
463 | type_, mode, size, time = self[fn] |
|
458 | type_, mode, size, time = self._map[fn] | |
464 | except KeyError: |
|
459 | except KeyError: | |
465 | if list_ignored and self._ignore(fn): |
|
460 | if list_ignored and self._ignore(fn): | |
466 | ignored.append(fn) |
|
461 | ignored.append(fn) |
@@ -156,7 +156,7 b' class localrepository(repo.repository):' | |||||
156 | # committed tags are stored in UTF-8 |
|
156 | # committed tags are stored in UTF-8 | |
157 | writetag(fp, name, util.fromlocal, prevtags) |
|
157 | writetag(fp, name, util.fromlocal, prevtags) | |
158 |
|
158 | |||
159 |
if use_dirstate and self.dirstate |
|
159 | if use_dirstate and '.hgtags' not in self.dirstate: | |
160 | self.add(['.hgtags']) |
|
160 | self.add(['.hgtags']) | |
161 |
|
161 | |||
162 | tagnode = self.commit(['.hgtags'], message, user, date, p1=parent, |
|
162 | tagnode = self.commit(['.hgtags'], message, user, date, p1=parent, | |
@@ -651,8 +651,8 b' class localrepository(repo.repository):' | |||||
651 | if use_dirstate: |
|
651 | if use_dirstate: | |
652 | if files: |
|
652 | if files: | |
653 | for f in files: |
|
653 | for f in files: | |
654 |
s = self.dirstate |
|
654 | s = self.dirstate[f] | |
655 |
if s in 'nma |
|
655 | if s in 'nma': | |
656 | commit.append(f) |
|
656 | commit.append(f) | |
657 | elif s == 'r': |
|
657 | elif s == 'r': | |
658 | remove.append(f) |
|
658 | remove.append(f) | |
@@ -970,7 +970,7 b' class localrepository(repo.repository):' | |||||
970 | if not (stat.S_ISREG(st.st_mode) or stat.S_ISLNK(st.st_mode)): |
|
970 | if not (stat.S_ISREG(st.st_mode) or stat.S_ISLNK(st.st_mode)): | |
971 | self.ui.warn(_("%s not added: only files and symlinks " |
|
971 | self.ui.warn(_("%s not added: only files and symlinks " | |
972 | "supported currently\n") % f) |
|
972 | "supported currently\n") % f) | |
973 |
elif self.dirstate |
|
973 | elif self.dirstate[f] in 'an': | |
974 | self.ui.warn(_("%s already tracked!\n") % f) |
|
974 | self.ui.warn(_("%s already tracked!\n") % f) | |
975 | else: |
|
975 | else: | |
976 | self.dirstate.add(f) |
|
976 | self.dirstate.add(f) | |
@@ -979,7 +979,7 b' class localrepository(repo.repository):' | |||||
979 | if not wlock: |
|
979 | if not wlock: | |
980 | wlock = self.wlock() |
|
980 | wlock = self.wlock() | |
981 | for f in list: |
|
981 | for f in list: | |
982 |
if self.dirstate |
|
982 | if self.dirstate[f] != 'a': | |
983 | self.ui.warn(_("%s not added!\n") % f) |
|
983 | self.ui.warn(_("%s not added!\n") % f) | |
984 | else: |
|
984 | else: | |
985 | self.dirstate.forget(f) |
|
985 | self.dirstate.forget(f) | |
@@ -997,7 +997,7 b' class localrepository(repo.repository):' | |||||
997 | for f in list: |
|
997 | for f in list: | |
998 | if unlink and os.path.exists(self.wjoin(f)): |
|
998 | if unlink and os.path.exists(self.wjoin(f)): | |
999 | self.ui.warn(_("%s still exists!\n") % f) |
|
999 | self.ui.warn(_("%s still exists!\n") % f) | |
1000 |
elif self.dirstate |
|
1000 | elif self.dirstate[f] == 'a': | |
1001 | self.dirstate.forget(f) |
|
1001 | self.dirstate.forget(f) | |
1002 | elif f not in self.dirstate: |
|
1002 | elif f not in self.dirstate: | |
1003 | self.ui.warn(_("%s not tracked!\n") % f) |
|
1003 | self.ui.warn(_("%s not tracked!\n") % f) | |
@@ -1011,7 +1011,7 b' class localrepository(repo.repository):' | |||||
1011 | if not wlock: |
|
1011 | if not wlock: | |
1012 | wlock = self.wlock() |
|
1012 | wlock = self.wlock() | |
1013 | for f in list: |
|
1013 | for f in list: | |
1014 |
if self.dirstate |
|
1014 | if self.dirstate[f] != 'r': | |
1015 | self.ui.warn("%s not removed!\n" % f) |
|
1015 | self.ui.warn("%s not removed!\n" % f) | |
1016 | else: |
|
1016 | else: | |
1017 | t = self.file(f).read(m[f]) |
|
1017 | t = self.file(f).read(m[f]) | |
@@ -1028,7 +1028,7 b' class localrepository(repo.repository):' | |||||
1028 | else: |
|
1028 | else: | |
1029 | if not wlock: |
|
1029 | if not wlock: | |
1030 | wlock = self.wlock() |
|
1030 | wlock = self.wlock() | |
1031 |
if self.dirstate |
|
1031 | if dest not in self.dirstate: | |
1032 | self.dirstate.add(dest) |
|
1032 | self.dirstate.add(dest) | |
1033 | self.dirstate.copy(source, dest) |
|
1033 | self.dirstate.copy(source, dest) | |
1034 |
|
1034 |
General Comments 0
You need to be logged in to leave comments.
Login now