1 # -*- encoding: utf-8 -*-
3 __author__= "Ćukasz Rekucki"
4 __date__ = "$2009-09-25 09:20:22$"
5 __doc__ = "Module documentation."
9 class MercurialRevision(wlrepo.Revision):
11 def __init__(self, lib, changectx):
12 super(MercurialRevision, self).__init__(lib)
13 self._changectx = changectx
15 branchname = self._changectx.branch()
16 if branchname.startswith("$doc:"):
17 self._docname = branchname[5:]
19 elif branchname.startswith("$user:"):
20 idx = branchname.find("$doc:")
22 raise ValueError("Revision %s is not a valid document revision." % changectx.hex());
23 self._username = branchname[6:idx]
24 self._docname = branchname[idx+5:]
26 raise ValueError("Revision %s is not a valid document revision." % changectx.hex());
29 def document_name(self):
37 return self._changectx.node()
40 return self._changectx
43 return self._changectx.branch()
45 def __unicode__(self):
46 return u"%s" % self._changectx.hex()
49 return "%s" % self._changectx.hex()
51 def ancestorof(self, other):
52 nodes = list(other._changectx._parents)
53 while nodes[0].node() != nullid:
55 if v == self._changectx:
57 nodes.extend( v._parents )
60 def parentof(self, other):
61 return self._changectx in other._changectx._parents
63 def has_common_ancestor(self, other):
64 a = self._changectx.ancestor(other._changectx)
65 return (a.branch() == self._changectx.branch())
67 def merge_with(self, other, user, message):
68 lock = self._library._lock(True)
70 self._library._checkout(self._changectx.node())
71 status = self._library._merge(other._changectx.node())
73 self._library._commit(user=user, message=message)
80 def __eq__(self, other):
81 return self._changectx.node() == other._changectx.node()
84 from wlrepo.mercurial_backend.library import MercurialLibrary