# HG changeset patch
# User Augie Fackler <r...@durin42.com>
# Date 1541634772 18000
#      Wed Nov 07 18:52:52 2018 -0500
# Node ID 69c1fd928cf6668e4ddbd6d26ebb53bb75e374c5
# Parent  93766fc0dafe96a41a18ddd74e1408fabd7d63ad
land: reinstate functionality to record acceptances in the take.log file

diff --git a/land b/land
--- a/land
+++ b/land
@@ -47,7 +47,7 @@ def _destcontains(node):
 # Find all accepted revisions
 all_accepted = [n for n in cq.draft() if cq.accepted(n)]
 
-acceptrange = collections.namedtuple('acceptrange', 'roots head')
+acceptrange = collections.namedtuple('acceptrange', 'roots head contents')
 
 def accepted_ranges(all_accepted):
     if not all_accepted:
@@ -71,15 +71,18 @@ def accepted_ranges(all_accepted):
     for head in accepted_heads:
         roots = []
         visit = [head]
+        contents = []
         while visit:
             current = visit.pop(-1)
             if _destcontains(current):
                 roots.append(current)
             elif current not in accepted_roots:
                 visit.extend(parents[current])
+                contents.append(current)
             else:
                 roots.extend(parents[current])
-        ranges.append(acceptrange(roots, head))
+                contents.append(current)
+        ranges.append(acceptrange(roots, head, contents))
 
     logging.debug('accepted roots: %s', ' '.join(accepted_roots))
     logging.debug('accepted heads: %s', ' '.join(accepted_heads))
@@ -102,15 +105,18 @@ for r in accepted_ranges(all_accepted):
         continue
     logging.debug('range %r is valid', r)
     heads.add(r.head)
-    take.append(r.head)
+    take.append(r)
 
 if take:
     logging.debug("landing changes in %s:", dest)
     cmd = "hg push -q -R %s %s" % (conf.source, dest)
-    for t in take:
-        logging.debug("\tlanding %s", t)
-        cmd += " -r %s" % t
+    allchanges = []
+    for r in take:
+        logging.debug("\tlanding %s", r.head)
+        cmd += " -r %s" % r.head
+        allchanges += r.contents
 
+    logging.debug("landing changes with %r", cmd)
     ret = os.system(cmd)
     if ret:
         print "exited %d" % ret
@@ -118,6 +124,11 @@ if take:
         # move bookmark to head of default branch or stable during freeze
         os.system("hg book -R %s -fr 'heads(default::)' @" % dest)
         with open("%s/.hg/take.log" % dest, "a") as f:
-            f.write(takelog)
+            for node in allchanges:
+                f.write('%(node)s %(author)s %(accepters)s\n' % {
+                    'node': node,
+                    'author': cq.author(node),
+                    'accepters': ' '.join(cq.accepted(node)),
+                })
 else:
     logging.debug("not landing any changes")
diff --git a/tests/test-land.t b/tests/test-land.t
--- a/tests/test-land.t
+++ b/tests/test-land.t
@@ -103,5 +103,9 @@ We expect to land 3::6.
   o  0:1ea7 default
   
 The `land` script should have written useful information in .hg/take.log in
-the destination repository. BUG: this doesn't work :(
+the destination repository.
   $ cat .hg/take.log
+  ee2d47383a2e910ced48bb5b25d04c2c94a7495d alice alice bob
+  472110eab2fa3ee331c706b610596d9c40d00f01 alice alice bob
+  6cfb447dff0e28177a4bc60d2a20f5d449f322ee alice alice bob
+  0cccaca5797043d1bd484de71068c4e47384dc84 alice alice bob
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to