##// END OF EJS Templates
merge with main
Thomas Arendsen Hein -
r5648:2079facc merge default
parent child Browse files
Show More
@@ -281,7 +281,7 b' hooks::'
281 commit to proceed. Non-zero status will cause the commit to fail.
281 commit to proceed. Non-zero status will cause the commit to fail.
282 Parent changeset IDs are in $HG_PARENT1 and $HG_PARENT2.
282 Parent changeset IDs are in $HG_PARENT1 and $HG_PARENT2.
283 preoutgoing;;
283 preoutgoing;;
284 Run before computing changes to send from the local repository to
284 Run before collecting changes to send from the local repository to
285 another. Non-zero status will cause failure. This lets you
285 another. Non-zero status will cause failure. This lets you
286 prevent pull over http or ssh. Also prevents against local pull,
286 prevent pull over http or ssh. Also prevents against local pull,
287 push (outbound) or bundle commands, but not effective, since you
287 push (outbound) or bundle commands, but not effective, since you
@@ -2029,6 +2029,7 b' def remove(ui, repo, *pats, **opts):'
2029 forget.append(abs)
2029 forget.append(abs)
2030 continue
2030 continue
2031 reason = _('has been marked for add (use -f to force removal)')
2031 reason = _('has been marked for add (use -f to force removal)')
2032 exact = 1 # force the message
2032 elif abs not in repo.dirstate:
2033 elif abs not in repo.dirstate:
2033 reason = _('is not managed')
2034 reason = _('is not managed')
2034 elif opts['after'] and not exact and abs not in deleted:
2035 elif opts['after'] and not exact and abs not in deleted:
@@ -67,7 +67,7 b' class _demandmod(object):'
67 return "<proxied module '%s'>" % self._data[0]
67 return "<proxied module '%s'>" % self._data[0]
68 return "<unloaded module '%s'>" % self._data[0]
68 return "<unloaded module '%s'>" % self._data[0]
69 def __call__(self, *args, **kwargs):
69 def __call__(self, *args, **kwargs):
70 raise TypeError("'unloaded module' object is not callable")
70 raise TypeError("%s object is not callable" % repr(self))
71 def __getattribute__(self, attr):
71 def __getattribute__(self, attr):
72 if attr in ('_data', '_extend', '_load', '_module'):
72 if attr in ('_data', '_extend', '_load', '_module'):
73 return object.__getattribute__(self, attr)
73 return object.__getattribute__(self, attr)
@@ -133,6 +133,8 b' def _runcatch(ui, args):'
133
133
134 except util.Abort, inst:
134 except util.Abort, inst:
135 ui.warn(_("abort: %s\n") % inst)
135 ui.warn(_("abort: %s\n") % inst)
136 except MemoryError:
137 ui.warn(_("abort: out of memory\n"))
136 except SystemExit, inst:
138 except SystemExit, inst:
137 # Commands shouldn't sys.exit directly, but give a return code.
139 # Commands shouldn't sys.exit directly, but give a return code.
138 # Just in case catch this and and pass exit code to caller.
140 # Just in case catch this and and pass exit code to caller.
@@ -1,35 +1,74 b''
1 import getopt
1 import getopt
2
2
3 def fancyopts(args, options, state):
3 def fancyopts(args, options, state):
4 long = []
4 """
5 short = ''
5 read args, parse options, and store options in state
6 map = {}
6
7 dt = {}
7 each option is a tuple of:
8
9 short option or ''
10 long option
11 default value
12 description
13
14 option types include:
15
16 boolean or none - option sets variable in state to true
17 string - parameter string is stored in state
18 list - parameter string is added to a list
19 integer - parameter strings is stored as int
20 function - call function with parameter
8
21
9 for s, l, d, c in options:
22 non-option args are returned
10 pl = l.replace('-', '_')
23 """
11 map['-'+s] = map['--'+l] = pl
24 namelist = []
12 if isinstance(d, list):
25 shortlist = ''
13 state[pl] = d[:]
26 argmap = {}
27 defmap = {}
28
29 for short, name, default, comment in options:
30 # convert opts to getopt format
31 oname = name
32 name = name.replace('-', '_')
33
34 argmap['-' + short] = argmap['--' + oname] = name
35 defmap[name] = default
36
37 # copy defaults to state
38 if isinstance(default, list):
39 state[name] = default[:]
40 elif callable(default):
41 print "whoa", name, default
42 state[name] = None
14 else:
43 else:
15 state[pl] = d
44 state[name] = default
16 dt[pl] = type(d)
17 if (d is not None and d is not True and d is not False and
18 not callable(d)):
19 if s: s += ':'
20 if l: l += '='
21 if s: short = short + s
22 if l: long.append(l)
23
45
24 opts, args = getopt.getopt(args, short, long)
46 # does it take a parameter?
47 if not (default is None or default is True or default is False):
48 if short: short += ':'
49 if oname: oname += '='
50 if short:
51 shortlist += short
52 if name:
53 namelist.append(oname)
54
55 # parse arguments
56 opts, args = getopt.getopt(args, shortlist, namelist)
25
57
26 for opt, arg in opts:
58 # transfer result to state
27 if dt[map[opt]] is type(fancyopts): state[map[opt]](state, map[opt], arg)
59 for opt, val in opts:
28 elif dt[map[opt]] is type(1): state[map[opt]] = int(arg)
60 name = argmap[opt]
29 elif dt[map[opt]] is type(''): state[map[opt]] = arg
61 t = type(defmap[name])
30 elif dt[map[opt]] is type([]): state[map[opt]].append(arg)
62 if t is type(fancyopts):
31 elif dt[map[opt]] is type(None): state[map[opt]] = True
63 state[name] = defmap[name](val)
32 elif dt[map[opt]] is type(False): state[map[opt]] = True
64 elif t is type(1):
65 state[name] = int(val)
66 elif t is type(''):
67 state[name] = val
68 elif t is type([]):
69 state[name].append(val)
70 elif t is type(None) or t is type(False):
71 state[name] = True
33
72
73 # return unparsed args
34 return args
74 return args
35
@@ -280,13 +280,13 b' def update(repo, node):'
280 # len(pl)==1, otherwise _merge.update() would have raised util.Abort:
280 # len(pl)==1, otherwise _merge.update() would have raised util.Abort:
281 repo.ui.status(_(" hg update %s\n hg update %s\n")
281 repo.ui.status(_(" hg update %s\n hg update %s\n")
282 % (pl[0].rev(), repo.changectx(node).rev()))
282 % (pl[0].rev(), repo.changectx(node).rev()))
283 return stats[3]
283 return stats[3] > 0
284
284
285 def clean(repo, node, show_stats=True):
285 def clean(repo, node, show_stats=True):
286 """forcibly switch the working directory to node, clobbering changes"""
286 """forcibly switch the working directory to node, clobbering changes"""
287 stats = _merge.update(repo, node, False, True, None)
287 stats = _merge.update(repo, node, False, True, None)
288 if show_stats: _showstats(repo, stats)
288 if show_stats: _showstats(repo, stats)
289 return stats[3]
289 return stats[3] > 0
290
290
291 def merge(repo, node, force=None, remind=True):
291 def merge(repo, node, force=None, remind=True):
292 """branch merge with node, resolving changes"""
292 """branch merge with node, resolving changes"""
@@ -301,11 +301,11 b' def merge(repo, node, force=None, remind'
301 % (pl[0].rev(), pl[1].rev()))
301 % (pl[0].rev(), pl[1].rev()))
302 elif remind:
302 elif remind:
303 repo.ui.status(_("(branch merge, don't forget to commit)\n"))
303 repo.ui.status(_("(branch merge, don't forget to commit)\n"))
304 return stats[3]
304 return stats[3] > 0
305
305
306 def revert(repo, node, choose):
306 def revert(repo, node, choose):
307 """revert changes to revision in node without updating dirstate"""
307 """revert changes to revision in node without updating dirstate"""
308 return _merge.update(repo, node, False, True, choose)[3]
308 return _merge.update(repo, node, False, True, choose)[3] > 0
309
309
310 def verify(repo):
310 def verify(repo):
311 """verify the consistency of a repository"""
311 """verify the consistency of a repository"""
@@ -6,18 +6,21 b''
6 # of the GNU General Public License, incorporated herein by reference.
6 # of the GNU General Public License, incorporated herein by reference.
7
7
8 from i18n import _
8 from i18n import _
9 import util
9 import util, re
10
11 _commentre = None
10
12
11 def _parselines(fp):
13 def _parselines(fp):
12 for line in fp:
14 for line in fp:
13 if not line.endswith('\n'):
15 if "#" in line:
14 line += '\n'
16 global _commentre
15 escape = False
17 if not _commentre:
16 for i in xrange(len(line)):
18 _commentre = re.compile(r'((^|[^\\])(\\\\)*)#.*')
17 if escape: escape = False
19 # remove comments prefixed by an even number of escapes
18 elif line[i] == '\\': escape = True
20 line = _commentre.sub(r'\1', line)
19 elif line[i] == '#': break
21 # fixup properly escaped comments that survived the above
20 line = line[:i].rstrip()
22 line = line.replace("\\#", "#")
23 line = line.rstrip()
21 if line:
24 if line:
22 yield line
25 yield line
23
26
@@ -661,6 +661,7 b' class localrepository(repo.repository):'
661 match=util.always, force=False, force_editor=False,
661 match=util.always, force=False, force_editor=False,
662 p1=None, p2=None, extra={}, empty_ok=False):
662 p1=None, p2=None, extra={}, empty_ok=False):
663 wlock = lock = tr = None
663 wlock = lock = tr = None
664 valid = 0 # don't save the dirstate if this isn't set
664 try:
665 try:
665 commit = []
666 commit = []
666 remove = []
667 remove = []
@@ -747,6 +748,9 b' class localrepository(repo.repository):'
747 if old_exec != new_exec or old_link != new_link:
748 if old_exec != new_exec or old_link != new_link:
748 changed.append(f)
749 changed.append(f)
749 m1.set(f, new_exec, new_link)
750 m1.set(f, new_exec, new_link)
751 if use_dirstate:
752 self.dirstate.normal(f)
753
750 except (OSError, IOError):
754 except (OSError, IOError):
751 if use_dirstate:
755 if use_dirstate:
752 self.ui.warn(_("trouble committing %s!\n") % f)
756 self.ui.warn(_("trouble committing %s!\n") % f)
@@ -817,14 +821,15 b' class localrepository(repo.repository):'
817 if use_dirstate or update_dirstate:
821 if use_dirstate or update_dirstate:
818 self.dirstate.setparents(n)
822 self.dirstate.setparents(n)
819 if use_dirstate:
823 if use_dirstate:
820 for f in new:
821 self.dirstate.normal(f)
822 for f in removed:
824 for f in removed:
823 self.dirstate.forget(f)
825 self.dirstate.forget(f)
826 valid = 1 # our dirstate updates are complete
824
827
825 self.hook("commit", node=hex(n), parent1=xp1, parent2=xp2)
828 self.hook("commit", node=hex(n), parent1=xp1, parent2=xp2)
826 return n
829 return n
827 finally:
830 finally:
831 if not valid: # don't save our updated dirstate
832 self.dirstate.invalidate()
828 del tr, lock, wlock
833 del tr, lock, wlock
829
834
830 def walk(self, node=None, files=[], match=util.always, badmatch=None):
835 def walk(self, node=None, files=[], match=util.always, badmatch=None):
General Comments 0
You need to be logged in to leave comments. Login now