merge with stable
authorMartin Geisler <mg@aragost.com>
Fri, 04 Nov 2011 10:39:04 +0100
changeset 15432 2ddae301d0a2
parent 15431 c41055249725 (diff)
parent 15430 54c0517c0fe8 (current diff)
child 15433 4df3de1d44ce
merge with stable
mercurial/help/subrepos.txt
--- a/hgext/rebase.py	Fri Nov 04 10:31:38 2011 +0100
+++ b/hgext/rebase.py	Fri Nov 04 10:39:04 2011 +0100
@@ -185,21 +185,19 @@
                 dest = repo[destf]
 
             if revf:
-                revgen = repo.set('%lr', revf)
+                rebaseset = repo.revs('%lr', revf)
             elif srcf:
-                revgen = repo.set('(%r)::', srcf)
+                rebaseset = repo.revs('(%r)::', srcf)
             else:
                 base = basef or '.'
-                revgen = repo.set('(children(ancestor(%r, %d)) and ::(%r))::',
-                                  base, dest, base)
-
-            rebaseset = [c.rev() for c in revgen]
+                rebaseset = repo.revs('(children(ancestor(%r, %d)) & ::%r)::',
+                    base, dest, base)
 
             if not rebaseset:
                 repo.ui.debug('base is ancestor of destination')
                 result = None
