[PATCH 2 of 7 mergedriver] merge.mergestate: add a way to get the other side of the merge

Siddharth Agarwal sid0 at fb.com
Fri Oct 16 21:35:15 CDT 2015


# HG changeset patch
# User Siddharth Agarwal <sid0 at fb.com>
# Date 1444895347 25200
#      Thu Oct 15 00:49:07 2015 -0700
# Node ID a1d0e62becae8276351a7dd9a76912cb3ea9f905
# Parent  b7d49ea007826ec28354bb67b10f651a5cbbf905
merge.mergestate: add a way to get the other side of the merge

It's surprising there was no API at all for this until now. In any case this
will be needed from custom merge drivers.

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -84,6 +84,8 @@ class mergestate(object):
         self._state = {}
         self._local = None
         self._other = None
+        if 'otherctx' in vars(self):
+            del self.__dict__['otherctx']
         if node:
             self._local = node
             self._other = other
@@ -101,6 +103,8 @@ class mergestate(object):
         self._local = None
         self._other = None
         self._mdstate = 'u'
+        if 'otherctx' in vars(self):
+            del self.__dict__['otherctx']
         records = self._readrecords()
         for rtype, record in records:
             if rtype == 'L':
@@ -233,6 +237,9 @@ class mergestate(object):
     @util.propertycache
     def mergedriver(self):
         return self._repo.ui.config('experimental', 'mergedriver')
+    @util.propertycache
+    def otherctx(self):
+        return self._repo[self._other]
 
     def active(self):
         """Whether mergestate is active.


More information about the Mercurial-devel mailing list