Mercurial > hg-stable
changeset 227:f57519cddd3d
move repo.current to dirstate.parents()
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
move repo.current to dirstate.parents()
dirstate now tracks the parents for the working dir
add a parents command to show them
manifest hash: cd69237838c3f69f7937723c4a6803d47cb27cfa
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCoMGuywK+sNU5EO8RAg5UAKCVLUrsJtkoIOTM+e0BLqEVN3Ni3gCeNDyy
ZF8jD728cl9K7S4sIN4gX4Y=
=P4bu
-----END PGP SIGNATURE-----
author | mpm@selenic.com |
---|---|
date | Fri, 03 Jun 2005 12:46:38 -0800 |
parents | 1536ccac47e9 |
children | 2502aa663484 |
files | hg mercurial/commands.py mercurial/hg.py |
diffstat | 3 files changed, 34 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/hg Fri Jun 03 12:45:04 2005 -0800 +++ b/hg Fri Jun 03 12:46:38 2005 -0800 @@ -66,9 +66,8 @@ else: date2 = time.asctime() if not node1: - node1 = repo.current + node1 = repo.dirstate.parents()[0] (c, a, d, u) = repo.diffdir(repo.root, node1) - a = [] # ignore unknown files in repo, by popular request def read(f): return file(os.path.join(repo.root, f)).read() change = repo.changelog.read(node1) @@ -139,9 +138,9 @@ elif cmd == "commit" or cmd == "checkin" or cmd == "ci": if 1: if len(args) > 0: - repo.commit(repo.current, args) + repo.commit(args) else: - repo.commit(repo.current) + repo.commit() elif cmd == "rawcommit": "raw commit interface" rc = {} @@ -204,7 +203,7 @@ if files: if os.system("patch -p%d < %s %s" % (strip, pf, quiet)): raise "patch failed!" - repo.commit(repo.current, files, text) + repo.commit(files, text) elif cmd == "diff": revs = []
--- a/mercurial/commands.py Fri Jun 03 12:45:04 2005 -0800 +++ b/mercurial/commands.py Fri Jun 03 12:46:38 2005 -0800 @@ -102,7 +102,7 @@ ops['number'] = 1 args = relpath(repo, args) - node = repo.current + node = repo.dirstate.parents()[0] if ops['revision']: node = repo.changelog.lookup(ops['revision']) change = repo.changelog.read(node) @@ -142,6 +142,17 @@ print "description:" print changes[4] +def parents(ui, repo, node = None): + '''show the parents of the current working dir''' + if node: + p = repo.changelog.parents(repo.lookup(hg.bin(node))) + else: + p = repo.dirstate.parents() + + for n in p: + if n != hg.nullid: + ui.write("%d:%s\n" % (repo.changelog.rev(n), hg.hex(n))) + def status(ui, repo): '''show changed files in the working directory @@ -172,6 +183,7 @@ ('n', 'number', None, 'show revision number'), ('c', 'changeset', None, 'show changeset')], 'hg annotate [-u] [-c] [-n] [-r id] [files]'), + "parents": (parents, [], 'hg parents [node]'), "status": (status, [], 'hg status'), "undo": (undo, [], 'hg undo'), }
--- a/mercurial/hg.py Fri Jun 03 12:45:04 2005 -0800 +++ b/mercurial/hg.py Fri Jun 03 12:46:38 2005 -0800 @@ -155,6 +155,7 @@ self.dirty = 0 self.ui = ui self.map = None + self.pl = None def __del__(self): if self.dirty: @@ -171,6 +172,15 @@ if not self.map: self.read() return key in self.map + def parents(self): + if not self.pl: + self.read() + return self.pl + + def setparents(self, p1, p2 = nullid): + self.dirty = 1 + self.pl = p1, p2 + def state(self, key): try: return self[key][0] @@ -181,11 +191,14 @@ if self.map is not None: return self.map self.map = {} + self.pl = [nullid, nullid] try: st = self.opener("dirstate").read() except: return - pos = 0 + self.pl = [st[:20], st[20: 40]] + + pos = 40 while pos < len(st): e = struct.unpack(">cllll", st[pos:pos+17]) l = e[4] @@ -232,6 +245,7 @@ def write(self): st = self.opener("dirstate", "w") + st.write("".join(self.pl)) for f, e in self.map.items(): e = struct.pack(">cllll", e[0], e[1], e[2], e[3], len(f)) st.write(e + f) @@ -297,15 +311,7 @@ if not self.remote: self.dirstate = dirstate(self.opener, ui) - try: - self.current = bin(self.opener("current").read()) - except IOError: - self.current = None - def setcurrent(self, node): - self.current = node - self.opener("current", "w").write(hex(node)) - def ignore(self, f): if self.ignorelist is None: self.ignorelist = [] @@ -366,7 +372,7 @@ node = self.changelog.tip() f.sort() - self.setcurrent(node) + self.dirstate.setparents(node) self.dirstate.update(f, 'i') else: @@ -486,7 +492,7 @@ os.makedirs(os.path.dirname(f)) file(f, "w").write(t) - self.setcurrent(node) + self.dirstate.setparents(node) self.dirstate.clear() self.dirstate.update([f for f,n in l], "n")