-            elif not keepf and list(repo.set('first(children(%ld) - %ld)',
-                                            rebaseset, rebaseset)):
+            elif not keepf and list(repo.revs('first(children(%ld) - %ld)',
+                                              rebaseset, rebaseset)):
                 raise util.Abort(
                     _("can't remove original changesets with"
                       " unrebased descendants"),
@@ -582,8 +580,7 @@
         # rebase on ancestor, force detach
         detach = True
     if detach:
-        detachset = [c.rev() for c in repo.set('::%d - ::%d - %d',
-                                                root, commonbase, root)]
+        detachset = repo.revs('::%d - ::%d - %d', root, commonbase, root)
 
     repo.ui.debug('rebase onto %d starting from %d\n' % (dest, root))
     state = dict.fromkeys(rebaseset, nullrev)
--- a/mercurial/cmdutil.py	Fri Nov 04 10:31:38 2011 +0100
+++ b/mercurial/cmdutil.py	Fri Nov 04 10:39:04 2011 +0100
@@ -1165,15 +1165,19 @@
             if ui.verbose or not exact:
                 ui.status(_('adding %s\n') % match.rel(join(f)))
 
-    if listsubrepos:
-        for subpath in wctx.substate:
-            sub = wctx.sub(subpath)
-            try:
-                submatch = matchmod.narrowmatcher(subpath, match)
+    for subpath in wctx.substate:
+        sub = wctx.sub(subpath)
+        try:
+            submatch = matchmod.narrowmatcher(subpath, match)
+            if listsubrepos:
                 bad.extend(sub.add(ui, submatch, dryrun, prefix))
-            except error.LookupError:
-                ui.status(_("skipping missing subrepository: %s\n")
-                               % join(subpath))
+            else:
+                for f in sub.walk(submatch):
+                    if submatch.exact(f):
+                        bad.extend(sub.add(ui, submatch, dryrun, prefix))
+        except error.LookupError:
+            ui.status(_("skipping missing subrepository: %s\n")
+                           % join(subpath))
 
     if not dryrun:
         rejected = wctx.add(names, prefix)
--- a/mercurial/commands.py	Fri Nov 04 10:31:38 2011 +0100
+++ b/mercurial/commands.py	Fri Nov 04 10:39:04 2011 +0100
@@ -2534,16 +2534,16 @@
         revs = scmutil.revrange(repo, revs)
 
     # check for merges
-    for ctx in repo.set('%ld and merge()', revs):
-        ui.warn(_('skipping ungraftable merge revision %s\n') % ctx.rev())
-        revs.remove(ctx.rev())
+    for rev in repo.revs('%ld and merge()', revs):
+        ui.warn(_('skipping ungraftable merge revision %s\n') % rev)
+        revs.remove(rev)
     if not revs:
         return -1
 
     # check for ancestors of dest branch
-    for ctx in repo.set('::. and %ld', revs):
-        ui.warn(_('skipping ancestor revision %s\n') % ctx.rev())
-        revs.remove(ctx.rev())
+    for rev in repo.revs('::. and %ld', revs):
+        ui.warn(_('skipping ancestor revision %s\n') % rev)
+        revs.remove(rev)
     if not revs:
         return -1
 
@@ -3705,14 +3705,14 @@
     [('f', 'follow', None,
      _('follow changeset history, or file history across copies and renames')),
     ('', 'follow-first', None,
-     _('only follow the first parent of merge changesets')),
+     _('only follow the first parent of merge changesets (DEPRECATED)')),
     ('d', 'date', '', _('show revisions matching date spec'), _('DATE')),
     ('C', 'copies', None, _('show copied files')),
     ('k', 'keyword', [],
      _('do case-insensitive search for a given text'), _('TEXT')),
     ('r', 'rev', [], _('show the specified revision or range'), _('REV')),
     ('', 'removed', None, _('include revisions where files were removed')),
-    ('m', 'only-merges', None, _('show only merges')),
+    ('m', 'only-merges', None, _('show only merges (DEPRECATED)')),
     ('u', 'user', [], _('revisions committed by user'), _('USER')),
     ('', 'only-branch', [],
      _('show only changesets within the given named branch (DEPRECATED)'),
--- a/mercurial/hbisect.py	Fri Nov 04 10:31:38 2011 +0100
+++ b/mercurial/hbisect.py	Fri Nov 04 10:39:04 2011 +0100
@@ -179,7 +179,7 @@
         # that's because the bisection can go either way
         range = '( bisect(bad)::bisect(good) | bisect(good)::bisect(bad) )'
 
-        _t = [c.rev() for c in repo.set('bisect(good)::bisect(bad)')]
+        _t = repo.revs('bisect(good)::bisect(bad)')
         # The sets of topologically good or bad csets
         if len(_t) == 0:
             # Goods are topologically after bads
@@ -206,22 +206,21 @@
         ignored = '( ( (%s) | (%s) ) - (%s) )' % (iba, iga, range)
 
         if status == 'range':
-            return [c.rev() for c in repo.set(range)]
+            return repo.revs(range)
         elif status == 'pruned':
-            return [c.rev() for c in repo.set(pruned)]
+            return repo.revs(pruned)
         elif status == 'untested':
-            return [c.rev() for c in repo.set(untested)]
+            return repo.revs(untested)
         elif status == 'ignored':
-            return [c.rev() for c in repo.set(ignored)]
+            return repo.revs(ignored)
         elif status == "goods":
-            return [c.rev() for c in repo.set(goods)]
+            return repo.revs(goods)
         elif status == "bads":
-            return [c.rev() for c in repo.set(bads)]
-
+            return repo.revs(bads)
         else:
             raise error.ParseError(_('invalid bisect state'))
 
-def label(repo, node, short=False):
+def label(repo, node):
     rev = repo.changelog.rev(node)
 
     # Try explicit sets
--- a/mercurial/help/subrepos.txt	Fri Nov 04 10:31:38 2011 +0100
+++ b/mercurial/help/subrepos.txt	Fri Nov 04 10:39:04 2011 +0100
@@ -73,8 +73,10 @@
 -----------------------------------
 
 :add: add does not recurse in subrepos unless -S/--subrepos is
-    specified. Git and Subversion subrepositories are currently
-    silently ignored.
+    specified.  However, if you specify the full path of a file in a
+    subrepo, it will be added even without -S/--subrepos specified.
+    Git and Subversion subrepositories are currently silently
+    ignored.
 
 :archive: archive does not recurse in subrepositories unless
     -S/--subrepos is specified.
--- a/mercurial/localrepo.py	Fri Nov 04 10:31:38 2011 +0100
+++ b/mercurial/localrepo.py	Fri Nov 04 10:39:04 2011 +0100
@@ -220,15 +220,18 @@
         for i in xrange(len(self)):
             yield i
 
+    def revs(self, expr, *args):
+        '''Return a list of revisions matching the given revset'''
+        expr = revset.formatspec(expr, *args)
+        m = revset.match(None, expr)
+        return [r for r in m(self, range(len(self)))]
+
     def set(self, expr, *args):
         '''
         Yield a context for each matching revision, after doing arg
         replacement via revset.formatspec
         '''
-
-        expr = revset.formatspec(expr, *args)
-        m = revset.match(None, expr)
-        for r in m(self, range(len(self))):
+        for r in self.revs(expr, *args):
             yield self[r]
 
     def url(self):
--- a/mercurial/subrepo.py	Fri Nov 04 10:31:38 2011 +0100
+++ b/mercurial/subrepo.py	Fri Nov 04 10:39:04 2011 +0100
@@ -353,6 +353,12 @@
                         unit=_('files'), total=total)
         ui.progress(_('archiving (%s)') % relpath, None)
 
+    def walk(self, match):
+        '''
+        walk recursively through the directory tree, finding all files
+        matched by the match function
+        '''
+        pass
 
 class hgsubrepo(abstractsubrepo):
     def __init__(self, ctx, path, state):
@@ -543,6 +549,9 @@
         ctx = self._repo[rev]
         return ctx.flags(name)
 
+    def walk(self, match):
+        ctx = self._repo[None]
+        return ctx.walk(match)
 
 class svnsubrepo(abstractsubrepo):
     def __init__(self, ctx, path, state):
--- a/tests/test-subrepo.t	Fri Nov 04 10:31:38 2011 +0100
+++ b/tests/test-subrepo.t	Fri Nov 04 10:39:04 2011 +0100
@@ -883,3 +883,125 @@
   rm2
   
   
+Test behavior of add for explicit path in subrepo:
+  $ cd ..
+  $ hg init addtests
+  $ cd addtests
+  $ echo s = s > .hgsub
+  $ hg add .hgsub
+  $ hg init s
+  $ hg ci -m0
+  committing subrepository s
+Adding with an explicit path in a subrepo adds the file
+  $ echo c1 > f1
+  $ echo c2 > s/f2
+  $ hg st -S
+  ? f1
+  ? s/f2
+  $ hg add s/f2
+  $ hg st -S
+  A s/f2
+  ? f1
+  $ hg ci -R s -m0
+  $ hg ci -Am1
+  adding f1
+  committing subrepository s
+Adding with an explicit path in a subrepo with -S has the same behavior
+  $ echo c3 > f3
+  $ echo c4 > s/f4
+  $ hg st -S
+  ? f3
+  ? s/f4
+  $ hg add -S s/f4
+  $ hg st -S
+  A s/f4
+  ? f3
+  $ hg ci -R s -m1
+  $ hg ci -Ama2
+  adding f3
+  committing subrepository s
+Adding without a path or pattern silently ignores subrepos
+  $ echo c5 > f5
+  $ echo c6 > s/f6
+  $ echo c7 > s/f7
+  $ hg st -S
+  ? f5
+  ? s/f6
+  ? s/f7
+  $ hg add
+  adding f5
+  $ hg st -S
+  A f5
+  ? s/f6
+  ? s/f7
+  $ hg ci -R s -Am2
+  adding f6
+  adding f7
+  $ hg ci -m3
+  committing subrepository s
+Adding without a path or pattern with -S also adds files in subrepos
+  $ echo c8 > f8
+  $ echo c9 > s/f9
+  $ echo c10 > s/f10
+  $ hg st -S
+  ? f8
+  ? s/f10
+  ? s/f9
+  $ hg add -S
+  adding f8
+  adding s/f10
+  adding s/f9
+  $ hg st -S
+  A f8
+  A s/f10
+  A s/f9
+  $ hg ci -R s -m3
+  $ hg ci -m4
+  committing subrepository s
+Adding with a pattern silently ignores subrepos
+  $ echo c11 > fm11
+  $ echo c12 > fn12
+  $ echo c13 > s/fm13
+  $ echo c14 > s/fn14
+  $ hg st -S
+  ? fm11
+  ? fn12
+  ? s/fm13
+  ? s/fn14
+  $ hg add 'glob:**fm*'
+  adding fm11
+  $ hg st -S
+  A fm11
+  ? fn12
+  ? s/fm13
+  ? s/fn14
+  $ hg ci -R s -Am4
+  adding fm13
+  adding fn14
+  $ hg ci -Am5
+  adding fn12
+  committing subrepository s
+Adding with a pattern with -S also adds matches in subrepos
+  $ echo c15 > fm15
+  $ echo c16 > fn16
+  $ echo c17 > s/fm17
+  $ echo c18 > s/fn18
+  $ hg st -S
+  ? fm15
+  ? fn16
+  ? s/fm17
+  ? s/fn18
+  $ hg add -S 'glob:**fm*'
+  adding fm15
+  adding s/fm17
+  $ hg st -S
+  A fm15
+  A s/fm17
+  ? fn16
+  ? s/fn18
+  $ hg ci -R s -Am5
+  adding fn18
+  $ hg ci -Am6
+  adding fn16
+  committing subrepository s
+  $ cd ..