Commits

Nicolas Dumazet  committed 928603c

rm pushed patch; add another.

  • Participants
  • Parent commits 262d4c5

Comments (0)

Files changed (5)

 diff --git a/hgext/graphlog.py b/hgext/graphlog.py
 --- a/hgext/graphlog.py
 +++ b/hgext/graphlog.py
-@@ -248,7 +248,7 @@
+@@ -241,15 +241,15 @@
+     check_unsupported_flags(opts)
+     limit = cmdutil.loglimit(opts)
+     start, stop = get_revs(repo, opts["rev"])
+-    stop = max(stop, start - limit + 1)
+     if start == nullrev:
+         return
+ 
      if path:
          path = util.canonpath(repo.root, os.getcwd(), path)
      if path: # could be reset in canonpath
 -        revdag = graphmod.filerevs(repo, path, start, stop)
 +        revdag = graphmod.filerevs(repo, path, start, stop, limit)
      else:
++        stop = max(stop, start - limit + 1)
          revdag = graphmod.revisions(repo, start, stop)
  
+     displayer = show_changeset(ui, repo, opts, buffered=True)
 diff --git a/mercurial/graphmod.py b/mercurial/graphmod.py
 --- a/mercurial/graphmod.py
 +++ b/mercurial/graphmod.py
  
  CHANGESET = 'C'
  
