trafodion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dbirds...@apache.org
Subject [1/2] incubator-trafodion git commit: [TRAFODION-2835] Add script to aid in merge conflict resolution
Date Tue, 12 Dec 2017 01:29:14 GMT
Repository: incubator-trafodion
Updated Branches:
  refs/heads/master 890ec605e -> d0cdf6a1a


[TRAFODION-2835] Add script to aid in merge conflict resolution


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/69e15743
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/69e15743
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/69e15743

Branch: refs/heads/master
Commit: 69e15743d797b62dab7c447aea069facba26e45b
Parents: 1485136
Author: Dave Birdsall <dbirdsall@apache.org>
Authored: Fri Dec 8 22:55:48 2017 +0000
Committer: Dave Birdsall <dbirdsall@apache.org>
Committed: Fri Dec 8 22:55:48 2017 +0000

----------------------------------------------------------------------
 core/sqf/sql/scripts/beheadMergeConflict.py | 112 +++++++++++++++++++++++
 1 file changed, 112 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/69e15743/core/sqf/sql/scripts/beheadMergeConflict.py
----------------------------------------------------------------------
diff --git a/core/sqf/sql/scripts/beheadMergeConflict.py b/core/sqf/sql/scripts/beheadMergeConflict.py
new file mode 100644
index 0000000..13a7e60
--- /dev/null
+++ b/core/sqf/sql/scripts/beheadMergeConflict.py
@@ -0,0 +1,112 @@
+# @@@ START COPYRIGHT @@@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# @@@ END COPYRIGHT @@@
+#
+#  This script is useful for resolving merge conflicts in regress
+#  test expected results files.
+#
+#  Very often a conflict occurs because a test has been updated
+#  in two branches, and that test has output containing DDL timestamps
+#  or plan IDs or other unimportant information that varies on every
+#  regress run. When these are the only differences, the conflict
+#  resolution is simple: Delete all the HEAD stuff and accept all the
+#  new stuff. This script does exactly that.
+#
+#  The script looks for lines of the following form:
+#
+#  <<<<<<< HEAD
+#  -- Definition current  Wed Nov 29 08:53:46 2017
+#  =======
+#  -- Definition current  Wed Dec  6 19:32:34 2017
+#  >>>>>>> b149874... [TRAFODION-2827] Turn update costing code on by
default
+#
+#  When it finds this, it removes the lines from <<<<<< HEAD to ======,
+#  and removes the final >>>>>> line, leaving just:
+#
+#  -- Definition current  Wed Dec  6 19:32:34 2017
+#
+
+import os
+import sys
+import subprocess 
+import sets
+import datetime
+import argparse  # requires Python 2.7
+
+# The class BeheadMergeConflicts does the heavy lifting
+
+class BeheadMergeConflicts:
+    #
+
+    def __init__(self, FileName):
+        self.FileName = FileName
+        self.state = 0
+
+    def removeConflicts(self):
+
+        try:
+            f = open(self.FileName)
+            state = 0
+            for line in f:
+                line = line.rstrip('\n')  # get rid of trailing return character
+                if state == 0:
+                    if line == "<<<<<<< HEAD":
+                        state = 1
+                    else:
+                        print line
+                elif state == 1:
+                    if line == "=======":
+                        state = 2
+                elif state == 2:
+                    if line.startswith(">>>>>>> "):
+                        state = 0
+                    else:
+                        print line
+                
+            f.close()
+         
+        except IOError as detail:
+            print "Could not open " + self.FileName
+            print detail        
+        
+
+
+
+
+# beginning of main
+
+
+# process command line arguments
+
+parser = argparse.ArgumentParser(
+    description='This script removes the "HEAD" part of git merge conflicts.')
+parser.add_argument("FileName", help='The name of the file that you wish to remove merge
conflicts from.')
+
+args = parser.parse_args()  # exits and prints help if args are incorrect
+
+exitCode = 0
+
+conflictBeheader = BeheadMergeConflicts(args.FileName)
+
+conflictBeheader.removeConflicts()
+
+exit(exitCode)   
+
+


Mime
View raw message