121 |
121 |
122 def checknewlabel(repo, lbl, kind): |
122 def checknewlabel(repo, lbl, kind): |
123 # Do not use the "kind" parameter in ui output. |
123 # Do not use the "kind" parameter in ui output. |
124 # It makes strings difficult to translate. |
124 # It makes strings difficult to translate. |
125 if lbl in ['tip', '.', 'null']: |
125 if lbl in ['tip', '.', 'null']: |
126 raise util.Abort(_("the name '%s' is reserved") % lbl) |
126 raise error.Abort(_("the name '%s' is reserved") % lbl) |
127 for c in (':', '\0', '\n', '\r'): |
127 for c in (':', '\0', '\n', '\r'): |
128 if c in lbl: |
128 if c in lbl: |
129 raise util.Abort(_("%r cannot be used in a name") % c) |
129 raise error.Abort(_("%r cannot be used in a name") % c) |
130 try: |
130 try: |
131 int(lbl) |
131 int(lbl) |
132 raise util.Abort(_("cannot use an integer as a name")) |
132 raise error.Abort(_("cannot use an integer as a name")) |
133 except ValueError: |
133 except ValueError: |
134 pass |
134 pass |
135 |
135 |
136 def checkfilename(f): |
136 def checkfilename(f): |
137 '''Check that the filename f is an acceptable filename for a tracked file''' |
137 '''Check that the filename f is an acceptable filename for a tracked file''' |
138 if '\r' in f or '\n' in f: |
138 if '\r' in f or '\n' in f: |
139 raise util.Abort(_("'\\n' and '\\r' disallowed in filenames: %r") % f) |
139 raise error.Abort(_("'\\n' and '\\r' disallowed in filenames: %r") % f) |
140 |
140 |
141 def checkportable(ui, f): |
141 def checkportable(ui, f): |
142 '''Check if filename f is portable and warn or abort depending on config''' |
142 '''Check if filename f is portable and warn or abort depending on config''' |
143 checkfilename(f) |
143 checkfilename(f) |
144 abort, warn = checkportabilityalert(ui) |
144 abort, warn = checkportabilityalert(ui) |
145 if abort or warn: |
145 if abort or warn: |
146 msg = util.checkwinfilename(f) |
146 msg = util.checkwinfilename(f) |
147 if msg: |
147 if msg: |
148 msg = "%s: %r" % (msg, f) |
148 msg = "%s: %r" % (msg, f) |
149 if abort: |
149 if abort: |
150 raise util.Abort(msg) |
150 raise error.Abort(msg) |
151 ui.warn(_("warning: %s\n") % msg) |
151 ui.warn(_("warning: %s\n") % msg) |
152 |
152 |
153 def checkportabilityalert(ui): |
153 def checkportabilityalert(ui): |
154 '''check if the user's config requests nothing, a warning, or abort for |
154 '''check if the user's config requests nothing, a warning, or abort for |
155 non-portable filenames''' |
155 non-portable filenames''' |
180 return |
180 return |
181 fl = encoding.lower(f) |
181 fl = encoding.lower(f) |
182 if fl in self._loweredfiles and f not in self._dirstate: |
182 if fl in self._loweredfiles and f not in self._dirstate: |
183 msg = _('possible case-folding collision for %s') % f |
183 msg = _('possible case-folding collision for %s') % f |
184 if self._abort: |
184 if self._abort: |
185 raise util.Abort(msg) |
185 raise error.Abort(msg) |
186 self._ui.warn(_("warning: %s\n") % msg) |
186 self._ui.warn(_("warning: %s\n") % msg) |
187 self._loweredfiles.add(fl) |
187 self._loweredfiles.add(fl) |
188 self._newfiles.add(f) |
188 self._newfiles.add(f) |
189 |
189 |
190 def filteredhash(repo, maxrev): |
190 def filteredhash(repo, maxrev): |
581 def __init__(self, vfs): |
581 def __init__(self, vfs): |
582 auditvfs.__init__(self, vfs) |
582 auditvfs.__init__(self, vfs) |
583 |
583 |
584 def __call__(self, path, mode='r', *args, **kw): |
584 def __call__(self, path, mode='r', *args, **kw): |
585 if mode not in ('r', 'rb'): |
585 if mode not in ('r', 'rb'): |
586 raise util.Abort('this vfs is read only') |
586 raise error.Abort('this vfs is read only') |
587 return self.vfs(path, mode, *args, **kw) |
587 return self.vfs(path, mode, *args, **kw) |
588 |
588 |
589 def join(self, path, *insidef): |
589 def join(self, path, *insidef): |
590 return self.vfs.join(path, *insidef) |
590 return self.vfs.join(path, *insidef) |
591 |
591 |
687 if not revspec and revspec != 0: |
687 if not revspec and revspec != 0: |
688 return repo[default] |
688 return repo[default] |
689 |
689 |
690 l = revrange(repo, [revspec]) |
690 l = revrange(repo, [revspec]) |
691 if not l: |
691 if not l: |
692 raise util.Abort(_('empty revision set')) |
692 raise error.Abort(_('empty revision set')) |
693 return repo[l.last()] |
693 return repo[l.last()] |
694 |
694 |
695 def _pairspec(revspec): |
695 def _pairspec(revspec): |
696 tree = revset.parse(revspec) |
696 tree = revset.parse(revspec) |
697 tree = revset.optimize(tree, True)[1] # fix up "x^:y" -> "(x^):y" |
697 tree = revset.optimize(tree, True)[1] # fix up "x^:y" -> "(x^):y" |