-@@ -36,20 +37,25 @@
+@@ -36,21 +37,25 @@
          yield (cur, CHANGESET, ctx, sorted(parents))
          cur -= 1
  
      file from revision start down to revision stop.
      """
      filerev = len(repo.file(path)) - 1
+-    while filerev >= 0:
++    if limit < sys.maxint:
++        lower = max(0, filerev - limit + 1)
++    else:
++        lower = 0
 +    count = 0
-     while filerev >= 0:
++    rev = stop + 1
++    while filerev >= lower and rev > stop:
          fctx = repo.filectx(path, fileid=filerev)
          parents = [f.linkrev() for f in fctx.parents() if f.path() == path]
          rev = fctx.rev()
          if rev <= start:
              yield (rev, CHANGESET, fctx.changectx(), sorted(parents))
 -        if rev <= stop:
-+        if limit < sys.maxint:
-+            count += 1
-+            if count == limit:
-+                break
-+        elif rev <= stop:
-             break
+-            break
          filerev -= 1
  
+ def nodes(repo, nodes):
 diff --git a/tests/test-glog b/tests/test-glog
 --- a/tests/test-glog
 +++ b/tests/test-glog
 
 coding style: use iterators instead of list comprehensions
 
-
 diff --git a/hgext/bugzilla.py b/hgext/bugzilla.py
 --- a/hgext/bugzilla.py
 +++ b/hgext/bugzilla.py
 diff --git a/mercurial/commands.py b/mercurial/commands.py
 --- a/mercurial/commands.py
 +++ b/mercurial/commands.py
-@@ -128,7 +128,7 @@
-             l = [f(n) for n, dummy in lines]
-             if l:
-                 ml = max(map(len, l))
--                pieces.append(["%*s" % (ml, x) for x in l])
-+                pieces.append("%*s" % (ml, x) for x in l)
- 
-         if pieces:
-             for p, l in zip(zip(*pieces), lines):
 @@ -454,8 +454,8 @@
          realhead = tag in activebranches
          open = node in repo.branchheads(tag, closed=False)
          if p.rev() == -1:
              if not len(repo):
                  t += _(' (empty repository)')
-@@ -2950,7 +2950,7 @@
- 
-     st = list(repo.status(unknown=True))[:7]
-     ms = merge_.mergestate(repo)
--    st.append([f for f in ms if f == 'u'])
-+    st.append(f for f in ms if f == 'u')
-     labels = [_('%d modified'), _('%d added'), _('%d removed'),
-               _('%d deleted'), _('%d unknown'), _('%d ignored'),
-               _('%d unresolved')]
 diff --git a/mercurial/copies.py b/mercurial/copies.py
 --- a/mercurial/copies.py
 +++ b/mercurial/copies.py
 diff --git a/mercurial/revlog.py b/mercurial/revlog.py
 --- a/mercurial/revlog.py
 +++ b/mercurial/revlog.py
-@@ -658,7 +658,7 @@
+@@ -680,7 +680,7 @@
              roots = list(roots)
              if not roots:
                  return nonodes
          else:
              roots = [nullid] # Everybody's a descendent of nullid
              lowestrev = nullrev
-@@ -685,7 +685,7 @@
+@@ -707,7 +707,7 @@
              # Start at the top and keep marking parents until we're done.
              nodestotag = set(heads)
              # Remember where the top was so we can use it as a limit later.
              while nodestotag:
                  # grab a node to tag
                  n = nodestotag.pop()
-@@ -701,8 +701,8 @@
+@@ -723,8 +723,8 @@
                          # and we haven't already been marked as an ancestor
                          ancestors.add(n) # Mark as ancestor
                          # Add non-nullid parents to list of nodes to tag.
                      elif n in heads: # We've seen it before, is it a fake head?
                          # So it is, real heads should not be the ancestors of
                          # any other heads.
-@@ -721,7 +721,7 @@
+@@ -743,7 +743,7 @@
                  roots = [n for n in roots if n in ancestors]
                  # Recompute the lowest revision
                  if roots:
                  else:
                      # No more roots?  Return empty list
                      return nonodes
-@@ -810,7 +810,7 @@
+@@ -832,7 +832,7 @@
              start = nullid
          if stop is None:
              stop = []
+# HG changeset patch
+# User Nicolas Dumazet <nicdumz.commits@gmail.com>
+# Date 1260718349 -32400
+cmdutil: loglimit: return None as default value instead of sys.maxint
+
+Semantically, it is better to use None over any other value when there is
+"no value". Using maxint in this context is quite hackish, and is not forward
+compatible.
+
+diff --git a/hgext/graphlog.py b/hgext/graphlog.py
+--- a/hgext/graphlog.py
++++ b/hgext/graphlog.py
+@@ -249,7 +249,8 @@
+     if path: # could be reset in canonpath
+         revdag = graphmod.filerevs(repo, path, start, stop, limit)
+     else:
+-        stop = max(stop, start - limit + 1)
++        if limit is not None:
++            stop = max(stop, start - limit + 1)
+         revdag = graphmod.revisions(repo, start, stop)
+ 
+     displayer = show_changeset(ui, repo, opts, buffered=True)
+@@ -259,7 +260,7 @@
+ def graphrevs(repo, nodes, opts):
+     limit = cmdutil.loglimit(opts)
+     nodes.reverse()
+-    if limit < sys.maxint:
++    if limit is not None:
+         nodes = nodes[:limit]
+     return graphmod.nodes(repo, nodes)
+ 
+diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
+--- a/mercurial/cmdutil.py
++++ b/mercurial/cmdutil.py
+@@ -94,8 +94,6 @@
+         except ValueError:
+             raise util.Abort(_('limit must be a positive integer'))
+         if limit <= 0: raise util.Abort(_('limit must be positive'))
+-    else:
+-        limit = sys.maxint
+     return limit
+ 
+ def remoteui(src, opts):
+diff --git a/mercurial/commands.py b/mercurial/commands.py
+--- a/mercurial/commands.py
++++ b/mercurial/commands.py
+@@ -1924,7 +1924,7 @@
+         displayer = cmdutil.show_changeset(ui, other, opts)
+         count = 0
+         for n in o:
+-            if count >= limit:
++            if limit is not None and count >= limit:
+                 break
+             parents = [p for p in other.changelog.parents(n) if p != nullid]
+             if opts.get('no_merges') and len(parents) == 2:
+diff --git a/mercurial/graphmod.py b/mercurial/graphmod.py
+--- a/mercurial/graphmod.py
++++ b/mercurial/graphmod.py
+@@ -18,7 +18,6 @@
+ """
+ 
+ from mercurial.node import nullrev
+-import sys
+ 
+ CHANGESET = 'C'
+ 
+@@ -37,14 +36,14 @@
+         yield (cur, CHANGESET, ctx, sorted(parents))
+         cur -= 1
+ 
+-def filerevs(repo, path, start, stop, limit=sys.maxint):
++def filerevs(repo, path, start, stop, limit=None):
+     """file cset DAG generator yielding (id, CHANGESET, ctx, [parentids]) tuples
+ 
+     This generator function walks through the revision history of a single
+     file from revision start down to revision stop.
+     """
+     filerev = len(repo.file(path)) - 1
+-    if limit < sys.maxint:
++    if limit is not None:
+         lower = max(0, filerev - limit + 1)
+         # ignore the "stop" parameter
+         stop = -1

