mercurial/context.py
changeset 33022 ce96efec8112
parent 33019 daccadd75760
child 33084 873f638fd7db
equal deleted inserted replaced
33021:24c0a9a7fa86 33022:ce96efec8112
    63         o._rev = nullrev
    63         o._rev = nullrev
    64         o._node = nullid
    64         o._node = nullid
    65 
    65 
    66         return o
    66         return o
    67 
    67 
    68     def __str__(self):
       
    69         r = short(self.node())
       
    70         if pycompat.ispy3:
       
    71             return r.decode('ascii')
       
    72         return r
       
    73 
       
    74     def __bytes__(self):
    68     def __bytes__(self):
    75         return short(self.node())
    69         return short(self.node())
       
    70 
       
    71     __str__ = encoding.strmethod(__bytes__)
    76 
    72 
    77     def __int__(self):
    73     def __int__(self):
    78         return self.rev()
    74         return self.rev()
    79 
    75 
    80     def __repr__(self):
    76     def __repr__(self):
   708             # file is missing
   704             # file is missing
   709             return False
   705             return False
   710 
   706 
   711     __bool__ = __nonzero__
   707     __bool__ = __nonzero__
   712 
   708 
   713     def __str__(self):
       
   714         try:
       
   715             return "%s@%s" % (self.path(), self._changectx)
       
   716         except error.LookupError:
       
   717             return "%s@???" % self.path()
       
   718 
       
   719     def __bytes__(self):
   709     def __bytes__(self):
   720         try:
   710         try:
   721             return "%s@%s" % (self.path(), self._changectx)
   711             return "%s@%s" % (self.path(), self._changectx)
   722         except error.LookupError:
   712         except error.LookupError:
   723             return "%s@???" % self.path()
   713             return "%s@???" % self.path()
       
   714 
       
   715     __str__ = encoding.strmethod(__bytes__)
   724 
   716 
   725     def __repr__(self):
   717     def __repr__(self):
   726         return "<%s %s>" % (type(self).__name__, str(self))
   718         return "<%s %s>" % (type(self).__name__, str(self))
   727 
   719 
   728     def __hash__(self):
   720     def __hash__(self):
  1304                 raise error.Abort(_('branch name not in UTF-8!'))
  1296                 raise error.Abort(_('branch name not in UTF-8!'))
  1305             self._extra['branch'] = branch
  1297             self._extra['branch'] = branch
  1306         if self._extra['branch'] == '':
  1298         if self._extra['branch'] == '':
  1307             self._extra['branch'] = 'default'
  1299             self._extra['branch'] = 'default'
  1308 
  1300 
  1309     def __str__(self):
       
  1310         return str(self._parents[0]) + r"+"
       
  1311 
       
  1312     def __bytes__(self):
  1301     def __bytes__(self):
  1313         return bytes(self._parents[0]) + "+"
  1302         return bytes(self._parents[0]) + "+"
       
  1303 
       
  1304     __str__ = encoding.strmethod(__bytes__)
  1314 
  1305 
  1315     def __nonzero__(self):
  1306     def __nonzero__(self):
  1316         return True
  1307         return True
  1317 
  1308 
  1318     __bool__ = __nonzero__
  1309     __bool__ = __nonzero__