Show More
@@ -21,8 +21,8 def lookup_rev(ui, repo, rev=None): | |||||
21 | return parents.pop() |
|
21 | return parents.pop() | |
22 |
|
22 | |||
23 | def check_clean(ui, repo): |
|
23 | def check_clean(ui, repo): | |
24 |
|
|
24 | modified, added, removed, unknown = repo.changes() | |
25 |
if |
|
25 | if modified or added or removed: | |
26 | ui.warn("Repository is not clean, please commit or revert\n") |
|
26 | ui.warn("Repository is not clean, please commit or revert\n") | |
27 | sys.exit(1) |
|
27 | sys.exit(1) | |
28 |
|
28 |
@@ -14,13 +14,13 def dodiff(fp, ui, repo, node1, node2, f | |||||
14 | return time.asctime(time.gmtime(c[2][0])) |
|
14 | return time.asctime(time.gmtime(c[2][0])) | |
15 |
|
15 | |||
16 | if not changes: |
|
16 | if not changes: | |
17 |
|
|
17 | changes = repo.changes(node1, node2, files, match=match) | |
18 | else: |
|
18 | modified, added, removed, unknown = changes | |
19 | (c, a, d, u) = changes |
|
|||
20 | if files: |
|
19 | if files: | |
21 |
|
|
20 | modified, added, removed = map(lambda x: filterfiles(x, files), | |
|
21 | (modified, added, removed)) | |||
22 |
|
22 | |||
23 |
if not |
|
23 | if not modified and not added and not removed: | |
24 | return |
|
24 | return | |
25 |
|
25 | |||
26 | if node2: |
|
26 | if node2: | |
@@ -40,19 +40,19 def dodiff(fp, ui, repo, node1, node2, f | |||||
40 | mmap = repo.manifest.read(change[0]) |
|
40 | mmap = repo.manifest.read(change[0]) | |
41 | date1 = date(change) |
|
41 | date1 = date(change) | |
42 |
|
42 | |||
43 |
for f in |
|
43 | for f in modified: | |
44 | to = None |
|
44 | to = None | |
45 | if f in mmap: |
|
45 | if f in mmap: | |
46 | to = repo.file(f).read(mmap[f]) |
|
46 | to = repo.file(f).read(mmap[f]) | |
47 | tn = read(f) |
|
47 | tn = read(f) | |
48 | fp.write("diff --git a/%s b/%s\n" % (f, f)) |
|
48 | fp.write("diff --git a/%s b/%s\n" % (f, f)) | |
49 | fp.write(mdiff.unidiff(to, date1, tn, date2, f, None, text=text)) |
|
49 | fp.write(mdiff.unidiff(to, date1, tn, date2, f, None, text=text)) | |
50 | for f in a: |
|
50 | for f in added: | |
51 | to = None |
|
51 | to = None | |
52 | tn = read(f) |
|
52 | tn = read(f) | |
53 | fp.write("diff --git /dev/null b/%s\n" % (f)) |
|
53 | fp.write("diff --git /dev/null b/%s\n" % (f)) | |
54 | fp.write(mdiff.unidiff(to, date1, tn, date2, f, None, text=text)) |
|
54 | fp.write(mdiff.unidiff(to, date1, tn, date2, f, None, text=text)) | |
55 | for f in d: |
|
55 | for f in removed: | |
56 | to = repo.file(f).read(mmap[f]) |
|
56 | to = repo.file(f).read(mmap[f]) | |
57 | tn = None |
|
57 | tn = None | |
58 | fp.write("diff --git a/%s /dev/null\n" % (f)) |
|
58 | fp.write("diff --git a/%s /dev/null\n" % (f)) | |
@@ -67,12 +67,12 def difftree(ui, repo, node1=None, node2 | |||||
67 | if node2: |
|
67 | if node2: | |
68 | change = repo.changelog.read(node2) |
|
68 | change = repo.changelog.read(node2) | |
69 | mmap2 = repo.manifest.read(change[0]) |
|
69 | mmap2 = repo.manifest.read(change[0]) | |
70 |
|
|
70 | modified, added, removed, unknown = repo.changes(node1, node2) | |
71 | def read(f): return repo.file(f).read(mmap2[f]) |
|
71 | def read(f): return repo.file(f).read(mmap2[f]) | |
72 | date2 = date(change) |
|
72 | date2 = date(change) | |
73 | else: |
|
73 | else: | |
74 | date2 = time.asctime() |
|
74 | date2 = time.asctime() | |
75 |
|
|
75 | modified, added, removed, unknown = repo.changes(node1) | |
76 | if not node1: |
|
76 | if not node1: | |
77 | node1 = repo.dirstate.parents()[0] |
|
77 | node1 = repo.dirstate.parents()[0] | |
78 | def read(f): return file(os.path.join(repo.root, f)).read() |
|
78 | def read(f): return file(os.path.join(repo.root, f)).read() | |
@@ -82,13 +82,13 def difftree(ui, repo, node1=None, node2 | |||||
82 | date1 = date(change) |
|
82 | date1 = date(change) | |
83 | empty = "0" * 40; |
|
83 | empty = "0" * 40; | |
84 |
|
84 | |||
85 |
for f in |
|
85 | for f in modified: | |
86 | # TODO get file permissions |
|
86 | # TODO get file permissions | |
87 | print ":100664 100664 %s %s M\t%s\t%s" % (hg.hex(mmap[f]), |
|
87 | print ":100664 100664 %s %s M\t%s\t%s" % (hg.hex(mmap[f]), | |
88 | hg.hex(mmap2[f]), f, f) |
|
88 | hg.hex(mmap2[f]), f, f) | |
89 | for f in a: |
|
89 | for f in added: | |
90 | print ":000000 100664 %s %s N\t%s\t%s" % (empty, hg.hex(mmap2[f]), f, f) |
|
90 | print ":000000 100664 %s %s N\t%s\t%s" % (empty, hg.hex(mmap2[f]), f, f) | |
91 | for f in d: |
|
91 | for f in removed: | |
92 | print ":100664 000000 %s %s D\t%s\t%s" % (hg.hex(mmap[f]), empty, f, f) |
|
92 | print ":100664 000000 %s %s D\t%s\t%s" % (hg.hex(mmap[f]), empty, f, f) | |
93 | ## |
|
93 | ## | |
94 |
|
94 |
@@ -160,8 +160,7 def sign(ui, repo, *revs, **opts): | |||||
160 | repo.opener("localsigs", "ab").write(sigmessage) |
|
160 | repo.opener("localsigs", "ab").write(sigmessage) | |
161 | return |
|
161 | return | |
162 |
|
162 | |||
163 |
|
|
163 | for x in repo.changes(): | |
164 | for x in (c, a, d, u): |
|
|||
165 | if ".hgsigs" in x and not opts["force"]: |
|
164 | if ".hgsigs" in x and not opts["force"]: | |
166 | raise util.Abort("working copy of .hgsigs is changed " |
|
165 | raise util.Abort("working copy of .hgsigs is changed " | |
167 | "(please commit .hgsigs manually" |
|
166 | "(please commit .hgsigs manually" |
@@ -263,13 +263,13 def make_file(repo, r, pat, node=None, | |||||
263 | def dodiff(fp, ui, repo, node1, node2, files=None, match=util.always, |
|
263 | def dodiff(fp, ui, repo, node1, node2, files=None, match=util.always, | |
264 | changes=None, text=False): |
|
264 | changes=None, text=False): | |
265 | if not changes: |
|
265 | if not changes: | |
266 |
|
|
266 | changes = repo.changes(node1, node2, files, match=match) | |
267 | else: |
|
267 | modified, added, removed, unknown = changes | |
268 | (c, a, d, u) = changes |
|
|||
269 | if files: |
|
268 | if files: | |
270 |
|
|
269 | modified, added, removed = map(lambda x: filterfiles(x, files), | |
|
270 | (modified, added, removed)) | |||
271 |
|
271 | |||
272 |
if not |
|
272 | if not modified and not added and not removed: | |
273 | return |
|
273 | return | |
274 |
|
274 | |||
275 | if node2: |
|
275 | if node2: | |
@@ -295,17 +295,17 def dodiff(fp, ui, repo, node1, node2, f | |||||
295 | mmap = repo.manifest.read(change[0]) |
|
295 | mmap = repo.manifest.read(change[0]) | |
296 | date1 = util.datestr(change[2]) |
|
296 | date1 = util.datestr(change[2]) | |
297 |
|
297 | |||
298 |
for f in |
|
298 | for f in modified: | |
299 | to = None |
|
299 | to = None | |
300 | if f in mmap: |
|
300 | if f in mmap: | |
301 | to = repo.file(f).read(mmap[f]) |
|
301 | to = repo.file(f).read(mmap[f]) | |
302 | tn = read(f) |
|
302 | tn = read(f) | |
303 | fp.write(mdiff.unidiff(to, date1, tn, date2, f, r, text=text)) |
|
303 | fp.write(mdiff.unidiff(to, date1, tn, date2, f, r, text=text)) | |
304 | for f in a: |
|
304 | for f in added: | |
305 | to = None |
|
305 | to = None | |
306 | tn = read(f) |
|
306 | tn = read(f) | |
307 | fp.write(mdiff.unidiff(to, date1, tn, date2, f, r, text=text)) |
|
307 | fp.write(mdiff.unidiff(to, date1, tn, date2, f, r, text=text)) | |
308 | for f in d: |
|
308 | for f in removed: | |
309 | to = repo.file(f).read(mmap[f]) |
|
309 | to = repo.file(f).read(mmap[f]) | |
310 | tn = None |
|
310 | tn = None | |
311 | fp.write(mdiff.unidiff(to, date1, tn, date2, f, r, text=text)) |
|
311 | fp.write(mdiff.unidiff(to, date1, tn, date2, f, r, text=text)) | |
@@ -785,8 +785,10 def commit(ui, repo, *pats, **opts): | |||||
785 | addremove(ui, repo, *pats, **opts) |
|
785 | addremove(ui, repo, *pats, **opts) | |
786 | fns, match, anypats, cwd = matchpats(repo, pats, opts) |
|
786 | fns, match, anypats, cwd = matchpats(repo, pats, opts) | |
787 | if pats: |
|
787 | if pats: | |
788 | c, a, d, u = repo.changes(files=fns, match=match) |
|
788 | modified, added, removed, unknown = ( | |
789 | files = c + a + [fn for fn in d if repo.dirstate.state(fn) == 'r'] |
|
789 | repo.changes(files=fns, match=match)) | |
|
790 | files = (modified + added + | |||
|
791 | [fn for fn in removed if repo.dirstate.state(fn) == 'r']) | |||
790 | else: |
|
792 | else: | |
791 | files = [] |
|
793 | files = [] | |
792 | try: |
|
794 | try: | |
@@ -1379,9 +1381,9 def identify(ui, repo): | |||||
1379 | return |
|
1381 | return | |
1380 |
|
1382 | |||
1381 | hexfunc = ui.verbose and hex or short |
|
1383 | hexfunc = ui.verbose and hex or short | |
1382 |
|
|
1384 | modified, added, removed, unknown = repo.changes() | |
1383 | output = ["%s%s" % ('+'.join([hexfunc(parent) for parent in parents]), |
|
1385 | output = ["%s%s" % ('+'.join([hexfunc(parent) for parent in parents]), | |
1384 |
( |
|
1386 | (modified or added or removed) and "+" or "")] | |
1385 |
|
1387 | |||
1386 | if not ui.quiet: |
|
1388 | if not ui.quiet: | |
1387 | # multiple tags for a single parent separated by '/' |
|
1389 | # multiple tags for a single parent separated by '/' | |
@@ -1410,8 +1412,8 def import_(ui, repo, patch1, *patches, | |||||
1410 | patches = (patch1,) + patches |
|
1412 | patches = (patch1,) + patches | |
1411 |
|
1413 | |||
1412 | if not opts['force']: |
|
1414 | if not opts['force']: | |
1413 |
|
|
1415 | modified, added, removed, unknown = repo.changes() | |
1414 |
if |
|
1416 | if modified or added or removed: | |
1415 | raise util.Abort(_("outstanding uncommitted changes")) |
|
1417 | raise util.Abort(_("outstanding uncommitted changes")) | |
1416 |
|
1418 | |||
1417 | d = opts["base"] |
|
1419 | d = opts["base"] | |
@@ -1827,13 +1829,13 def remove(ui, repo, pat, *pats, **opts) | |||||
1827 | """ |
|
1829 | """ | |
1828 | names = [] |
|
1830 | names = [] | |
1829 | def okaytoremove(abs, rel, exact): |
|
1831 | def okaytoremove(abs, rel, exact): | |
1830 |
|
|
1832 | modified, added, removed, unknown = repo.changes(files=[abs]) | |
1831 | reason = None |
|
1833 | reason = None | |
1832 |
if |
|
1834 | if modified: | |
1833 | reason = _('is modified') |
|
1835 | reason = _('is modified') | |
1834 | elif a: |
|
1836 | elif added: | |
1835 | reason = _('has been marked for add') |
|
1837 | reason = _('has been marked for add') | |
1836 | elif u: |
|
1838 | elif unknown: | |
1837 | reason = _('is not managed') |
|
1839 | reason = _('is not managed') | |
1838 | if reason: |
|
1840 | if reason: | |
1839 | if exact: |
|
1841 | if exact: | |
@@ -1891,9 +1893,9 def revert(ui, repo, *pats, **opts): | |||||
1891 | repo.dirstate.parents()[0] |
|
1893 | repo.dirstate.parents()[0] | |
1892 |
|
1894 | |||
1893 | files, choose, anypats, cwd = matchpats(repo, pats, opts) |
|
1895 | files, choose, anypats, cwd = matchpats(repo, pats, opts) | |
1894 |
|
|
1896 | modified, added, removed, unknown = repo.changes(match=choose) | |
1895 | repo.forget(a) |
|
1897 | repo.forget(added) | |
1896 | repo.undelete(d) |
|
1898 | repo.undelete(removed) | |
1897 |
|
1899 | |||
1898 | return repo.update(node, False, True, choose, False) |
|
1900 | return repo.update(node, False, True, choose, False) | |
1899 |
|
1901 | |||
@@ -2024,13 +2026,14 def status(ui, repo, *pats, **opts): | |||||
2024 | """ |
|
2026 | """ | |
2025 |
|
2027 | |||
2026 | files, matchfn, anypats, cwd = matchpats(repo, pats, opts) |
|
2028 | files, matchfn, anypats, cwd = matchpats(repo, pats, opts) | |
2027 | (c, a, d, u) = [[util.pathto(cwd, x) for x in n] |
|
2029 | modified, added, removed, unknown = [ | |
|
2030 | [util.pathto(cwd, x) for x in n] | |||
2028 |
|
|
2031 | for n in repo.changes(files=files, match=matchfn)] | |
2029 |
|
2032 | |||
2030 |
changetypes = [(_('modified'), 'M', |
|
2033 | changetypes = [(_('modified'), 'M', modified), | |
2031 | (_('added'), 'A', a), |
|
2034 | (_('added'), 'A', added), | |
2032 | (_('removed'), 'R', d), |
|
2035 | (_('removed'), 'R', removed), | |
2033 | (_('unknown'), '?', u)] |
|
2036 | (_('unknown'), '?', unknown)] | |
2034 |
|
2037 | |||
2035 | end = opts['print0'] and '\0' or '\n' |
|
2038 | end = opts['print0'] and '\0' or '\n' | |
2036 |
|
2039 | |||
@@ -2078,8 +2081,7 def tag(ui, repo, name, rev_=None, **opt | |||||
2078 | repo.opener("localtags", "a").write("%s %s\n" % (r, name)) |
|
2081 | repo.opener("localtags", "a").write("%s %s\n" % (r, name)) | |
2079 | return |
|
2082 | return | |
2080 |
|
2083 | |||
2081 |
|
|
2084 | for x in repo.changes(): | |
2082 | for x in (c, a, d, u): |
|
|||
2083 | if ".hgtags" in x: |
|
2085 | if ".hgtags" in x: | |
2084 | raise util.Abort(_("working copy of .hgtags is changed " |
|
2086 | raise util.Abort(_("working copy of .hgtags is changed " | |
2085 | "(please commit .hgtags manually)")) |
|
2087 | "(please commit .hgtags manually)")) |
@@ -265,19 +265,20 class hgweb(object): | |||||
265 | date1 = util.datestr(change1[2]) |
|
265 | date1 = util.datestr(change1[2]) | |
266 | date2 = util.datestr(change2[2]) |
|
266 | date2 = util.datestr(change2[2]) | |
267 |
|
267 | |||
268 |
|
|
268 | modified, added, removed, unknown = r.changes(node1, node2) | |
269 | if files: |
|
269 | if files: | |
270 |
|
|
270 | modified, added, removed = map(lambda x: filterfiles(x, files), | |
|
271 | (modified, added, removed)) | |||
271 |
|
272 | |||
272 |
for f in |
|
273 | for f in modified: | |
273 | to = r.file(f).read(mmap1[f]) |
|
274 | to = r.file(f).read(mmap1[f]) | |
274 | tn = r.file(f).read(mmap2[f]) |
|
275 | tn = r.file(f).read(mmap2[f]) | |
275 | yield diffblock(mdiff.unidiff(to, date1, tn, date2, f), f, tn) |
|
276 | yield diffblock(mdiff.unidiff(to, date1, tn, date2, f), f, tn) | |
276 | for f in a: |
|
277 | for f in added: | |
277 | to = None |
|
278 | to = None | |
278 | tn = r.file(f).read(mmap2[f]) |
|
279 | tn = r.file(f).read(mmap2[f]) | |
279 | yield diffblock(mdiff.unidiff(to, date1, tn, date2, f), f, tn) |
|
280 | yield diffblock(mdiff.unidiff(to, date1, tn, date2, f), f, tn) | |
280 | for f in d: |
|
281 | for f in removed: | |
281 | to = r.file(f).read(mmap1[f]) |
|
282 | to = r.file(f).read(mmap1[f]) | |
282 | tn = None |
|
283 | tn = None | |
283 | yield diffblock(mdiff.unidiff(to, date1, tn, date2, f), f, tn) |
|
284 | yield diffblock(mdiff.unidiff(to, date1, tn, date2, f), f, tn) |
@@ -355,9 +355,9 class localrepository(object): | |||||
355 | else: |
|
355 | else: | |
356 | self.ui.warn(_("%s not tracked!\n") % f) |
|
356 | self.ui.warn(_("%s not tracked!\n") % f) | |
357 | else: |
|
357 | else: | |
358 |
|
|
358 | modified, added, removed, unknown = self.changes(match=match) | |
359 |
commit = |
|
359 | commit = modified + added | |
360 | remove = d |
|
360 | remove = removed | |
361 |
|
361 | |||
362 | p1, p2 = self.dirstate.parents() |
|
362 | p1, p2 = self.dirstate.parents() | |
363 | c1 = self.changelog.read(p1) |
|
363 | c1 = self.changelog.read(p1) | |
@@ -1392,13 +1392,13 class localrepository(object): | |||||
1392 | ma = self.manifest.read(man) |
|
1392 | ma = self.manifest.read(man) | |
1393 | mfa = self.manifest.readflags(man) |
|
1393 | mfa = self.manifest.readflags(man) | |
1394 |
|
1394 | |||
1395 |
|
|
1395 | modified, added, removed, unknown = self.changes() | |
1396 |
|
1396 | |||
1397 | if allow and not forcemerge: |
|
1397 | if allow and not forcemerge: | |
1398 |
if |
|
1398 | if modified or added or removed: | |
1399 | raise util.Abort(_("outstanding uncommited changes")) |
|
1399 | raise util.Abort(_("outstanding uncommited changes")) | |
1400 | if not forcemerge and not force: |
|
1400 | if not forcemerge and not force: | |
1401 | for f in u: |
|
1401 | for f in unknown: | |
1402 | if f in m2: |
|
1402 | if f in m2: | |
1403 | t1 = self.wread(f) |
|
1403 | t1 = self.wread(f) | |
1404 | t2 = self.file(f).read(m2[f]) |
|
1404 | t2 = self.file(f).read(m2[f]) | |
@@ -1425,16 +1425,16 class localrepository(object): | |||||
1425 | # construct a working dir manifest |
|
1425 | # construct a working dir manifest | |
1426 | mw = m1.copy() |
|
1426 | mw = m1.copy() | |
1427 | mfw = mf1.copy() |
|
1427 | mfw = mf1.copy() | |
1428 | umap = dict.fromkeys(u) |
|
1428 | umap = dict.fromkeys(unknown) | |
1429 |
|
1429 | |||
1430 |
for f in a + |
|
1430 | for f in added + modified + unknown: | |
1431 | mw[f] = "" |
|
1431 | mw[f] = "" | |
1432 | mfw[f] = util.is_exec(self.wjoin(f), mfw.get(f, False)) |
|
1432 | mfw[f] = util.is_exec(self.wjoin(f), mfw.get(f, False)) | |
1433 |
|
1433 | |||
1434 | if moddirstate: |
|
1434 | if moddirstate: | |
1435 | wlock = self.wlock() |
|
1435 | wlock = self.wlock() | |
1436 |
|
1436 | |||
1437 | for f in d: |
|
1437 | for f in removed: | |
1438 | if f in mw: |
|
1438 | if f in mw: | |
1439 | del mw[f] |
|
1439 | del mw[f] | |
1440 |
|
1440 |
General Comments 0
You need to be logged in to leave comments.
Login now