File mqorder

-# HG changeset patch
-# User Nicolas Dumazet <nicdumz.commits@gmail.com>
-# Date 1260511792 -32400
-# Node ID 1c99072a8454b02fd993cf47c66b2b9eea72fa51
-# Parent  359c56728257c1d62a780f0a698e5657c14ed337
-mq: qpop: remove added files before re-adding removed files
-
-We need to do this to avoid file/directories conflicts.
-This causes patches removing a committed file and replacing it
-with a directory to be "unpoppable".
-
-diff --git a/hgext/mq.py b/hgext/mq.py
---- a/hgext/mq.py
-+++ b/hgext/mq.py
-@@ -1096,12 +1096,6 @@
-                 m, a, r, d = repo.status(qp, top)[:4]
-                 if d:
-                     raise util.Abort(_("deletions found between repo revs"))
--                for f in m:
--                    getfile(f, mmap[f], mmap.flags(f))
--                for f in r:
--                    getfile(f, mmap[f], mmap.flags(f))
--                for f in m + r:
--                    repo.dirstate.normal(f)
-                 for f in a:
-                     try:
-                         os.unlink(repo.wjoin(f))
-@@ -1111,6 +1105,12 @@
-                     try: os.removedirs(os.path.dirname(repo.wjoin(f)))
-                     except: pass
-                     repo.dirstate.forget(f)
-+                for f in m:
-+                    getfile(f, mmap[f], mmap.flags(f))
-+                for f in r:
-+                    getfile(f, mmap[f], mmap.flags(f))
-+                for f in m + r:
-+                    repo.dirstate.normal(f)
-                 repo.dirstate.setparents(qp, nullid)
-             for patch in reversed(self.applied[start:end]):
-                 self.ui.status(_("popping %s\n") % patch.name)
-diff --git a/tests/test-mq b/tests/test-mq
---- a/tests/test-mq
-+++ b/tests/test-mq
-@@ -561,3 +561,22 @@
- hg qseries -v
- hg up qparent
- hg qpop
-+
-+cd ..
-+hg init deletion-order
-+cd deletion-order
-+
-+touch a
-+hg ci -Aqm0
-+
-+hg qnew -DU rename-dir
-+hg rm a
-+
-+mkdir a b
-+touch a/a b/b
-+hg -q add a b
-+hg qref
-+
-+echo % test popping must remove files added in subdirectories first
-+hg qpop
-+cd ..
-diff --git a/tests/test-mq.out b/tests/test-mq.out
---- a/tests/test-mq.out
-+++ b/tests/test-mq.out
-@@ -612,3 +612,6 @@
- 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
- popping empty
- patch queue now empty
-+% test popping must remove files added in subdirectories first
-+popping rename-dir
-+patch queue now empty
+graphlimit
 symlink-basic
 dirstate-stat
 inotify-test-permissions
 addbug
-mqorder
-graphlimit
 debug
 iterators
+loglimit
 no-match-under
 matching
 inotify-moverepo