##// END OF EJS Templates
merge with stable
Yuya Nishihara -
r41387:0ae3ddb4 merge default
parent child Browse files
Show More
@@ -396,6 +396,11 b' class revlog(object):'
396 newversionflags = REVLOGV1 | FLAG_INLINE_DATA
396 newversionflags = REVLOGV1 | FLAG_INLINE_DATA
397 if 'generaldelta' in opts:
397 if 'generaldelta' in opts:
398 newversionflags |= FLAG_GENERALDELTA
398 newversionflags |= FLAG_GENERALDELTA
399 elif getattr(self.opener, 'options', None) is not None:
400 # If options provided but no 'revlog*' found, the repository
401 # would have no 'requires' file in it, which means we have to
402 # stick to the old format.
403 newversionflags = REVLOGV0
399 else:
404 else:
400 newversionflags = REVLOG_DEFAULT_VERSION
405 newversionflags = REVLOG_DEFAULT_VERSION
401
406
@@ -896,8 +901,6 b' class revlog(object):'
896 common = [nullrev]
901 common = [nullrev]
897
902
898 if rustext is not None:
903 if rustext is not None:
899 # TODO: WdirUnsupported should be raised instead of GraphError
900 # if common includes wdirrev
901 return rustext.ancestor.MissingAncestors(self.index, common)
904 return rustext.ancestor.MissingAncestors(self.index, common)
902 return ancestor.incrementalmissingancestors(self.parentrevs, common)
905 return ancestor.incrementalmissingancestors(self.parentrevs, common)
903
906
@@ -183,7 +183,8 b' class partialdiscovery(object):'
183 def addcommons(self, commons):
183 def addcommons(self, commons):
184 """registrer nodes known as common"""
184 """registrer nodes known as common"""
185 self._common.addbases(commons)
185 self._common.addbases(commons)
186 self._common.removeancestorsfrom(self.undecided)
186 if self._undecided is not None:
187 self._common.removeancestorsfrom(self._undecided)
187
188
188 def addmissings(self, missings):
189 def addmissings(self, missings):
189 """registrer some nodes as missing"""
190 """registrer some nodes as missing"""
@@ -999,15 +999,47 b' class ui(object):'
999 "cmdname.type" is recommended. For example, status issues
999 "cmdname.type" is recommended. For example, status issues
1000 a label of "status.modified" for modified files.
1000 a label of "status.modified" for modified files.
1001 '''
1001 '''
1002 self._write(self._fout, *args, **opts)
1002 dest = self._fout
1003
1004 # inlined _write() for speed
1005 if self._buffers:
1006 label = opts.get(r'label', '')
1007 if label and self._bufferapplylabels:
1008 self._buffers[-1].extend(self.label(a, label) for a in args)
1009 else:
1010 self._buffers[-1].extend(args)
1011 return
1012
1013 # inliend _writenobuf() for speed
1014 self._progclear()
1015 msg = b''.join(args)
1016
1017 # opencode timeblockedsection because this is a critical path
1018 starttime = util.timer()
1019 try:
1020 if self._colormode == 'win32':
1021 # windows color printing is its own can of crab, defer to
1022 # the color module and that is it.
1023 color.win32print(self, dest.write, msg, **opts)
1024 else:
1025 if self._colormode is not None:
1026 label = opts.get(r'label', '')
1027 msg = self.label(msg, label)
1028 dest.write(msg)
1029 except IOError as err:
1030 raise error.StdioError(err)
1031 finally:
1032 self._blockedtimes['stdio_blocked'] += \
1033 (util.timer() - starttime) * 1000
1003
1034
1004 def write_err(self, *args, **opts):
1035 def write_err(self, *args, **opts):
1005 self._write(self._ferr, *args, **opts)
1036 self._write(self._ferr, *args, **opts)
1006
1037
1007 def _write(self, dest, *args, **opts):
1038 def _write(self, dest, *args, **opts):
1039 # update write() as well if you touch this code
1008 if self._isbuffered(dest):
1040 if self._isbuffered(dest):
1009 if self._bufferapplylabels:
1041 label = opts.get(r'label', '')
1010 label = opts.get(r'label', '')
1042 if label and self._bufferapplylabels:
1011 self._buffers[-1].extend(self.label(a, label) for a in args)
1043 self._buffers[-1].extend(self.label(a, label) for a in args)
1012 else:
1044 else:
1013 self._buffers[-1].extend(args)
1045 self._buffers[-1].extend(args)
@@ -1015,6 +1047,7 b' class ui(object):'
1015 self._writenobuf(dest, *args, **opts)
1047 self._writenobuf(dest, *args, **opts)
1016
1048
1017 def _writenobuf(self, dest, *args, **opts):
1049 def _writenobuf(self, dest, *args, **opts):
1050 # update write() as well if you touch this code
1018 self._progclear()
1051 self._progclear()
1019 msg = b''.join(args)
1052 msg = b''.join(args)
1020
1053
@@ -16,6 +16,12 b' pub type Revision = i32;'
16
16
17 pub const NULL_REVISION: Revision = -1;
17 pub const NULL_REVISION: Revision = -1;
18
18
19 /// Same as `mercurial.node.wdirrev`
20 ///
21 /// This is also equal to `i32::max_value()`, but it's better to spell
22 /// it out explicitely, same as in `mercurial.node`
23 pub const WORKING_DIRECTORY_REVISION: Revision = 0x7fffffff;
24
19 /// The simplest expression of what we need of Mercurial DAGs.
25 /// The simplest expression of what we need of Mercurial DAGs.
20 pub trait Graph {
26 pub trait Graph {
21 /// Return the two parents of the given `Revision`.
27 /// Return the two parents of the given `Revision`.
@@ -27,4 +33,5 b' pub trait Graph {'
27 #[derive(Clone, Debug, PartialEq)]
33 #[derive(Clone, Debug, PartialEq)]
28 pub enum GraphError {
34 pub enum GraphError {
29 ParentOutOfRange(Revision),
35 ParentOutOfRange(Revision),
36 WorkingDirectoryUnsupported,
30 }
37 }
@@ -16,7 +16,7 b' extern crate python3_sys as python_sys;'
16
16
17 use self::python_sys::PyCapsule_Import;
17 use self::python_sys::PyCapsule_Import;
18 use cpython::{PyClone, PyErr, PyObject, PyResult, Python};
18 use cpython::{PyClone, PyErr, PyObject, PyResult, Python};
19 use hg::{Graph, GraphError, Revision};
19 use hg::{Graph, GraphError, Revision, WORKING_DIRECTORY_REVISION};
20 use libc::c_int;
20 use libc::c_int;
21 use std::ffi::CStr;
21 use std::ffi::CStr;
22 use std::mem::transmute;
22 use std::mem::transmute;
@@ -86,6 +86,9 b' impl Clone for Index {'
86 impl Graph for Index {
86 impl Graph for Index {
87 /// wrap a call to the C extern parents function
87 /// wrap a call to the C extern parents function
88 fn parents(&self, rev: Revision) -> Result<[Revision; 2], GraphError> {
88 fn parents(&self, rev: Revision) -> Result<[Revision; 2], GraphError> {
89 if rev == WORKING_DIRECTORY_REVISION {
90 return Err(GraphError::WorkingDirectoryUnsupported);
91 }
89 let mut res: [c_int; 2] = [0; 2];
92 let mut res: [c_int; 2] = [0; 2];
90 let code = unsafe {
93 let code = unsafe {
91 (self.parents)(
94 (self.parents)(
@@ -8,6 +8,8 b''
8 //! Bindings for Rust errors
8 //! Bindings for Rust errors
9 //!
9 //!
10 //! [`GraphError`] exposes `hg::GraphError` as a subclass of `ValueError`
10 //! [`GraphError`] exposes `hg::GraphError` as a subclass of `ValueError`
11 //! but some variants of `hg::GraphError` can be converted directly to other
12 //! existing Python exceptions if appropriate.
11 //!
13 //!
12 //! [`GraphError`]: struct.GraphError.html
14 //! [`GraphError`]: struct.GraphError.html
13 use cpython::exc::ValueError;
15 use cpython::exc::ValueError;
@@ -22,6 +24,15 b' impl GraphError {'
22 hg::GraphError::ParentOutOfRange(r) => {
24 hg::GraphError::ParentOutOfRange(r) => {
23 GraphError::new(py, ("ParentOutOfRange", r))
25 GraphError::new(py, ("ParentOutOfRange", r))
24 }
26 }
27 hg::GraphError::WorkingDirectoryUnsupported => {
28 match py
29 .import("mercurial.error")
30 .and_then(|m| m.get(py, "WdirUnsupported"))
31 {
32 Err(e) => e,
33 Ok(cls) => PyErr::from_instance(py, cls),
34 }
35 }
25 }
36 }
26 }
37 }
27 }
38 }
@@ -717,6 +717,9 b' Test clone from the repository in (emula'
717 $ hg -R src commit -m '#0'
717 $ hg -R src commit -m '#0'
718 $ hg -R src log -q
718 $ hg -R src log -q
719 0:e1bab28bca43
719 0:e1bab28bca43
720 $ hg -R src debugrevlog -c | egrep 'format|flags'
721 format : 0
722 flags : (none)
720 $ hg clone -U -q src dst
723 $ hg clone -U -q src dst
721 $ hg -R dst log -q
724 $ hg -R dst log -q
722 0:e1bab28bca43
725 0:e1bab28bca43
@@ -2,6 +2,11 b' from __future__ import absolute_import'
2 import sys
2 import sys
3 import unittest
3 import unittest
4
4
5 from mercurial import (
6 error,
7 node,
8 )
9
5 try:
10 try:
6 from mercurial import rustext
11 from mercurial import rustext
7 rustext.__name__ # trigger immediate actual import
12 rustext.__name__ # trigger immediate actual import
@@ -153,6 +158,12 b' class rustancestorstest(unittest.TestCas'
153 # rust-cpython issues appropriate str instances for Python 2 and 3
158 # rust-cpython issues appropriate str instances for Python 2 and 3
154 self.assertEqual(exc.args, ('ParentOutOfRange', 1))
159 self.assertEqual(exc.args, ('ParentOutOfRange', 1))
155
160
161 def testwdirunsupported(self):
162 # trying to access ancestors of the working directory raises
163 # WdirUnsupported directly
164 idx = self.parseindex()
165 with self.assertRaises(error.WdirUnsupported):
166 list(AncestorsIterator(idx, [node.wdirrev], -1, False))
156
167
157 if __name__ == '__main__':
168 if __name__ == '__main__':
158 import silenttestrunner
169 import silenttestrunner
General Comments 0
You need to be logged in to leave comments. Login now