1 # -*- encoding: utf-8 -*-
3 __author__= "Ćukasz Rekucki"
4 __date__ = "$2009-09-25 09:20:22$"
5 __doc__ = "Module documentation."
11 class MercurialRevision(wlrepo.Revision):
13 def __init__(self, lib, changectx):
14 super(MercurialRevision, self).__init__(lib)
15 self._changectx = changectx
17 branchname = self._changectx.branch()
18 if branchname.startswith("$doc:"):
19 self._docname = branchname[5:]
21 elif branchname.startswith("$user:"):
22 idx = branchname.find("$doc:")
24 raise ValueError("Revision %s is not a valid document revision." % changectx.hex());
25 self._username = branchname[0:idx]
26 self._docname = branchname[idx+5:]
28 raise ValueError("Revision %s is not a valid document revision." % changectx.hex());
31 def document_name(self):
39 return self._changectx.node()
42 return self._changectx
45 return self._changectx.branch()
47 def __unicode__(self):
48 return u"%s" % self._changectx.hex()
51 return "%s" % self._changectx.hex()
53 def ancestorof(self, other):
54 nodes = list(other._changectx._parents)
55 while nodes[0].node() != nullid:
57 if v == self._changectx:
59 nodes.extend( v._parents )
62 def parentof(self, other):
63 return self._changectx in other._changectx._parents
65 def has_common_ancestor(self, other):
66 a = self._changectx.ancestor(other._changectx)
67 return (a.branch() == self._changectx.branch())
69 def merge_with(self, other, user, message):
70 lock = self._library._lock(True)
72 self._library._checkout(self._changectx.node())
73 self._library._merge(other._changectx.node())
74 self._library._commit(user=user, message=message)
78 def __eq__(self, other):
79 return self._changectx.node() == other._changectx.node()
82 from wlrepo.mercurial_backend.library import MercurialLibrary