Show More
@@ -396,6 +396,11 class revlog(object): | |||
|
396 | 396 | newversionflags = REVLOGV1 | FLAG_INLINE_DATA |
|
397 | 397 | if 'generaldelta' in opts: |
|
398 | 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 | 404 | else: |
|
400 | 405 | newversionflags = REVLOG_DEFAULT_VERSION |
|
401 | 406 | |
@@ -896,8 +901,6 class revlog(object): | |||
|
896 | 901 | common = [nullrev] |
|
897 | 902 | |
|
898 | 903 | if rustext is not None: |
|
899 | # TODO: WdirUnsupported should be raised instead of GraphError | |
|
900 | # if common includes wdirrev | |
|
901 | 904 | return rustext.ancestor.MissingAncestors(self.index, common) |
|
902 | 905 | return ancestor.incrementalmissingancestors(self.parentrevs, common) |
|
903 | 906 |
@@ -183,7 +183,8 class partialdiscovery(object): | |||
|
183 | 183 | def addcommons(self, commons): |
|
184 | 184 | """registrer nodes known as common""" |
|
185 | 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 | 189 | def addmissings(self, missings): |
|
189 | 190 | """registrer some nodes as missing""" |
@@ -999,15 +999,47 class ui(object): | |||
|
999 | 999 | "cmdname.type" is recommended. For example, status issues |
|
1000 | 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 | 1035 | def write_err(self, *args, **opts): |
|
1005 | 1036 | self._write(self._ferr, *args, **opts) |
|
1006 | 1037 | |
|
1007 | 1038 | def _write(self, dest, *args, **opts): |
|
1039 | # update write() as well if you touch this code | |
|
1008 | 1040 | if self._isbuffered(dest): |
|
1009 | if self._bufferapplylabels: | |
|
1010 | 1041 |
|
|
1042 | if label and self._bufferapplylabels: | |
|
1011 | 1043 | self._buffers[-1].extend(self.label(a, label) for a in args) |
|
1012 | 1044 | else: |
|
1013 | 1045 | self._buffers[-1].extend(args) |
@@ -1015,6 +1047,7 class ui(object): | |||
|
1015 | 1047 | self._writenobuf(dest, *args, **opts) |
|
1016 | 1048 | |
|
1017 | 1049 | def _writenobuf(self, dest, *args, **opts): |
|
1050 | # update write() as well if you touch this code | |
|
1018 | 1051 | self._progclear() |
|
1019 | 1052 | msg = b''.join(args) |
|
1020 | 1053 |
@@ -16,6 +16,12 pub type Revision = i32; | |||
|
16 | 16 | |
|
17 | 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 | 25 | /// The simplest expression of what we need of Mercurial DAGs. |
|
20 | 26 | pub trait Graph { |
|
21 | 27 | /// Return the two parents of the given `Revision`. |
@@ -27,4 +33,5 pub trait Graph { | |||
|
27 | 33 | #[derive(Clone, Debug, PartialEq)] |
|
28 | 34 | pub enum GraphError { |
|
29 | 35 | ParentOutOfRange(Revision), |
|
36 | WorkingDirectoryUnsupported, | |
|
30 | 37 | } |
@@ -16,7 +16,7 extern crate python3_sys as python_sys; | |||
|
16 | 16 | |
|
17 | 17 | use self::python_sys::PyCapsule_Import; |
|
18 | 18 | use cpython::{PyClone, PyErr, PyObject, PyResult, Python}; |
|
19 | use hg::{Graph, GraphError, Revision}; | |
|
19 | use hg::{Graph, GraphError, Revision, WORKING_DIRECTORY_REVISION}; | |
|
20 | 20 | use libc::c_int; |
|
21 | 21 | use std::ffi::CStr; |
|
22 | 22 | use std::mem::transmute; |
@@ -86,6 +86,9 impl Clone for Index { | |||
|
86 | 86 | impl Graph for Index { |
|
87 | 87 | /// wrap a call to the C extern parents function |
|
88 | 88 | fn parents(&self, rev: Revision) -> Result<[Revision; 2], GraphError> { |
|
89 | if rev == WORKING_DIRECTORY_REVISION { | |
|
90 | return Err(GraphError::WorkingDirectoryUnsupported); | |
|
91 | } | |
|
89 | 92 | let mut res: [c_int; 2] = [0; 2]; |
|
90 | 93 | let code = unsafe { |
|
91 | 94 | (self.parents)( |
@@ -8,6 +8,8 | |||
|
8 | 8 | //! Bindings for Rust errors |
|
9 | 9 | //! |
|
10 | 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 | 14 | //! [`GraphError`]: struct.GraphError.html |
|
13 | 15 | use cpython::exc::ValueError; |
@@ -22,6 +24,15 impl GraphError { | |||
|
22 | 24 | hg::GraphError::ParentOutOfRange(r) => { |
|
23 | 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), | |
|
25 | 34 | } |
|
26 | 35 | } |
|
27 | 36 | } |
|
37 | } | |
|
38 | } |
@@ -717,6 +717,9 Test clone from the repository in (emula | |||
|
717 | 717 | $ hg -R src commit -m '#0' |
|
718 | 718 | $ hg -R src log -q |
|
719 | 719 | 0:e1bab28bca43 |
|
720 | $ hg -R src debugrevlog -c | egrep 'format|flags' | |
|
721 | format : 0 | |
|
722 | flags : (none) | |
|
720 | 723 | $ hg clone -U -q src dst |
|
721 | 724 | $ hg -R dst log -q |
|
722 | 725 | 0:e1bab28bca43 |
@@ -2,6 +2,11 from __future__ import absolute_import | |||
|
2 | 2 | import sys |
|
3 | 3 | import unittest |
|
4 | 4 | |
|
5 | from mercurial import ( | |
|
6 | error, | |
|
7 | node, | |
|
8 | ) | |
|
9 | ||
|
5 | 10 | try: |
|
6 | 11 | from mercurial import rustext |
|
7 | 12 | rustext.__name__ # trigger immediate actual import |
@@ -153,6 +158,12 class rustancestorstest(unittest.TestCas | |||
|
153 | 158 | # rust-cpython issues appropriate str instances for Python 2 and 3 |
|
154 | 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 | 168 | if __name__ == '__main__': |
|
158 | 169 | import silenttestrunner |
General Comments 0
You need to be logged in to leave comments.
Login now