1 # -*- encoding: utf-8 -*-
3 __author__= "Ćukasz Rekucki"
4 __date__ = "$2009-09-25 09:20:22$"
5 __doc__ = "Module documentation."
8 from mercurial.node import nullid
10 class MercurialRevision(wlrepo.Revision):
12 def __init__(self, lib, changectx):
13 super(MercurialRevision, self).__init__(lib)
14 self._changectx = changectx
16 branchname = self._changectx.branch()
17 if branchname.startswith("$doc:"):
18 self._docname = branchname[5:]
20 elif branchname.startswith("$user:"):
21 idx = branchname.find("$doc:")
23 raise ValueError("Revision %s is not a valid document revision." % changectx.hex());
24 self._username = branchname[6:idx]
25 self._docname = branchname[idx+5:]
27 raise ValueError("Revision %s is not a valid document revision." % changectx.hex());
30 def document_name(self):
38 return self._changectx.node()
41 return self._changectx
44 return self._changectx.branch()
46 def __unicode__(self):
47 return u"%s" % self._changectx.hex()
50 return "%s" % self._changectx.hex()
52 def ancestorof(self, other):
53 nodes = list(other._changectx._parents)
54 while nodes[0].node() != nullid:
56 if v == self._changectx:
58 nodes.extend( v._parents )
61 def parentof(self, other):
62 return self._changectx in other._changectx._parents
64 def has_common_ancestor(self, other):
65 a = self._changectx.ancestor(other._changectx)
66 return (a.branch() == self._changectx.branch())
68 def merge_with(self, other, user, message):
69 lock = self._library.lock(True)
71 self._library._checkout(self._changectx.node())
72 status = self._library._merge(other._changectx.node())
74 self._library._commit(user=user, message=message)
81 def __eq__(self, other):
82 return self._changectx.node() == other._changectx.node()
85 from wlrepo.mercurial_backend.library import MercurialLibrary